projects
/
oweals
/
openssl.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
| inline |
side by side
(parent:
4379d5c
)
Avoid calling memcpy with lenght of 0
author
Kurt Roeckx
<kurt@roeckx.be>
Thu, 26 May 2016 16:40:32 +0000
(18:40 +0200)
committer
Kurt Roeckx
<kurt@roeckx.be>
Fri, 27 May 2016 19:01:12 +0000
(21:01 +0200)
We can call memcpy() with a pointer 1 past the last allocated byte and length
of 0 and you can argue that that's undefined behaviour.
Reported by tis-interpreter
Reviewed-by: Rich Salz <rsalz@openssl.org>
GH: #1132
crypto/asn1/a_bitstr.c
patch
|
blob
|
history
diff --git
a/crypto/asn1/a_bitstr.c
b/crypto/asn1/a_bitstr.c
index 2f0d8f8c2d58c4da0edb165c3a29f6fdd2ebeabe..33be907f9d5edd33c2d086404d815fcb4b7b9f3b 100644
(file)
--- a/
crypto/asn1/a_bitstr.c
+++ b/
crypto/asn1/a_bitstr.c
@@
-66,10
+66,11
@@
int i2c_ASN1_BIT_STRING(ASN1_BIT_STRING *a, unsigned char **pp)
*(p++) = (unsigned char)bits;
d = a->data;
- memcpy(p, d, len);
-
p += len
;
- if (len > 0)
+ if (len > 0) {
+
memcpy(p, d, len)
;
+ p += len;
p[-1] &= (0xff << bits);
+ }
*pp = p;
return (ret);
}