From patchwork Fri Oct 4 12:42:23 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alan Modra X-Patchwork-Id: 98384 Return-Path: X-Original-To: patchwork@sourceware.org Delivered-To: patchwork@sourceware.org Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id D4E7A386D610 for ; Fri, 4 Oct 2024 12:42:55 +0000 (GMT) X-Original-To: binutils@sourceware.org Delivered-To: binutils@sourceware.org Received: from mail-pf1-x430.google.com (mail-pf1-x430.google.com [IPv6:2607:f8b0:4864:20::430]) by sourceware.org (Postfix) with ESMTPS id AFF2B385E011 for ; Fri, 4 Oct 2024 12:42:27 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org AFF2B385E011 Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=gmail.com ARC-Filter: OpenARC Filter v1.0.0 sourceware.org AFF2B385E011 Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=2607:f8b0:4864:20::430 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1728045749; cv=none; b=kpfIF+NB6BYn7XzmeFtwIsSjANX4pXaj5Y/SADQBHVZIJt+EE9teIyTTKurjPYrS4wTixVxe2UZIxjipg5F333FqLuq0KLjB9RvFCkLYDbwi04nvSApAXmqVX/4QxIO8h24Kd1b5bEwaKUlKYKtBrlcnnlQHBMEulNrijwt5L8I= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1728045749; c=relaxed/simple; bh=h7GQtZIL6vZODCblR6tGcveUTOLmiAJlzJkC7SJYG8I=; h=DKIM-Signature:Date:From:To:Subject:Message-ID:MIME-Version; b=Mx98oJ5OG4Qvl0gb0tgZwsP3FGa3vhFeyp4InjCIcpWeawEUzbn5NkxSF9sEGPvI+VsJ1Kg4fGGMkohwEMEFOUd+Dz5SlX/1vGIqpDKGDFN7SLYNivhdg5kkyyh6uufSvJtX+z+1uEyG2slC8fNpwPSL28oXNDHW3MfdhKfTbsM= ARC-Authentication-Results: i=1; server2.sourceware.org Received: by mail-pf1-x430.google.com with SMTP id d2e1a72fcca58-7198cb6bb02so1535129b3a.3 for ; Fri, 04 Oct 2024 05:42:27 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1728045746; x=1728650546; darn=sourceware.org; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:to:from:date:from:to:cc:subject:date:message-id:reply-to; bh=89O0s6IxFdxDbGfyxA7CE4kCKxuXe7kDh7SLVs/iq2k=; b=fJf8wHa449CQcMZ3ZDSMBbzbwIjLVOHAIJF9tod+tbmhnByr/0SLgkEuOhagVZIapg k2LnpjlIwHzdCyOI1y3rMS2s2rltQUZ+gPk6H4sZeYiAUz1EpVRngXQeZtDi2zcRd92M M0TdqNrpaQMkM/hMmNKmTm3i8Of0GYPRxOIbJr6OInMk7fu73DhpTTjgVVkfSmsdmuH3 qHBj46Nilzoygsr0JdbZQ52fGsmUGhoR17VjRw7kKD1zgK5o/k9+bzzs9062La2sdFQ2 KcAF5wc7lfC9QYI1k7uokHfE7fFGdGsTFe6+RjL4PkzYWHgJKVm4Ccjg4SmqxuIppaeJ tpVA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1728045746; x=1728650546; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:to:from:date:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to; bh=89O0s6IxFdxDbGfyxA7CE4kCKxuXe7kDh7SLVs/iq2k=; b=Zauy86H9QOb9+MB7AYnnchX+tMMIkUyCnLWRUKBJqcoJJ13vWwEZ87Yt81A4E23aoL Cf/PS/0PNmBTwg0RSdtDMvLxo8n/gSazIh8HV4kntf3KAxfriuCmO1zaFEnZDuH6axxY o9+srBrBFjNaXMPBQQVTAemv1M4yViYc4U0GEvCefjOfqZTDwWxwMTXsxmsb8Qijl2VH 6u1xMXv+jtidcohFLJziT8wmalKbp8JCw3gkgo+S3u3ttdarbKNl23sOoTHFrm38u4lH HD2bo++KL2EOnUTg0x8gP+6uJh/WFEKjew4adGQRzsCZHlT3oDO9duPbGJU2AaYRo4+a talA== X-Gm-Message-State: AOJu0YzskcKEreu6/Rj/uaK4lcghjmgQJ2fiCNMFtJWaiZBF0/42EMFD hm1DadZ4UPiGlWFtot9IJXGy93nxZFK0CshwOnZFFBApY5rqVbXOl80Hmw== X-Google-Smtp-Source: AGHT+IEbfI5xT+uNfaojQMrT8DiRp34Xpslq7HoXZZ9mEzY5jxfB7+pZAF0/BgKgo3lChVadahd6gQ== X-Received: by 2002:a05:6a00:4b52:b0:714:1fc3:79fb with SMTP id d2e1a72fcca58-71de22dd687mr4770037b3a.0.1728045746317; Fri, 04 Oct 2024 05:42:26 -0700 (PDT) Received: from squeak.grove.modra.org (158.106.96.58.static.exetel.com.au. [58.96.106.158]) by smtp.gmail.com with ESMTPSA id d2e1a72fcca58-71dd9ddbd17sm3093830b3a.134.2024.10.04.05.42.25 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 04 Oct 2024 05:42:25 -0700 (PDT) Received: by squeak.grove.modra.org (Postfix, from userid 1000) id 852D011405B8; Fri, 4 Oct 2024 22:12:23 +0930 (ACST) Date: Fri, 4 Oct 2024 22:12:23 +0930 From: Alan Modra To: binutils@sourceware.org Subject: dlltool fixes for commit 68bbe1183379 Message-ID: References: MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: X-Spam-Status: No, score=-3032.8 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, FREEMAIL_FROM, GIT_PATCH_0, KAM_NUMSUBJECT, RCVD_IN_DNSWL_NONE, SPF_HELO_NONE, SPF_PASS, TXREP autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org X-BeenThere: binutils@sourceware.org X-Mailman-Version: 2.1.30 Precedence: list List-Id: Binutils mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: binutils-bounces~patchwork=sourceware.org@sourceware.org For some reason, dlltool supports mcore-elf input files, and oss-fuzz tests dlltool using mcore-elf. I'd guess fuzzed PE objects could hit the same segfaults. * dlltool.c (filter_symbols): Drop symbols with NULL names. (identify_member_contains_symname): Don't consider symbols with NULL names. diff --git a/binutils/dlltool.c b/binutils/dlltool.c index 9acd080b7b6..d6821caaf21 100644 --- a/binutils/dlltool.c +++ b/binutils/dlltool.c @@ -1539,7 +1539,7 @@ filter_symbols (bfd *abfd, void *minisyms, long symcount, unsigned int size) || bfd_is_com_section (sym->section)) && ! bfd_is_und_section (sym->section)); - keep = keep && ! match_exclude (sym->name); + keep = keep && sym->name != NULL && !match_exclude (sym->name); if (keep) { @@ -3197,9 +3197,10 @@ identify_member_contains_symname (bfd * abfd, for (i = 0; i < number_of_symbols; i++) { - if (strncmp (symbol_table[i]->name, - search_data->symname, - strlen (search_data->symname)) == 0) + if (symbol_table[i]->name != NULL + && strncmp (symbol_table[i]->name, + search_data->symname, + strlen (search_data->symname)) == 0) { search_data->found = true; break;