]> git.ipfire.org Git - thirdparty/openssl.git/commitdiff
Fix buggy stringop-overflow error on s390
authorNeil Horman <nhorman@openssl.org>
Fri, 20 Jun 2025 14:22:10 +0000 (10:22 -0400)
committerNeil Horman <nhorman@openssl.org>
Fri, 20 Jun 2025 15:00:08 +0000 (11:00 -0400)
Despite some recent changes to our s390 builds, we're still seeing
errors due to some stringop-overflow warnings:
https://github.com/openssl/openssl/actions/runs/15748518222/job/44389197443

It appears to be caused because the static analysis that gcc preforms in
gcc 12 (the version of the compiler on our s390 runner), fails to infer
the proper sizes of the buffer on which we do the reverse memcpy in
swap_copy(), resulting in warnings, which on --strict-warnings builds,
breaks us.

Fix it by using inlen rather than outlen to limit the copy length,
adjusting it if need be to match the size of the output buffer in
le_copy().  This allows the compiler to properly infer the array length
constraints and suppress the warnings.

Reviewed-by: Tomas Mraz <tomas@openssl.org>
Reviewed-by: Matt Caswell <matt@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/27864)

test/params_api_test.c

index 7d82316a19ce6831992ba31877362e7556c08d71..cc34b1f1de408c54c1283cf31a5d59ff019d01dc 100644 (file)
@@ -42,11 +42,13 @@ static void le_copy(unsigned char *out, size_t outlen,
     if (IS_LITTLE_ENDIAN) {
         memcpy(out, in, outlen);
     } else {
-        if (outlen < inlen)
+        if (outlen < inlen) {
             in = (const char *)in + inlen - outlen;
+            inlen = outlen;
+        }
         if (!ossl_assert(outlen <= inlen))
             return;
-        swap_copy(out, in, outlen);
+        swap_copy(out, in, inlen);
     }
 }