From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-pj1-x1032.google.com (mail-pj1-x1032.google.com [IPv6:2607:f8b0:4864:20::1032]) by sourceware.org (Postfix) with ESMTPS id A7BEC3858D28 for ; Sat, 6 Aug 2022 10:32:21 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org A7BEC3858D28 Received: by mail-pj1-x1032.google.com with SMTP id e8-20020a17090a280800b001f2fef7886eso5035643pjd.3 for ; Sat, 06 Aug 2022 03:32:21 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:date:from:to:subject:message-id:mime-version :content-disposition; bh=OFhO26BIu8kkCnqW4bJvl2FISbLDQkPHjsNovfUT/gc=; b=Hrla53gXvXHimCkj5kEhNPv1j9h6TSK36ArgCc9g60i3y68f4gCmZYvsFnZuA4vdRO +qgE6YyVv8xyDd7spvFxZpyIHiHJuwSj0npld1LSKVd+EIgYdTV4kGXbZR+bpzowhSBO K06UiSScadmQHqE+1Im680RH2LiRdPqsUMx1xLzdVyKrqk+85glDYoK68Q8FdRp+7/4b U1ibaIFOoajvRbDVt9oa72/H54h67viwcS+ps7JrQVmKTZgd/OCeNoVMDCtQt9PDIOOo ZRCzmCnOK3v3UCXMbRQ3Gn4La7qYjEmT5WkSIw9CW9bW14wUZqY40w52cnb3YA+2rjEr BrfQ== X-Gm-Message-State: ACgBeo34iSYt+PL3d/37LG4VX6Xo+wMoPstU7dlVJLFN3Zh6FtFoO4f3 XP8ZmqxNRLoySJYWYMYQ8x0cYI7AWxA= X-Google-Smtp-Source: AA6agR58hN7aFZHmq7aBxvnTqun71OPoeMg5B472jd00hTRiHUq5xDFA0DRasV27ramTKSxkQiH8zQ== X-Received: by 2002:a17:90a:f18f:b0:1f5:1683:3f63 with SMTP id bv15-20020a17090af18f00b001f516833f63mr11875601pjb.105.1659781940417; Sat, 06 Aug 2022 03:32:20 -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 b17-20020a170903229100b0016dc8932725sm4641070plh.285.2022.08.06.03.32.19 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 06 Aug 2022 03:32:20 -0700 (PDT) Received: by squeak.grove.modra.org (Postfix, from userid 1000) id 779F51140DD8; Sat, 6 Aug 2022 20:02:17 +0930 (ACST) Date: Sat, 6 Aug 2022 20:02:17 +0930 From: Alan Modra To: binutils@sourceware.org Subject: asan: heap buffer overflow in _bfd_error_handler Message-ID: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline X-Spam-Status: No, score=-3036.7 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, T_SCC_BODY_TEXT_LINE 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-List-Received-Date: Sat, 06 Aug 2022 10:32:22 -0000 On coff_slurp_symbol_table printing "unrecognized storage class" for a symbol error. If the symbol name is the last string in its section and not terminated, we run off the end of the buffer. * coffgen.c (build_debug_section): Terminate the section with an extra 0. diff --git a/bfd/coffgen.c b/bfd/coffgen.c index 4d2b82e4a6f..90fba3b8554 100644 --- a/bfd/coffgen.c +++ b/bfd/coffgen.c @@ -1539,9 +1539,10 @@ build_debug_section (bfd *abfd, asection ** sect_return) return NULL; sec_size = sect->size; - debug_section = (char *) _bfd_alloc_and_read (abfd, sec_size, sec_size); + debug_section = (char *) _bfd_alloc_and_read (abfd, sec_size + 1, sec_size); if (debug_section == NULL) return NULL; + debug_section[sec_size] = 0; if (bfd_seek (abfd, position, SEEK_SET) != 0) return NULL; -- Alan Modra Australia Development Lab, IBM