summaryrefslogtreecommitdiffstats
path: root/usr.bin/ssh/sshbuf-getput-crypto.c
diff options
context:
space:
mode:
authordjm <djm@openbsd.org>2015-01-12 15:18:07 +0000
committerdjm <djm@openbsd.org>2015-01-12 15:18:07 +0000
commit38940dfd04fe962674726534b4e88593400cfc1c (patch)
tree8a0a0031cec41cc628fc397c0a46d2dd5313934d /usr.bin/ssh/sshbuf-getput-crypto.c
parentMake sure the given user exists. (diff)
downloadwireguard-openbsd-38940dfd04fe962674726534b4e88593400cfc1c.tar.xz
wireguard-openbsd-38940dfd04fe962674726534b4e88593400cfc1c.zip
apparently memcpy(x, NULL, 0) is undefined behaviour according to
C99 (cf. sections 7.21.1 and 7.1.4), so check skip memcpy calls when length==0; ok markus@
Diffstat (limited to 'usr.bin/ssh/sshbuf-getput-crypto.c')
-rw-r--r--usr.bin/ssh/sshbuf-getput-crypto.c5
1 files changed, 3 insertions, 2 deletions
diff --git a/usr.bin/ssh/sshbuf-getput-crypto.c b/usr.bin/ssh/sshbuf-getput-crypto.c
index 79951afda17..f086cae06eb 100644
--- a/usr.bin/ssh/sshbuf-getput-crypto.c
+++ b/usr.bin/ssh/sshbuf-getput-crypto.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: sshbuf-getput-crypto.c,v 1.2 2014/06/18 15:42:09 naddy Exp $ */
+/* $OpenBSD: sshbuf-getput-crypto.c,v 1.3 2015/01/12 15:18:07 djm Exp $ */
/*
* Copyright (c) 2011 Damien Miller
*
@@ -189,7 +189,8 @@ sshbuf_put_bignum1(struct sshbuf *buf, const BIGNUM *v)
return r;
}
POKE_U16(dp, len_bits);
- memcpy(dp + 2, d, len_bytes);
+ if (len_bytes != 0)
+ memcpy(dp + 2, d, len_bytes);
bzero(d, sizeof(d));
return 0;
}