From 0f0fb62e037f5e816107dc4f0429de75c5957f84 Mon Sep 17 00:00:00 2001 From: tb <> Date: Sat, 20 Oct 2018 16:07:09 +0000 Subject: 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 --- src/lib/libcrypto/asn1/a_bitstr.c | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) (limited to 'src') 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 @@ -/* $OpenBSD: a_bitstr.c,v 1.28 2018/05/13 13:48:08 jsing Exp $ */ +/* $OpenBSD: a_bitstr.c,v 1.29 2018/10/20 16:07:09 tb Exp $ */ /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) * All rights reserved. * @@ -118,10 +118,11 @@ 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) - p[-1]&=(0xff << bits); + if (len > 0) { + memcpy(p, d, len); + p += len; + p[-1] &= 0xff << bits; + } *pp = p; return (ret); } -- cgit v1.2.3-55-g6feb