]> git.ipfire.org Git - thirdparty/binutils-gdb.git/commitdiff
buffer overflow in libctf tests
authorAlan Modra <amodra@gmail.com>
Wed, 24 Apr 2024 00:00:24 +0000 (09:30 +0930)
committerAlan Modra <amodra@gmail.com>
Wed, 24 Apr 2024 00:03:03 +0000 (09:33 +0930)
       * testsuite/libctf-regression/gzrewrite.c (main): Don't overflow
       "a" buffer in "after adding types" check.
       * testsuite/libctf-regression/zrewrite.c (main): Likewise.

libctf/testsuite/libctf-regression/gzrewrite.c
libctf/testsuite/libctf-regression/zrewrite.c

index 99722200950f43e952dca515157256eb3ff0c788..2e679e85bfee63fe2191d7214b9dc7579f5325b0 100644 (file)
@@ -114,7 +114,7 @@ main (int argc, char *argv[])
   if ((b = read_gz ("tmpdir/two.gz", &b_len)) == NULL)
     goto read_err;
 
-  if (memcmp (a, b, b_len) == 0)
+  if (a_len == b_len && memcmp (a, b, b_len) == 0)
     {
       fprintf (stderr, "gzwrites after adding types does not change the dict\n");
       return 1;
index a88c824b568e7f266d86f6140752bd4113fb2498..5e061f10a5fa266c25e6ea15a4869ce938b0b686 100644 (file)
@@ -109,7 +109,7 @@ main (int argc, char *argv[])
 
   b = read_file ("tmpdir/two", &b_len);
 
-  if (memcmp (a, b, b_len) == 0)
+  if (a_len == b_len && memcmp (a, b, b_len) == 0)
     {
       fprintf (stderr, "compress_writes after adding types does not change the dict\n");
       return 1;