aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorAndreas Schneider <asn@cryptomilk.org>2016-11-06 11:15:23 +0100
committerAndreas Schneider <asn@cryptomilk.org>2016-11-06 11:15:23 +0100
commit02be4802d5f036e777671e188781e11c9bd7ad9e (patch)
treefa3657103353c292d47fe17460e4efba98387af6 /src
parent5437deed1bd026ae00a2fb9209b6a87807fa358b (diff)
downloadlibssh-02be4802d5f036e777671e188781e11c9bd7ad9e.tar.gz
libssh-02be4802d5f036e777671e188781e11c9bd7ad9e.tar.xz
libssh-02be4802d5f036e777671e188781e11c9bd7ad9e.zip
pki_ed25519: Do paranoia checks before we allocate memory
Signed-off-by: Andreas Schneider <asn@cryptomilk.org>
Diffstat (limited to 'src')
-rw-r--r--src/pki_ed25519.c12
1 files changed, 7 insertions, 5 deletions
diff --git a/src/pki_ed25519.c b/src/pki_ed25519.c
index a51f6c6b..393948ac 100644
--- a/src/pki_ed25519.c
+++ b/src/pki_ed25519.c
@@ -76,16 +76,18 @@ int pki_ed25519_sign(const ssh_key privkey,
if (rc != 0) {
goto error;
}
- sig->ed25519_sig = malloc(ED25519_SIG_LEN);
- if (sig->ed25519_sig == NULL) {
- goto error;
- }
/* This shouldn't happen */
if (dlen - hlen != ED25519_SIG_LEN) {
goto error;
}
- memcpy(sig->ed25519_sig, buffer, dlen - hlen);
+
+ sig->ed25519_sig = malloc(ED25519_SIG_LEN);
+ if (sig->ed25519_sig == NULL) {
+ goto error;
+ }
+
+ memcpy(sig->ed25519_sig, buffer, ED25519_SIG_LEN);
SAFE_FREE(buffer);
return SSH_OK;