diff --git a/src/lib/key.c b/src/lib/key.c index f8ce2a8..2ebca9c 100644 --- a/src/lib/key.c +++ b/src/lib/key.c @@ -86,8 +86,16 @@ keypair_t *get_keypair(char *username) } uint8_t pk[PK_SIZE], sk[SK_SIZE]; - fread(pk, 1, PK_SIZE, keyf); - fread(sk, 1, SK_SIZE, keyf); + size_t bytes_read; + bytes_read = fread(pk, 1, PK_SIZE, keyf); + if (bytes_read != PK_SIZE) { + error(1, "Error reading public key from file, bytes_read(%zu)!=%d", bytes_read, PK_SIZE); + } + + bytes_read = fread(sk, 1, SK_SIZE, keyf); + if (bytes_read != SK_SIZE) { + error(1, "Error reading secret key from file, bytes_read(%zu)!=%d", bytes_read, SK_SIZE); + } fclose(keyf); keypair_t *kp = memalloc(sizeof(keypair_t)); diff --git a/src/lib/util.c b/src/lib/util.c index 4f4479a..9743a90 100644 --- a/src/lib/util.c +++ b/src/lib/util.c @@ -94,11 +94,11 @@ void mkdir_p(const char *file) snprintf(path, PATH_MAX, "%s%s", home, file + 1); } else { strcpy(path, file); - } + } /* fix first / not appearing in the string */ if (path[0] == '/') - strcat(dir_path, "/"); + strcat(dir_path, "/"); /* Find last occurrence of '/' */ char *last_slash = strrchr(path, '/');