]> git.ipfire.org Git - thirdparty/glibc.git/commitdiff
support: Report NULL blobs explicitly in TEST_COMPARE
authorFlorian Weimer <fweimer@redhat.com>
Thu, 16 May 2019 12:50:15 +0000 (14:50 +0200)
committerFlorian Weimer <fweimer@redhat.com>
Thu, 16 May 2019 12:50:15 +0000 (14:50 +0200)
Provide an explicit diagnostic if the length is positive, and
do not just crash with a null pointer dereference.  Null pointers
are only valid if the length is zero, so this can only happen with
a faulty test.

ChangeLog
support/support_test_compare_blob.c

index ea7b3d4f48a16bb1e0873f6173afcc2fa1c575c3..0f6ee3ec8e45a749386513f3e348086cdf4bb161 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,8 @@
+2019-05-16  Florian Weimer  <fweimer@redhat.com>
+
+       * support/support_test_compare_blob.c (report_blob): Report
+       incorrect NULL blobs.
+
 2019-05-15  Mark Wielaard  <mark@klomp.org>
 
        [BZ# 24476]
index 5bcb03418c564257c29b259dea1a8b92edfb757d..37f012257d9af24e8d5dd9a1f0eb200ae178d28f 100644 (file)
@@ -33,7 +33,9 @@ static void
 report_blob (const char *what, const unsigned char *blob,
              unsigned long int length, const char *expr)
 {
-  if (length > 0)
+  if (blob == NULL && length > 0)
+    printf ("  %s (evaluated from %s): NULL\n", what, expr);
+  else if (length > 0)
     {
       printf ("  %s (evaluated from %s):\n", what, expr);
       char *quoted = support_quote_blob (blob, length);