summaryrefslogtreecommitdiff
path: root/sshbuf-getput-crypto.c
diff options
context:
space:
mode:
authordjm@openbsd.org <djm@openbsd.org>2015-01-12 15:18:07 +0000
committerDamien Miller <djm@mindrot.org>2015-01-13 19:25:52 +1100
commita7f49dcb527dd17877fcb8d5c3a9a6f550e0bba5 (patch)
tree0db86a4b895a3ec9bf168df6d385cc9544184dc6 /sshbuf-getput-crypto.c
parent905fe30fca82f38213763616d0d26eb6790bde33 (diff)
upstream commit
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 'sshbuf-getput-crypto.c')
-rw-r--r--sshbuf-getput-crypto.c5
1 files changed, 3 insertions, 2 deletions
diff --git a/sshbuf-getput-crypto.c b/sshbuf-getput-crypto.c
index 74351d3e5..7fad28bb7 100644
--- a/sshbuf-getput-crypto.c
+++ b/sshbuf-getput-crypto.c
@@ -1,4 +1,4 @@
1/* $OpenBSD: sshbuf-getput-crypto.c,v 1.2 2014/06/18 15:42:09 naddy Exp $ */ 1/* $OpenBSD: sshbuf-getput-crypto.c,v 1.3 2015/01/12 15:18:07 djm Exp $ */
2/* 2/*
3 * Copyright (c) 2011 Damien Miller 3 * Copyright (c) 2011 Damien Miller
4 * 4 *
@@ -195,7 +195,8 @@ sshbuf_put_bignum1(struct sshbuf *buf, const BIGNUM *v)
195 return r; 195 return r;
196 } 196 }
197 POKE_U16(dp, len_bits); 197 POKE_U16(dp, len_bits);
198 memcpy(dp + 2, d, len_bytes); 198 if (len_bytes != 0)
199 memcpy(dp + 2, d, len_bytes);
199 bzero(d, sizeof(d)); 200 bzero(d, sizeof(d));
200 return 0; 201 return 0;
201} 202}