diff options
author | Damien Miller <djm@mindrot.org> | 2018-07-10 11:39:52 +0200 |
---|---|---|
committer | Damien Miller <djm@mindrot.org> | 2018-07-10 11:39:52 +0200 |
commit | 120a1ec74e8d9d29f4eb9a27972ddd22351ddef9 (patch) | |
tree | 52308557de781f1d8ffb083369e0c209bc305c02 /entropy.c | |
parent | upstream: kerberos/gssapi fixes for buffer removal (diff) | |
download | openssh-120a1ec74e8d9d29f4eb9a27972ddd22351ddef9.tar.xz openssh-120a1ec74e8d9d29f4eb9a27972ddd22351ddef9.zip |
Adapt portable to legacy buffer API removal
Diffstat (limited to 'entropy.c')
-rw-r--r-- | entropy.c | 32 |
1 files changed, 19 insertions, 13 deletions
@@ -53,7 +53,8 @@ #include "atomicio.h" #include "pathnames.h" #include "log.h" -#include "buffer.h" +#include "sshbuf.h" +#include "ssherr.h" /* * Portable OpenSSH PRNG seeding: @@ -181,29 +182,34 @@ seed_from_prngd(unsigned char *buf, size_t bytes) } void -rexec_send_rng_seed(Buffer *m) +rexec_send_rng_seed(struct sshbuf *m) { u_char buf[RANDOM_SEED_SIZE]; + size_t len = sizeof(buf); + int r; if (RAND_bytes(buf, sizeof(buf)) <= 0) { error("Couldn't obtain random bytes (error %ld)", ERR_get_error()); - buffer_put_string(m, "", 0); - } else - buffer_put_string(m, buf, sizeof(buf)); + len = 0; + } + if ((r = sshbuf_put_string(m, buf, len)) != 0) + fatal("%s: buffer error: %s", __func__, ssh_err(r)); + explicit_bzero(buf, sizeof(buf)); } void -rexec_recv_rng_seed(Buffer *m) +rexec_recv_rng_seed(struct sshbuf *m) { - u_char *buf; - u_int len; + u_char *buf = NULL; + size_t len = 0; + int r; - buf = buffer_get_string_ret(m, &len); - if (buf != NULL) { - debug3("rexec_recv_rng_seed: seeding rng with %u bytes", len); - RAND_add(buf, len, len); - } + if ((r = sshbuf_get_string_direct(m, &buf, &len)) != 0 + fatal("%s: buffer error: %s", __func__, ssh_err(r)); + + debug3("rexec_recv_rng_seed: seeding rng with %u bytes", len); + RAND_add(buf, len, len); } #endif /* OPENSSL_PRNG_ONLY */ |