From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 15332 invoked by alias); 13 Jun 2018 23:25:05 -0000 Mailing-List: contact elfutils-devel-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Post: List-Help: List-Subscribe: Sender: elfutils-devel-owner@sourceware.org Received: (qmail 15309 invoked by uid 89); 13 Jun 2018 23:25:04 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Checked: by ClamAV 0.99.4 on sourceware.org X-Virus-Found: No X-Spam-SWARE-Status: No, score=-26.9 required=5.0 tests=BAYES_00,GIT_PATCH_0,GIT_PATCH_1,GIT_PATCH_2,GIT_PATCH_3,RCVD_IN_DNSWL_NONE,SPF_PASS autolearn=ham version=3.3.2 spammy= X-Spam-Status: No, score=-26.9 required=5.0 tests=BAYES_00,GIT_PATCH_0,GIT_PATCH_1,GIT_PATCH_2,GIT_PATCH_3,RCVD_IN_DNSWL_NONE,SPF_PASS autolearn=ham version=3.3.2 X-Spam-Checker-Version: SpamAssassin 3.3.2 (2011-06-06) on sourceware.org X-Spam-Level: X-HELO: gnu.wildebeest.org Received: from wildebeest.demon.nl (HELO gnu.wildebeest.org) (212.238.236.112) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Wed, 13 Jun 2018 23:25:03 +0000 Received: from librem.wildebeest.org (deer0x15.wildebeest.org [172.31.17.151]) (using TLSv1.2 with cipher ADH-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by gnu.wildebeest.org (Postfix) with ESMTPSA id 2F812300041F; Thu, 14 Jun 2018 01:25:01 +0200 (CEST) Received: by librem.wildebeest.org (Postfix, from userid 1000) id 21313142805; Thu, 14 Jun 2018 01:25:01 +0200 (CEST) From: Mark Wielaard To: elfutils-devel@sourceware.org Cc: Mark Wielaard Subject: [PATCH] readelf: Check there are at least 4 bytes available for DWARF_FORM_block4. Date: Wed, 13 Jun 2018 23:25:00 -0000 Message-Id: <20180613232458.19286-1-mark@klomp.org> X-Mailer: git-send-email 2.17.0 X-Spam-Flag: NO X-IsSubscribed: yes X-SW-Source: 2018-q2/txt/msg00215.txt.bz2 Found by afl-fuzz. When printing a DWARF_FORM_block4 we checked there were only 2 bytes available (copy/paste from DW_FORM_block2 right before). Obviously we need at least 4 bytes to read the length of a DW_FORM_block4. Signed-off-by: Mark Wielaard --- src/ChangeLog | 5 +++++ src/readelf.c | 2 +- 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/src/ChangeLog b/src/ChangeLog index fbbb9acb..5baf82e6 100644 --- a/src/ChangeLog +++ b/src/ChangeLog @@ -1,3 +1,8 @@ +2018-06-12 Mark Wielaard + + * readelf.c (print_form_data): Check we have 4, not 2, bytes + available for DW_FORM_block4. + 2018-06-12 Mark Wielaard * print_form_data): Don't increase strreadp after use. Do diff --git a/src/readelf.c b/src/readelf.c index 17d91735..3b477ab0 100644 --- a/src/readelf.c +++ b/src/readelf.c @@ -7907,7 +7907,7 @@ print_form_data (Dwarf *dbg, int form, const unsigned char *readp, break; case DW_FORM_block4: - if (readendp - readp < 2) + if (readendp - readp < 4) goto invalid_data; val = read_4ubyte_unaligned_inc (dbg, readp); if ((size_t) (readendp - readp) < val) -- 2.17.0