From patchwork Fri May 3 16:53:56 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Florian Weimer X-Patchwork-Id: 32498 Received: (qmail 60208 invoked by alias); 3 May 2019 16:54:01 -0000 Mailing-List: contact libc-alpha-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: libc-alpha-owner@sourceware.org Delivered-To: mailing list libc-alpha@sourceware.org Received: (qmail 60200 invoked by uid 89); 3 May 2019 16:54:01 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-19.1 required=5.0 tests=AWL, BAYES_00, GIT_PATCH_0, GIT_PATCH_1, GIT_PATCH_2, GIT_PATCH_3, SPF_HELO_PASS autolearn=ham version=3.3.1 spammy= X-HELO: mx1.redhat.com From: Florian Weimer To: libc-alpha@sourceware.org Subject: Re: [PATCH] support: Report NULL blobs explicitly in TEST_COMPARE References: <87ftpvr0nm.fsf@oldenburg2.str.redhat.com> Date: Fri, 03 May 2019 18:53:56 +0200 In-Reply-To: <87ftpvr0nm.fsf@oldenburg2.str.redhat.com> (Florian Weimer's message of "Fri, 03 May 2019 17:57:33 +0200") Message-ID: <87v9yrpjh7.fsf@oldenburg2.str.redhat.com> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/26.1 (gnu/linux) MIME-Version: 1.0 * Florian Weimer: > 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. > > 2019-05-03 Florian Weimer > > * support/support_test_compare_blob.c (report_blob): Report > incorrect NULL blobs. > > diff --git a/support/support_test_compare_blob.c b/support/support_test_compare_blob.c > index 5bcb03418c..00491b0df1 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) > + 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); Hmph, this patch is better because it does not change test failure output with for NULL with zero length: 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);