diff options
author | tb <> | 2018-10-20 16:07:09 +0000 |
---|---|---|
committer | tb <> | 2018-10-20 16:07:09 +0000 |
commit | 0f0fb62e037f5e816107dc4f0429de75c5957f84 (patch) | |
tree | 28dceffa7b3ebc20aebfda763e4c4387e16378fd | |
parent | 7ff63dc8bd7dbad26207de0396f83320e8e5c3a4 (diff) | |
download | openbsd-0f0fb62e037f5e816107dc4f0429de75c5957f84.tar.gz openbsd-0f0fb62e037f5e816107dc4f0429de75c5957f84.tar.bz2 openbsd-0f0fb62e037f5e816107dc4f0429de75c5957f84.zip |
Avoid calling memcpy with a length <= 0. Reported due to a GCC 7.3.0
compiler warning by Pavel Kraynyukhov. A similar fix was made in
OpenSSL commit 369e93398b68b8a328e6c1d766222b.
ok inoguchi
-rw-r--r-- | src/lib/libcrypto/asn1/a_bitstr.c | 11 |
1 files changed, 6 insertions, 5 deletions
diff --git a/src/lib/libcrypto/asn1/a_bitstr.c b/src/lib/libcrypto/asn1/a_bitstr.c index 11771bdd02..7fd40d8a8c 100644 --- a/src/lib/libcrypto/asn1/a_bitstr.c +++ b/src/lib/libcrypto/asn1/a_bitstr.c | |||
@@ -1,4 +1,4 @@ | |||
1 | /* $OpenBSD: a_bitstr.c,v 1.28 2018/05/13 13:48:08 jsing Exp $ */ | 1 | /* $OpenBSD: a_bitstr.c,v 1.29 2018/10/20 16:07:09 tb Exp $ */ |
2 | /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) | 2 | /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) |
3 | * All rights reserved. | 3 | * All rights reserved. |
4 | * | 4 | * |
@@ -118,10 +118,11 @@ i2c_ASN1_BIT_STRING(ASN1_BIT_STRING *a, unsigned char **pp) | |||
118 | 118 | ||
119 | *(p++) = (unsigned char)bits; | 119 | *(p++) = (unsigned char)bits; |
120 | d = a->data; | 120 | d = a->data; |
121 | memcpy(p, d, len); | 121 | if (len > 0) { |
122 | p += len; | 122 | memcpy(p, d, len); |
123 | if (len > 0) | 123 | p += len; |
124 | p[-1]&=(0xff << bits); | 124 | p[-1] &= 0xff << bits; |
125 | } | ||
125 | *pp = p; | 126 | *pp = p; |
126 | return (ret); | 127 | return (ret); |
127 | } | 128 | } |