From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from simark.ca by simark.ca with LMTP id oYCEFMEmg2q1LC0AWB0awg (envelope-from ) for ; Mon, 17 Aug 2026 11:20:33 -0400 Received: by simark.ca (Postfix, from userid 112) id 511561E167; Mon, 17 Aug 2026 11:20:33 -0400 (EDT) X-Spam-Checker-Version: SpamAssassin 4.0.1 (2024-03-25) on simark.ca X-Spam-Level: X-Spam-Status: No, score=-5.3 required=5.0 tests=ARC_SIGNED,ARC_VALID,BAYES_00, MAILING_LIST_MULTI,RCVD_IN_DNSWL_MED autolearn=ham autolearn_force=no version=4.0.1 Received: from vm01.sourceware.org (vm01.sourceware.org [IPv6:2620:52:6:3111::32]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange x25519 server-signature ECDSA (prime256v1) server-digest SHA256) (No client certificate requested) by simark.ca (Postfix) with ESMTPS id F248D1E033 for ; Mon, 17 Aug 2026 11:20:32 -0400 (EDT) Received: from vm01.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 2CAE64BA903D for ; Mon, 17 Aug 2026 15:20:32 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 2CAE64BA903D Received: from simark.ca (simark.ca [158.69.221.121]) by sourceware.org (Postfix) with ESMTPS id 9941D4BA900A; Mon, 17 Aug 2026 15:18:53 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 9941D4BA900A Authentication-Results: sourceware.org; dmarc=fail (p=none dis=none) header.from=efficios.com Authentication-Results: sourceware.org; spf=fail smtp.mailfrom=efficios.com ARC-Filter: OpenARC Filter v1.0.0 sourceware.org 9941D4BA900A Authentication-Results: sourceware.org; arc=none smtp.remote-ip=158.69.221.121 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1786979933; cv=none; b=ahWWeixu/vgfIxh/4n8hFAq6FKA/kIUXbZJdGrLUypjdYAnbQZ9p2/ErK1wV36FKsvgw+/364HJvBxk8j65VB2Ev2EWKgdl6pOj7TwoLJvN024Jqhd4NAHDQNuq4sgYACNk+RPZGZf7sjes4pZ5lJbjpyHO6s0vW26J2BZJF6c0= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1786979933; c=relaxed/simple; bh=aTx6ewosglpkhuPfArGmJSXqpDRGTJrQyi15CcNJjVc=; h=From:To:Subject:Date:Message-ID:MIME-Version; b=O2Kyz3ciya7AlqV6s0Qsz3Dffux3jz1QkvFWschRiCTqMODDj1R/0t1pQmXYfmLEUaORFtO6bVKI5aEWUBoycvwvDXTfyZ+LaXxB2aw71w0CsDjMDZp4qnpUtqhhtNir9XzlHQf0jI06ZStfsCm04eRziqPOvk99LiQcZGzVxDk= ARC-Authentication-Results: i=1; sourceware.org DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 9941D4BA900A Received: by simark.ca (Postfix) id 402A51E033; Mon, 17 Aug 2026 11:18:53 -0400 (EDT) From: Simon Marchi To: gdb-patches@sourceware.org, binutils@sourceware.org Cc: Simon Marchi Subject: [PATCH 08/13] gdb/dwarf2: remove uses of sprintf Date: Mon, 17 Aug 2026 11:16:13 -0400 Message-ID: <20260817151646.152571-9-simon.marchi@efficios.com> X-Mailer: git-send-email 2.55.0 In-Reply-To: <20260817151646.152571-1-simon.marchi@efficios.com> References: <20260817151646.152571-1-simon.marchi@efficios.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-BeenThere: gdb-patches@sourceware.org X-Mailman-Version: 2.1.30 Precedence: list List-Id: Gdb-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: gdb-patches-bounces~public-inbox=simark.ca@sourceware.org When building on macOS, I get some: /Users/smarchi/src/binutils-gdb/gdb/dwarf2/read.c:3773:4: error: 'sprintf' is deprecated: This function is provided for compatibility reasons only. Due to security concerns inherent in the design of sprintf(3), it is highly recommended that you use snprintf(3) instead. [-Werror,-Wdeprecated-declarations] 3773 | sprintf (buf, "TU %s at offset %s", hex_string (sig_type->signature), | ^ Replace them with xsnprintf, which takes the destination size and asserts that the output was not truncated. Change-Id: Ie0324f75e5d4aad9b647007848459bf4af5998a6 --- gdb/dwarf2/read.c | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/gdb/dwarf2/read.c b/gdb/dwarf2/read.c index ca475f53745d..a8b99425554a 100644 --- a/gdb/dwarf2/read.c +++ b/gdb/dwarf2/read.c @@ -3770,15 +3770,16 @@ process_queue (dwarf2_per_objfile *per_objfile) if (signatured_type *sig_type = per_cu->as_signatured_type (); sig_type != nullptr) { - sprintf (buf, "TU %s at offset %s", hex_string (sig_type->signature), - sect_offset_str (per_cu->sect_off ())); + xsnprintf (buf, sizeof (buf), "TU %s at offset %s", + hex_string (sig_type->signature), + sect_offset_str (per_cu->sect_off ())); /* There can be 100s of TUs. Only print them in verbose mode. */ debug_print_threshold = 2; } else { - sprintf (buf, "CU at offset %s", - sect_offset_str (per_cu->sect_off ())); + xsnprintf (buf, sizeof (buf), "CU at offset %s", + sect_offset_str (per_cu->sect_off ())); debug_print_threshold = 1; } -- 2.55.0