From: Tobias Brunner Date: Thu, 22 Aug 2019 14:27:19 +0000 (+0200) Subject: asn1: Fix a compiler warning with GCC 9.1 X-Git-Tag: 5.8.1rc1~6 X-Git-Url: http://git.ipfire.org/gitweb/gitweb.cgi?a=commitdiff_plain;h=a4279fcc386c9bb396d1d1fc46d6c14b2f37cec4;p=thirdparty%2Fstrongswan.git asn1: Fix a compiler warning with GCC 9.1 Compiling with GCC 9.1, as e.g. happens on AppVeyor, results in the following warning: asn1/asn1.c: In function 'asn1_integer': asn1/asn1.c:871:24: error: '' may be used uninitialized in this function [-Werror=maybe-uninitialized] 871 | len = content.len + ((*content.ptr & 0x80) ? 1 : 0); | ^~~~~~~~~~~~ Some experiments showed that the problem was the chunk_from_chars() assignment. This might be because the temporary chunk_t that was assigned to the variable was defined in a sub-block, so it might actually be undefined later when *content.ptr is read. --- diff --git a/src/libstrongswan/asn1/asn1.c b/src/libstrongswan/asn1/asn1.c index aa649e9697..f75e942578 100644 --- a/src/libstrongswan/asn1/asn1.c +++ b/src/libstrongswan/asn1/asn1.c @@ -851,15 +851,14 @@ chunk_t asn1_bitstring(const char *mode, chunk_t content) */ chunk_t asn1_integer(const char *mode, chunk_t content) { - chunk_t object; + chunk_t zero = chunk_from_chars(0x00), object; size_t len; u_char *pos; bool move; - if (content.len == 0) { /* make sure 0 is encoded properly */ - content = chunk_from_chars(0x00); + content = zero; move = FALSE; } else