From patchwork Mon Dec 30 19:36:18 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Adhemerval Zanella Netto X-Patchwork-Id: 854253 Delivered-To: patch@linaro.org Received: by 2002:a5d:4888:0:b0:385:e875:8a9e with SMTP id g8csp6599588wrq; Mon, 30 Dec 2024 11:37:47 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCWQicrExpY0R+tTDOzbCExtWh/4D8N65rW59tCxedavGfw7R2XbQXPGjYC1m8XTtaXkK8BQmA==@linaro.org X-Google-Smtp-Source: AGHT+IFu7a+tRylkfkWq+QztxFpPP/PxvKK+FHezOVRd03g/WEwGVUUcgFLDNGZawCaYUTf8xugT X-Received: by 2002:a05:6214:31a0:b0:6d8:a7e1:e270 with SMTP id 6a1803df08f44-6dd233ad9ecmr556728446d6.40.1735587466848; Mon, 30 Dec 2024 11:37:46 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1735587466; cv=pass; d=google.com; s=arc-20240605; b=SqgFfGyscuA8Vt0n1KbvMbjeReGl17C0LIu6mQTzCawd/pafjgd6FqozUVrTfBOATd XbUB+1R6Dssh2QrshJpe9I4gaztQusVhiGa62WJYJNvrhEzxUVVK8NErtFZILgQZEZuL FjTyENNhGOD2aF4hQfEFENr+G+c/l3VBtoKtPOsbDSq3Km7AeFUuONnMS5y0hHSZmW6d 9OmDiWTBSjBuDfGYLqB1a8BTOjBl+DF+Tg/yOWPprMTsOAvpxkRFGRjAHwqWSKhWguem vSt0J2iyzpm1klakdLSpw2PwIGSg/NQ2uv/uX7euKv2e7U2sF6P/eul/6Y6z8eUckzFh jM4A== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20240605; h=errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature:dkim-filter:arc-filter:dmarc-filter :delivered-to:dkim-filter; bh=8P4w4cDtQa7xsomeZ7Nst4Fzd9ReC3wOeXpbYQc4zes=; fh=xV8Gp349bHw1ljD2lFQRwhGaJ4bIEzpeFyS/N97S3Sw=; b=U5tI2NVhewmoDh1y+yqOxs6hMrSxau/1p0QYhPF0P+NHEYhYpH5lBJxW7FwuJ0IgP6 CbWmPdJBuFFVGeVM2+5NrX/2+9wZiKSnmUR8NjONr4rbxc9mTE3F32cPQiPsK1Sly31D N5Hs7w4OWiskBSdQPrw3k1YltTLzIT2NgNwcmeytLV2dt92YEog3SfR9KE2/J0WW5gLV 52sKZ40l1P20Cd+5/H1o/l9SXQMeC2YXfSOIY0BapmKhzRdNCDev3L5bPRnLsHPalYxr n+cNhBB0OGLOcmT9Iv/F+NS+Bqmk8VlQQKFTX6LU8eyKbwe7WNWZZgc8miAA4S8eHKPe YkwQ==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b="iBWxEK5/"; arc=pass (i=1); spf=pass (google.com: domain of libc-alpha-bounces~patch=linaro.org@sourceware.org designates 2620:52:3:1:0:246e:9693:128c as permitted sender) smtp.mailfrom="libc-alpha-bounces~patch=linaro.org@sourceware.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from server2.sourceware.org (server2.sourceware.org. [2620:52:3:1:0:246e:9693:128c]) by mx.google.com with ESMTPS id 6a1803df08f44-6dd18234167si291392746d6.216.2024.12.30.11.37.46 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 30 Dec 2024 11:37:46 -0800 (PST) Received-SPF: pass (google.com: domain of libc-alpha-bounces~patch=linaro.org@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=@linaro.org header.s=google header.b="iBWxEK5/"; arc=pass (i=1); spf=pass (google.com: domain of libc-alpha-bounces~patch=linaro.org@sourceware.org designates 2620:52:3:1:0:246e:9693:128c as permitted sender) smtp.mailfrom="libc-alpha-bounces~patch=linaro.org@sourceware.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 6A15A3858CDA for ; Mon, 30 Dec 2024 19:37:46 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 6A15A3858CDA Authentication-Results: sourceware.org; dkim=pass (2048-bit key, unprotected) header.d=linaro.org header.i=@linaro.org header.a=rsa-sha256 header.s=google header.b=iBWxEK5/ X-Original-To: libc-alpha@sourceware.org Delivered-To: libc-alpha@sourceware.org Received: from mail-pl1-x631.google.com (mail-pl1-x631.google.com [IPv6:2607:f8b0:4864:20::631]) by sourceware.org (Postfix) with ESMTPS id D53393858D20 for ; Mon, 30 Dec 2024 19:37:11 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org D53393858D20 Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=linaro.org Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=linaro.org ARC-Filter: OpenARC Filter v1.0.0 sourceware.org D53393858D20 Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=2607:f8b0:4864:20::631 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1735587432; cv=none; b=TWH3IYVLORrcO+fkznW6s1TR4nP97OMN2SH4f+t0eHejOC5E2F1jG1JP14xjdVHXVwYAYDR0MgjQgXpGEGVAz96aKY97ZzX9zdiXKTy4kn46R4UB7VroNn0KPVeFEAHMafOZuKsNKqgIhY37FVI7dxh/JbomsbP5Qcz9uu7ccBA= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1735587432; c=relaxed/simple; bh=N7hKrKr/KueemOOG7RlO/rOkTCblgot4o66mPNBW2To=; h=DKIM-Signature:From:To:Subject:Date:Message-ID:MIME-Version; b=KMyYz06vujlxSeZUJLc/vqhQEr50Ywj54iywrYglJO00hUy0yn+qAnUXl05b36Ixfq36TaDdxmGdW00VaIcw4z80IkX29RWBiXpCMPqBTYFPheKSQQ6HUeLd7TQxNp0R/KaMcUiw0VpPefMmQ6scjEilTHtbruseyVUHYhlDMIM= ARC-Authentication-Results: i=1; server2.sourceware.org DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org D53393858D20 Received: by mail-pl1-x631.google.com with SMTP id d9443c01a7336-2166360285dso124561815ad.1 for ; Mon, 30 Dec 2024 11:37:11 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1735587430; x=1736192230; darn=sourceware.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=8P4w4cDtQa7xsomeZ7Nst4Fzd9ReC3wOeXpbYQc4zes=; b=iBWxEK5/SZFRZky3ZrlX1xW1BHpqD4Bt+CGUMvTVkLrUUpuuiC+yEXEIAHMPTrf5G9 8PSg7DqAfc3y/0M33WU4d9JaJyYSEoROlB5e0KLotOrJmpc+hDwONWkGccSk+ftFRUOS fKkUNvY4JI1/nSi06zLrN64tzm6JRlJEKzkpjROSTBvZ2qFLzHxoPI+maIRZ/I7Eq88f WK+PwWJ/p7e12XjfmuGlmyi2DfjdJUn/qZRXjJz9/fwEwQPKroHZXnY/yTFEcQWfSGsf wSbupxGFXBehqpQla483F55UqmbJQq6kPQeZABYylNyu66r0LI23LIsKsplNtniPZc1H Bc/w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1735587430; x=1736192230; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=8P4w4cDtQa7xsomeZ7Nst4Fzd9ReC3wOeXpbYQc4zes=; b=fH6/K96K3VFnYaJ3QJR2Y+ny+uzZygAKC/5WerzLClH527nd6KlPjc8HIdTB1vqH/X gaL/4UeT7AmrKosJF3JxYWtCoymIJ7t100Yh62xEjPqddKW+4T2uwA1E9jxso5UsbWLJ MvBSbimM+TP+T3h3kXWNVxDDFby/bGdoN6A8mAJRMZSoU0RPLUi8V7X+IQnMHWDkTohP 9Ijysqx0RrJGn7xWzu8NZqvdFiwylWDEl/PlLaYg461FoMLRlt3nTpBEMK25XP9cxX14 vRnEHOr/9gjKR0T+zqUENXqGsFeBvH76OwY4DIftEC7nUg3a6kWWNMP5+44pXvanPZ/x g82w== X-Gm-Message-State: AOJu0YxPUPJAvl5jcxcBvyDgSgaHSiKvJfzci3RsGcHPYMo71dianQHb yfya7ZJWq8mRUBpYK65bRoQRiei9HKt3EUlY4pgfAZRxJ+CpK0nvzoIS0+rlpczXBjwhi1YoMFg T X-Gm-Gg: ASbGnctKXKj7wbqdr1/1GcvZOors6nelmpojXG5T6r0zkwcHkW7dazlDTZ83GT3duWN v9m4XUfpsBmXXJZSw/9TqRkWN/goKHK0IP66x7Y/X4nzJ8R1FWN83JVlCLKMxS0i3YqY49Ou+My +zYU1mU9m74m3zxx3N6VkCTvaDULNy7KMD72gxeBldu7qp79zfodwAzMNmW9Uw0sa/hA0iG6x0A WxnXf+w9jXaH6aAbHq7COjamKbMWWm+isTBxKVbIG8bwFWZuFs62s2IJAvfrdd/DeJ9rayJdV+T ZryHGF6onG2v/obTh5ldHwPcViQ+ X-Received: by 2002:a05:6a20:e68b:b0:1e1:72ce:fefc with SMTP id adf61e73a8af0-1e5e05a9edemr66166149637.22.1735587430638; Mon, 30 Dec 2024 11:37:10 -0800 (PST) Received: from ubuntu-vm.. (201-92-184-234.dsl.telesp.net.br. [201.92.184.234]) by smtp.gmail.com with ESMTPSA id d2e1a72fcca58-72aad8344desm19516230b3a.54.2024.12.30.11.37.09 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 30 Dec 2024 11:37:10 -0800 (PST) From: Adhemerval Zanella To: libc-alpha@sourceware.org Cc: Florian Weimer , Adhemerval Zanella Subject: [PATCH v2 2/2] assert: Remove the use of %n from __assert_fail_base (BZ #32456) Date: Mon, 30 Dec 2024 16:36:18 -0300 Message-ID: <20241230193700.2851662-2-adhemerval.zanella@linaro.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20241230193700.2851662-1-adhemerval.zanella@linaro.org> References: <20241230193700.2851662-1-adhemerval.zanella@linaro.org> MIME-Version: 1.0 X-BeenThere: libc-alpha@sourceware.org X-Mailman-Version: 2.1.30 Precedence: list List-Id: Libc-alpha mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: libc-alpha-bounces~patch=linaro.org@sourceware.org The require size for mmap can be inferred from __vasprintf return value. It also fixes tst-assert-2 when building with --enable-fortify, where even if the format is not translated, __readonly_area fails because malloc can not be used. Checked on aarch64-linux-gnu. Reviewed-by: Florian Weimer --- assert/assert-perr.c | 2 +- assert/assert.c | 27 ++++++++++----------------- po/libc.pot | 12 ++++-------- 3 files changed, 15 insertions(+), 26 deletions(-) diff --git a/assert/assert-perr.c b/assert/assert-perr.c index 0010cbc278..8a03620b4c 100644 --- a/assert/assert-perr.c +++ b/assert/assert-perr.c @@ -32,7 +32,7 @@ __assert_perror_fail (int errnum, char errbuf[1024]; char *e = __strerror_r (errnum, errbuf, sizeof errbuf); - __assert_fail_base (_("%s%s%s:%u: %s%sUnexpected error: %s.\n%n"), + __assert_fail_base (_("%s%s%s:%u: %s%sUnexpected error: %s.\n"), e, file, line, function); } libc_hidden_def (__assert_perror_fail) diff --git a/assert/assert.c b/assert/assert.c index 3a16f85394..3834ddd864 100644 --- a/assert/assert.c +++ b/assert/assert.c @@ -15,24 +15,17 @@ License along with the GNU C Library; if not, see . */ -#include -#include +#include #include #include -#include -#include -#include -#include -#include +#include #include #include -#include +#include extern const char *__progname; -#include -#include #define fflush(s) _IO_fflush (s) /* This function, when passed a string containing an asserted @@ -56,12 +49,12 @@ __assert_fail_base (const char *fmt, const char *assertion, const char *file, FATAL_PREPARE; #endif - int total; - if (__asprintf (&str, fmt, - __progname, __progname[0] ? ": " : "", - file, line, - function ? function : "", function ? ": " : "", - assertion, &total) >= 0) + int total = __asprintf (&str, fmt, + __progname, __progname[0] ? ": " : "", + file, line, + function ? function : "", function ? ": " : "", + assertion); + if (total >= 0) { /* Print the message. */ (void) __fxprintf (NULL, "%s", str); @@ -129,6 +122,6 @@ void __assert_fail (const char *assertion, const char *file, unsigned int line, const char *function) { - __assert_fail_base (_("%s%s%s:%u: %s%sAssertion `%s' failed.\n%n"), + __assert_fail_base (_("%s%s%s:%u: %s%sAssertion `%s' failed.\n"), assertion, file, line, function); } diff --git a/po/libc.pot b/po/libc.pot index d66bd04122..c8193f53c7 100644 --- a/po/libc.pot +++ b/po/libc.pot @@ -6,7 +6,7 @@ msgid "" msgstr "" "Project-Id-Version: libc 2.40.9000\n" -"POT-Creation-Date: 2024-12-30 16:29-0300\n" +"POT-Creation-Date: 2024-12-30 16:34-0300\n" "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" "Last-Translator: FULL NAME \n" "Language-Team: LANGUAGE \n" @@ -102,16 +102,12 @@ msgstr "" #: assert/assert-perr.c:35 #, c-format -msgid "" -"%s%s%s:%u: %s%sUnexpected error: %s.\n" -"%n" +msgid "%s%s%s:%u: %s%sUnexpected error: %s.\n" msgstr "" -#: assert/assert.c:132 +#: assert/assert.c:125 #, c-format -msgid "" -"%s%s%s:%u: %s%sAssertion `%s' failed.\n" -"%n" +msgid "%s%s%s:%u: %s%sAssertion `%s' failed.\n" msgstr "" #: catgets/gencat.c:111