mirror of
https://git.libssh.org/projects/libssh.git
synced 2025-11-29 01:03:57 +03:00
pki_ed25519: Do paranoia checks before we allocate memory
Signed-off-by: Andreas Schneider <asn@cryptomilk.org>
This commit is contained in:
@@ -76,16 +76,18 @@ int pki_ed25519_sign(const ssh_key privkey,
|
|||||||
if (rc != 0) {
|
if (rc != 0) {
|
||||||
goto error;
|
goto error;
|
||||||
}
|
}
|
||||||
sig->ed25519_sig = malloc(ED25519_SIG_LEN);
|
|
||||||
if (sig->ed25519_sig == NULL) {
|
|
||||||
goto error;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* This shouldn't happen */
|
/* This shouldn't happen */
|
||||||
if (dlen - hlen != ED25519_SIG_LEN) {
|
if (dlen - hlen != ED25519_SIG_LEN) {
|
||||||
goto error;
|
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);
|
SAFE_FREE(buffer);
|
||||||
|
|
||||||
return SSH_OK;
|
return SSH_OK;
|
||||||
|
|||||||
Reference in New Issue
Block a user