From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on dcvr.yhbt.net X-Spam-Level: X-Spam-ASN: AS31976 209.132.180.0/23 X-Spam-Status: No, score=-4.1 required=3.0 tests=AWL,BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_EF,HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,RCVD_IN_DNSWL_MED,SPF_HELO_PASS,SPF_PASS shortcircuit=no autolearn=ham autolearn_force=no version=3.4.2 Received: from sourceware.org (server1.sourceware.org [209.132.180.131]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dcvr.yhbt.net (Postfix) with ESMTPS id 5D8561F453 for ; Fri, 3 May 2019 15:57:40 +0000 (UTC) DomainKey-Signature: a=rsa-sha1; c=nofws; d=sourceware.org; h=list-id :list-unsubscribe:list-subscribe:list-archive:list-post :list-help:sender:from:to:subject:date:message-id:mime-version :content-type; q=dns; s=default; b=SZYpL5eQiz7xhNudDmFy5m/kLaBLK PHd8k8/aWJmzjqnYq4TUacg74GWobao+1z3aUhGf3w6oKVP8+DFpaKdnzqPdr3XW mXAXk+PVgvMb2f366zwlhwW22LZcXlKKwQYqr/dJA1ez7e3zYRP2N8v5/Na0C3P9 ymsRshm8KqYKR8= DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=sourceware.org; h=list-id :list-unsubscribe:list-subscribe:list-archive:list-post :list-help:sender:from:to:subject:date:message-id:mime-version :content-type; s=default; bh=oyQFv7rXfnKjEXksm7FBlCV7K1Q=; b=nf3 N2VeBDqWuVe/ikr2EdoCjjKJ2ZuB6yCvlb2r3BlzM+O2hksJb3223+KsyaV1xzYG isfhS/hXNqi+f0kK5r0VVv0YtM9LCPUQZ2KlGJotUGtiUJFniU8vB8A3VN9EKzxO fT77/HVLKEsbt4/raQZSzULYD6SDN0LVmJD22Lt8= Received: (qmail 76601 invoked by alias); 3 May 2019 15:57:38 -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 Received: (qmail 76468 invoked by uid 89); 3 May 2019 15:57:37 -0000 Authentication-Results: sourceware.org; auth=none X-HELO: mx1.redhat.com From: Florian Weimer To: libc-alpha@sourceware.org Subject: [PATCH] support: Report NULL blobs explicitly in TEST_COMPARE Date: Fri, 03 May 2019 17:57:33 +0200 Message-ID: <87ftpvr0nm.fsf@oldenburg2.str.redhat.com> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/26.1 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain 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);