From patchwork Fri May 3 15:57:33 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Florian Weimer X-Patchwork-Id: 1094958 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=sourceware.org (client-ip=209.132.180.131; helo=sourceware.org; envelope-from=libc-alpha-return-101729-incoming=patchwork.ozlabs.org@sourceware.org; receiver=) Authentication-Results: ozlabs.org; dmarc=fail (p=none dis=none) header.from=redhat.com Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; secure) header.d=sourceware.org header.i=@sourceware.org header.b="nsW2Qyvt"; dkim-atps=neutral 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 ozlabs.org (Postfix) with ESMTPS id 44wcGb6Mqwz9s9N for ; Sat, 4 May 2019 01:57:43 +1000 (AEST) 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=gjAPIYVqNP1uFuvUDufJMw4C4C+h3 i4f75kjhNM2/7FMFUEBVL8Mr7jnju6gJOa4xOd3akkhebo/y64xKIhf06U4tdprl GlG4wOgwyEeocTDUMs6yn/WeVbk1SeOfjcI1luI1zoC8AdGX30zgFUMm2kM5a9jk qFmiAiLz0EpwRg= 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=nsW 2QyvtQOI2/hDTh8LPdIj80DlVy6GCub9KxJX4dJrzcPtgGt2kx//O9to/u/J8QRO 27/eGiZEXJhU6pekaNecm6uUYmm6IGPcLwST8rk0ajuvE+OlYZv/3DmMHst4P2Ek DCLSphvth18l85sistGjOtH1hRSdoLGUwWESjeBg= 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 Delivered-To: mailing list libc-alpha@sourceware.org Received: (qmail 76468 invoked by uid 89); 3 May 2019 15:57:37 -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=faulty 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 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);