[Cryptech-Commits] [sw/stm32] branch ksng updated: Handle race condition while fetching key metadata for display.

git at cryptech.is git at cryptech.is
Wed Apr 12 21:01:25 UTC 2017


This is an automated email from the git hooks/post-receive script.

sra at hactrn.net pushed a commit to branch ksng
in repository sw/stm32.

The following commit(s) were added to refs/heads/ksng by this push:
     new 108b532  Handle race condition while fetching key metadata for display.
108b532 is described below

commit 108b532b9ae4c9138ad1a25e9ef437183711a05b
Author: Rob Austein <sra at hactrn.net>
AuthorDate: Wed Apr 12 16:58:50 2017 -0400

    Handle race condition while fetching key metadata for display.
    
    Fetching a list of keys and all of their metadata isn't an atomic
    process, nor, probably, should it be, so we need to cope with things
    like a key being deleted via the RPC interface while we're fetching
    its metadata for display on the console interface.
---
 projects/hsm/mgmt-keystore.c | 12 ++++++------
 1 file changed, 6 insertions(+), 6 deletions(-)

diff --git a/projects/hsm/mgmt-keystore.c b/projects/hsm/mgmt-keystore.c
index 230bded..f24f49b 100644
--- a/projects/hsm/mgmt-keystore.c
+++ b/projects/hsm/mgmt-keystore.c
@@ -208,21 +208,21 @@ static int show_keys(struct cli_def *cli, const char *title)
 	for (int i = 0; i < n; i++) {
 
 	    if ((status = hal_uuid_format(&uuids[i], key_name, sizeof(key_name))) != LIBHAL_OK) {
-		cli_print(cli, "Could not convert key name: %s",
+		cli_print(cli, "Could not convert key name, skipping: %s",
 			  hal_error_string(status));
-		return CLI_ERROR;
+		continue;
 	    }
 
 	    if ((status = hal_rpc_pkey_open(client, session, &pkey, &uuids[i])) != LIBHAL_OK) {
-	        cli_print(cli, "Could not open key %s: %s",
+	        cli_print(cli, "Could not open key %s, skipping: %s",
 			  key_name, hal_error_string(status));
-		return CLI_ERROR;
+		continue;
 	    }
 
 	    if ((status = hal_rpc_pkey_get_key_type(pkey, &type))   != LIBHAL_OK ||
 		(status = hal_rpc_pkey_get_key_curve(pkey, &curve)) != LIBHAL_OK ||
 		(status = hal_rpc_pkey_get_key_flags(pkey, &flags)) != LIBHAL_OK)
-	        cli_print(cli, "Could not fetch metadata for key %s: %s",
+	        cli_print(cli, "Could not fetch metadata for key %s, skipping: %s",
 			  key_name, hal_error_string(status));
 
 	    if (status == LIBHAL_OK)
@@ -231,7 +231,7 @@ static int show_keys(struct cli_def *cli, const char *title)
 	        (void) hal_rpc_pkey_close(pkey);
 
 	    if (status != LIBHAL_OK)
-	        return CLI_ERROR;
+	        continue;
 
 	    const char *type_name = "unknown";
 	    switch (type) {

-- 
To stop receiving notification emails like this one, please contact
the administrator of this repository.


More information about the Commits mailing list