From patchwork Mon Dec 12 08:59:04 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alan Modra X-Patchwork-Id: 32270 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:f944:0:0:0:0:0 with SMTP id q4csp2125857wrr; Mon, 12 Dec 2022 00:59:43 -0800 (PST) X-Google-Smtp-Source: AA0mqf4c6mM3p7U9i8U8+3ZIF4+SM5XB6d6LY/J69u7zgjqkeokd6hB7Uc4hoCwvPlRQSY3vlI+G X-Received: by 2002:a17:907:c80f:b0:7c1:75e9:1180 with SMTP id ub15-20020a170907c80f00b007c175e91180mr1997199ejc.22.1670835583614; Mon, 12 Dec 2022 00:59:43 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1670835583; cv=none; d=google.com; s=arc-20160816; b=LofEmPa6dIwbQmaaCyiBhjwTrrP9oc9usa3ZQ0nOgayRLSc4y5LgdMFFSEfJHbDVAw G14/NtLjcVSnJ6Jxk8lrhZGr5zA+3m5whNorLBJ6cnZz1vlaM5++fPs7mzzqn3YCLZO7 4Vo4qztoU7QhA40YVco6OgCHn9GZ56AOXlzxPugNjQ/8htxTACCuv4m47WVwhfMBjKEJ GCxbtJmvyq2uwNKl/9Ib81CdnCIITBiAXMwdUWEKj5tGsQtTeW3xT7j6L4+1Cz9r2iWF HKYcZpkiOtVLEUMbPkdSasgr57WrFghxbqIDhWlSLHOdBbIDbqw+IT1xLPRGLu7tmQRf nGtw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:reply-to:from:list-subscribe:list-help:list-post :list-archive:list-unsubscribe:list-id:precedence :content-disposition:mime-version:message-id:subject:to:date :dmarc-filter:delivered-to:dkim-signature:dkim-filter; bh=vI3gcI3n6M3uE/eDq+W6BNtgic194YfqQJGQeQFa/Kg=; b=1DkZWE4IGOfHXtQFxAZcSl3BnH+7edSnopgOxs8/oFOT6xEC/+LxuVyo05Fwjncf39 83i24g+yq72PSeZoib+ssv/ymGO0PZEieX7grs+fDAtyIbpWopTNesFLl2KUmb100137 mu05YMIwE+fEAet1OKNTwLy49RpepN9GWFGk9mpvsaEGYvyUry8mqXshkvB2Rcs/ow7v NFhuKEZYlN2ayS+d+L9yvGveLfUF5gRMFKSkMN3RWUrGRldGoxRUshBELFfrC2gOWB7Z +2W3FqyK5UFU8w/HpB4JxG1XesNYSlqHaa4wLEVxkE386sRvvXoNJcnolRRf9cfQxlSS VCRg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@sourceware.org header.s=default header.b=a0b7Pwry; spf=pass (google.com: domain of binutils-bounces+ouuuleilei=gmail.com@sourceware.org designates 2620:52:3:1:0:246e:9693:128c as permitted sender) smtp.mailfrom="binutils-bounces+ouuuleilei=gmail.com@sourceware.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=sourceware.org Received: from sourceware.org (server2.sourceware.org. [2620:52:3:1:0:246e:9693:128c]) by mx.google.com with ESMTPS id og13-20020a1709071dcd00b007c0b56b90f5si4503844ejc.307.2022.12.12.00.59.43 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 12 Dec 2022 00:59:43 -0800 (PST) Received-SPF: pass (google.com: domain of binutils-bounces+ouuuleilei=gmail.com@sourceware.org designates 2620:52:3:1:0:246e:9693:128c as permitted sender) client-ip=2620:52:3:1:0:246e:9693:128c; Authentication-Results: mx.google.com; dkim=pass header.i=@sourceware.org header.s=default header.b=a0b7Pwry; spf=pass (google.com: domain of binutils-bounces+ouuuleilei=gmail.com@sourceware.org designates 2620:52:3:1:0:246e:9693:128c as permitted sender) smtp.mailfrom="binutils-bounces+ouuuleilei=gmail.com@sourceware.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=sourceware.org Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 335B23946A69 for ; Mon, 12 Dec 2022 08:59:16 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 335B23946A69 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1670835556; bh=vI3gcI3n6M3uE/eDq+W6BNtgic194YfqQJGQeQFa/Kg=; h=Date:To:Subject:List-Id:List-Unsubscribe:List-Archive:List-Post: List-Help:List-Subscribe:From:Reply-To:From; b=a0b7PwryXL7oFDVCU3pKNY62iBcSACTVHJE68jIz+l0yG6X0BkJcf6+y4UvWIYGOG 0CkjA/yNSqMXYErRC9d2zK1nNQAzdsQcM7ktXsF9W/FPXKT6gN9dqMQo+IDxa3t3Hk 7PixHdEPj8F9mJ+fERM9WLLwCOiC6XEYKLJ2T1cQ= X-Original-To: binutils@sourceware.org Delivered-To: binutils@sourceware.org Received: from mail-pl1-x62c.google.com (mail-pl1-x62c.google.com [IPv6:2607:f8b0:4864:20::62c]) by sourceware.org (Postfix) with ESMTPS id B6A7A3954A62 for ; Mon, 12 Dec 2022 08:59:07 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org B6A7A3954A62 Received: by mail-pl1-x62c.google.com with SMTP id jn7so11358723plb.13 for ; Mon, 12 Dec 2022 00:59:07 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-disposition:mime-version:message-id:subject:to:from:date :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=vI3gcI3n6M3uE/eDq+W6BNtgic194YfqQJGQeQFa/Kg=; b=aRBSay1SFkkHzmbxtaSBndcA31l51cwr+fHb7k5T7wxJV1iSLkMsOj1I25FybYSOl6 dmcNt9oeI0gwKrIiHDpK+6s+2LnBltNKO+a7eT2ux6f6Y31E5b8HOPSezWftgc+Ig+ya U3Eq15Pt0pirecwSyAMdTGed8YYm/Y9aMvuCG4twaBLf4r6yFjD9tLD7lqYxAZ7YGaNQ Kxggt8q7S3YSkuQbpXLWW1wbiu+LFMhqPvALX3DnPIRfJHeFsvvg5ZdOCoHZIHss3ff5 xG3OB9NIY/rrRB0zxu5EggBVAoFZYdBjNQ5IR6Tf2vvHHhhdDlQnlfpHu1jP5rvaOien LJJA== X-Gm-Message-State: ANoB5pnkqDFdTCgKuyo8wIKYcLdeeUdNZ8Lu1fiJp33ltYWYLX9jli4s +lBrFGx38zhupnPjULGQ6Ch6LuijlSU= X-Received: by 2002:a17:903:2652:b0:189:eadb:45c7 with SMTP id je18-20020a170903265200b00189eadb45c7mr15382262plb.37.1670835546622; Mon, 12 Dec 2022 00:59:06 -0800 (PST) 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 c4-20020a170902d90400b001743ba85d39sm5741815plz.110.2022.12.12.00.59.06 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 12 Dec 2022 00:59:06 -0800 (PST) Received: by squeak.grove.modra.org (Postfix, from userid 1000) id 2975C1142D5F; Mon, 12 Dec 2022 19:29:04 +1030 (ACDT) Date: Mon, 12 Dec 2022 19:29:04 +1030 To: binutils@sourceware.org Subject: PR29892, Field file_table of struct module is uninitialized Message-ID: MIME-Version: 1.0 Content-Disposition: inline X-Spam-Status: No, score=-3036.0 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, FREEMAIL_FROM, GIT_PATCH_0, 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.29 Precedence: list List-Id: Binutils mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-Patchwork-Original-From: Alan Modra via Binutils From: Alan Modra Reply-To: Alan Modra Errors-To: binutils-bounces+ouuuleilei=gmail.com@sourceware.org Sender: "Binutils" X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1751998092926008417?= X-GMAIL-MSGID: =?utf-8?q?1751998092926008417?= PR 29892 * vms-alphs.c (new_module): Use bfd_zmalloc to alloc file_table. (parse_module): Rewrite file_table reallocation code and clear. diff --git a/bfd/vms-alpha.c b/bfd/vms-alpha.c index 3b63259cc81..6ee7060b0b2 100644 --- a/bfd/vms-alpha.c +++ b/bfd/vms-alpha.c @@ -4337,7 +4337,7 @@ new_module (bfd *abfd) = (struct module *) bfd_zalloc (abfd, sizeof (struct module)); module->file_table_count = 16; /* Arbitrary. */ module->file_table - = bfd_malloc (module->file_table_count * sizeof (struct fileinfo)); + = bfd_zmalloc (module->file_table_count * sizeof (struct fileinfo)); return module; } @@ -4520,15 +4520,18 @@ parse_module (bfd *abfd, struct module *module, unsigned char *ptr, src_ptr + DST_S_B_SRC_DF_FILENAME, ptr + rec_length - (src_ptr + DST_S_B_SRC_DF_FILENAME)); - while (fileid >= module->file_table_count) + if (fileid >= module->file_table_count) { - module->file_table_count *= 2; + unsigned int old_count = module->file_table_count; + module->file_table_count += fileid; module->file_table = bfd_realloc_or_free (module->file_table, module->file_table_count * sizeof (struct fileinfo)); if (module->file_table == NULL) return false; + memset (module->file_table + old_count, 0, + fileid * sizeof (struct fileinfo)); } module->file_table [fileid].name = filename;