From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: 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 Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=gmail.com Received: by mail-pl1-x62c.google.com with SMTP id jn7so11358723plb.13 for ; Mon, 12 Dec 2022 00:59:07 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=content-disposition:mime-version:message-id:subject:to:from:date :from:to:cc:subject:date:message-id:reply-to; bh=vI3gcI3n6M3uE/eDq+W6BNtgic194YfqQJGQeQFa/Kg=; b=pb4lFvKlR3GVyhWsnlY8j6fu+rfc2qEGIPDjEp0h2cOWqGW07ngtPgNIprfiG3imI+ g1xaRfL8uay69bYBsKqaI+dkWY5F+65UjkAsOCV7JLGHht7n7hIj1YizVsinSGXlL743 arSg59qd1tlQb0hrO9WP5LowCTfjD4KDZYTHRGecectPkZwZe7D8i2qnYA6fLCVEqhKR gemhbWjZmRWp9mRgeqy9uebj/NjFsBbN4VwIr+JED0SNQ3mLDOUU/kvbN3UeqwDg/WjH tUC7nSf89+ughKxeu9F5jUHQT+MwSM8WJLZp+VOpQanV5/D2m1W8vch9kBvMmKIEXyoS 0hoA== 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-Google-Smtp-Source: AA0mqf5wXl8Y6wrhmsQXnR6iMSaGKg+yd++3p5J8TcIei1tS7hBFbtDLXWUrUz3tEw3eVOL43hVxQw== 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 From: Alan Modra To: binutils@sourceware.org Subject: PR29892, Field file_table of struct module is uninitialized Message-ID: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii 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 List-Id: 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; -- Alan Modra Australia Development Lab, IBM