From 41583c1011ef1b3b54a8ba7e62bad47a9d13ead5 Mon Sep 17 00:00:00 2001 From: Andrew Bettison Date: Sun, 20 May 2012 15:25:19 +0930 Subject: [PATCH] Fix bug in "rhizome add file" command Was not opening keyring file properly --- commandline.c | 5 ++--- keyring.c | 16 ++++++++-------- 2 files changed, 10 insertions(+), 11 deletions(-) diff --git a/commandline.c b/commandline.c index 06aa8124..fbc1f529 100644 --- a/commandline.c +++ b/commandline.c @@ -1083,7 +1083,7 @@ int app_rhizome_add_file(int argc, const char *const *argv, struct command_line_ cli_arg(argc, argv, o, "manifestpath", &manifestpath, NULL, ""); if (create_serval_instance_dir() == -1) return -1; - if (!keyring_open_with_pins(pin)) + if (!(keyring = keyring_open_with_pins((char *)pin))) return -1; if (rhizome_opendb() == -1) return -1; @@ -1323,8 +1323,7 @@ int app_keyring_set_did(int argc, const char *const *argv, struct command_line_o if (strlen(did)>31) return WHY("DID too long (31 digits max)"); if (strlen(name)>63) return WHY("Name too long (31 char max)"); - keyring = keyring_open_with_pins((char *)pin); - if (!keyring) + if (!(keyring = keyring_open_with_pins((char *)pin))) return -1; unsigned char packedSid[SID_SIZE]; diff --git a/keyring.c b/keyring.c index ebac62a7..e704b592 100644 --- a/keyring.c +++ b/keyring.c @@ -1360,15 +1360,15 @@ int keyring_enter_pins(keyring_file *k, const char *pinlist) keyring_file *keyring_open_with_pins(const char *pinlist) { keyring_file *k = NULL; - if (create_serval_instance_dir() == -1) + if (create_serval_instance_dir() == -1) return NULL; - char keyringFile[1024]; - if (!FORM_SERVAL_INSTANCE_PATH(keyringFile, "serval.keyring")) - return NULL; - if ((k = keyring_open(keyringFile)) == NULL) - return NULL; - keyring_enter_pins(k,pinlist); - return k; + char keyringFile[1024]; + if (!FORM_SERVAL_INSTANCE_PATH(keyringFile, "serval.keyring")) + return NULL; + if ((k = keyring_open(keyringFile)) == NULL) + return NULL; + keyring_enter_pins(k,pinlist); + return k; } /* If no identities, create an initial identity with a phone number.