about summary refs log tree commit diff
diff options
context:
space:
mode:
authorFlorian Weimer <fweimer@redhat.com>2019-05-16 14:50:15 +0200
committerFlorian Weimer <fweimer@redhat.com>2019-05-16 14:50:15 +0200
commit85b0e1e8a62c052e73b167ebf0c1a6a216525dce (patch)
treec6a7f6ba997191b8a4f0f010f5e0d5091f538b04
parent11b451c8868d8a2b0edc5dfd44fc58d9ee538be0 (diff)
downloadglibc-85b0e1e8a62c052e73b167ebf0c1a6a216525dce.tar.gz
glibc-85b0e1e8a62c052e73b167ebf0c1a6a216525dce.tar.xz
glibc-85b0e1e8a62c052e73b167ebf0c1a6a216525dce.zip
support: Report NULL blobs explicitly in TEST_COMPARE
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.
-rw-r--r--ChangeLog5
-rw-r--r--support/support_test_compare_blob.c4
2 files changed, 8 insertions, 1 deletions
diff --git a/ChangeLog b/ChangeLog
index ea7b3d4f48..0f6ee3ec8e 100644
--- 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]
diff --git a/support/support_test_compare_blob.c b/support/support_test_compare_blob.c
index 5bcb03418c..37f012257d 100644
--- a/support/support_test_compare_blob.c
+++ b/support/support_test_compare_blob.c
@@ -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);