From patchwork Sat Nov 9 19:01:36 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Samuel Thibault X-Patchwork-Id: 100688 Return-Path: X-Original-To: patchwork@sourceware.org Delivered-To: patchwork@sourceware.org Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 56F363858C62 for ; Sat, 9 Nov 2024 19:02:01 +0000 (GMT) X-Original-To: libc-alpha@sourceware.org Delivered-To: libc-alpha@sourceware.org Received: from sonata.ens-lyon.org (domu-toccata.ens-lyon.fr [140.77.166.138]) by sourceware.org (Postfix) with ESMTPS id 4C9CE3858D21 for ; Sat, 9 Nov 2024 19:01:40 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 4C9CE3858D21 Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=ens-lyon.org Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=bounce.ens-lyon.org ARC-Filter: OpenARC Filter v1.0.0 sourceware.org 4C9CE3858D21 Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=140.77.166.138 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1731178901; cv=none; b=WPQg41Wm8ujsnB4reDPDUes3Fi1uB15gNAYO8EsQi4X7nAKhca1pyo1JVlCukcv5BrUsEuQsg3TqCVLAAgjEUmp9Y2kjlzHNguoz32DD3IyURxqTEgzwynWXuVk/dBU7XjcnbaS3jJ1cyTgtRXctcFEGeDhN9UIgYY8Q6sTvEBU= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1731178901; c=relaxed/simple; bh=YZKoZkahT5WnavUYNlQ8Y920CCd6pQKUnWqOdedl6Do=; h=From:To:Subject:Date:Message-ID:MIME-Version; b=iBth2tiOzhfgTUoxqyoMruzH3lTqIlo1H2ZR4bNF4R2BAkAOBiPjUrplbCUVhbaizLap69VgS/9V9zfxoKdX9fcal55p6inlifHATAIZD8GZSUdPgTu8446pFEhCCzMpvWGyYK/O4lF8IgdC8UQIB2dz4DblQ+gqRyih+Rlw6fU= ARC-Authentication-Results: i=1; server2.sourceware.org Received: from localhost (localhost [127.0.0.1]) by sonata.ens-lyon.org (Postfix) with ESMTP id A258EA1BF5; Sat, 9 Nov 2024 20:01:38 +0100 (CET) Received: from sonata.ens-lyon.org ([127.0.0.1]) by localhost (sonata.ens-lyon.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id j3HwmtwGEsGs; Sat, 9 Nov 2024 20:01:38 +0100 (CET) Received: from begin (aamiens-653-1-40-48.w83-192.abo.wanadoo.fr [83.192.199.48]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange ECDHE (P-256) server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by sonata.ens-lyon.org (Postfix) with ESMTPSA id 60303A1BF3; Sat, 9 Nov 2024 20:01:38 +0100 (CET) Received: from samy by begin with local (Exim 4.98) (envelope-from ) id 1t9qiH-0000000DVth-3T8A; Sat, 09 Nov 2024 20:01:37 +0100 From: Samuel Thibault To: libc-alpha@sourceware.org Cc: Samuel Thibault , commit-hurd@gnu.org Subject: [hurd, commited] mach: Fix __xpg_strerror_r on in-range but undefined errors [BZ #32350] Date: Sat, 9 Nov 2024 20:01:36 +0100 Message-ID: <20241109190136.3220870-1-samuel.thibault@ens-lyon.org> X-Mailer: git-send-email 2.45.2 MIME-Version: 1.0 X-Spam-Status: No, score=-13.2 required=5.0 tests=BAYES_00, GIT_PATCH_0, JMQ_SPF_NEUTRAL, KAM_DMARC_STATUS, SPF_HELO_PASS, 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: 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~patchwork=sourceware.org@sourceware.org For instance, 1073741906 leads to system 16, subsystem 0 and code 82, which is in range (max_code is 122), but not defined. Return EINVAL in that case, like --- sysdeps/mach/xpg-strerror.c | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/sysdeps/mach/xpg-strerror.c b/sysdeps/mach/xpg-strerror.c index f8c65f8124..5e0e5a41d7 100644 --- a/sysdeps/mach/xpg-strerror.c +++ b/sysdeps/mach/xpg-strerror.c @@ -62,9 +62,19 @@ __xpg_strerror_r (int errnum, char *buf, size_t buflen) if (sub >= es->max_sub) estr = (const char *) es->bad_sub; else if (code >= es->subsystem[sub].max_code) - return EINVAL; + { + __snprintf (buf, buflen, "%s%d", _("Unknown error code: "), code); + return EINVAL; + } else - estr = (const char *) _(es->subsystem[sub].codes[code]); + { + estr = (const char *) _(es->subsystem[sub].codes[code]); + if (estr == NULL) + { + __snprintf (buf, buflen, "%s%d", _("Unknown error code: "), code); + return EINVAL; + } + } size_t estrlen = strlen (estr);