aboutsummaryrefslogtreecommitdiff
path: root/src/pki_container_openssh.c
diff options
context:
space:
mode:
authorAndreas Schneider <asn@cryptomilk.org>2018-07-05 10:47:49 +0200
committerAndreas Schneider <asn@cryptomilk.org>2018-07-05 12:12:14 +0200
commitc503bb572eee1a166ce5e631785b7d24e6319605 (patch)
tree6ab8c088fe5f2764fffe91ef9ea9d9640cf63ed1 /src/pki_container_openssh.c
parent36a727e656a7fcd91722cf2d050fc87d55410b5b (diff)
downloadlibssh-c503bb572eee1a166ce5e631785b7d24e6319605.tar.gz
libssh-c503bb572eee1a166ce5e631785b7d24e6319605.tar.xz
libssh-c503bb572eee1a166ce5e631785b7d24e6319605.zip
crytpo: Make sure we check return of ssh_get_random() correctly
Signed-off-by: Andreas Schneider <asn@cryptomilk.org>
Diffstat (limited to 'src/pki_container_openssh.c')
-rw-r--r--src/pki_container_openssh.c15
1 files changed, 13 insertions, 2 deletions
diff --git a/src/pki_container_openssh.c b/src/pki_container_openssh.c
index 22fccbc6..53e1e7fe 100644
--- a/src/pki_container_openssh.c
+++ b/src/pki_container_openssh.c
@@ -576,6 +576,7 @@ ssh_string ssh_pki_openssh_privkey_export(const ssh_key privkey,
int to_encrypt=0;
unsigned char *b64;
uint32_t str_len, len;
+ int ok;
int rc;
if (privkey == NULL) {
@@ -594,7 +595,11 @@ ssh_string ssh_pki_openssh_privkey_export(const ssh_key privkey,
if(buffer == NULL || pubkey_s == NULL){
goto error;
}
- ssh_get_random(&rnd, sizeof(rnd), 0);
+
+ ok = ssh_get_random(&rnd, sizeof(rnd), 0);
+ if (!ok) {
+ goto error;
+ }
privkey_buffer = ssh_buffer_new();
if (privkey_buffer == NULL) {
@@ -634,7 +639,13 @@ ssh_string ssh_pki_openssh_privkey_export(const ssh_key privkey,
ssh_buffer_free(kdf_buf);
goto error;
}
- ssh_get_random(ssh_string_data(salt),16, 0);
+
+ ok = ssh_get_random(ssh_string_data(salt), 16, 0);
+ if (!ok) {
+ ssh_buffer_free(kdf_buf);
+ goto error;
+ }
+
ssh_buffer_pack(kdf_buf, "Sd", salt, rounds);
kdf_options = ssh_string_new(ssh_buffer_get_len(kdf_buf));
if (kdf_options == NULL){