From patchwork Thu Aug 3 20:48:25 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Samuel Thibault X-Patchwork-Id: 1816669 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=sourceware.org (client-ip=2620:52:3:1:0:246e:9693:128c; helo=server2.sourceware.org; envelope-from=libc-alpha-bounces+incoming=patchwork.ozlabs.org@sourceware.org; receiver=) Received: from server2.sourceware.org (server2.sourceware.org [IPv6:2620:52:3:1:0:246e:9693:128c]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-384) server-digest SHA384) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4RH1Cb10rGz1yf5 for ; Fri, 4 Aug 2023 06:48:42 +1000 (AEST) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id B3F283857806 for ; Thu, 3 Aug 2023 20:48:40 +0000 (GMT) X-Original-To: libc-alpha@sourceware.org Delivered-To: libc-alpha@sourceware.org Received: from sonata.ens-lyon.org (sonata.ens-lyon.org [140.77.166.138]) by sourceware.org (Postfix) with ESMTPS id 9F1F33858408 for ; Thu, 3 Aug 2023 20:48:30 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 9F1F33858408 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 Received: from localhost (localhost [127.0.0.1]) by sonata.ens-lyon.org (Postfix) with ESMTP id 7303520116; Thu, 3 Aug 2023 22:48:29 +0200 (CEST) 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 akZu3wcNbLao; Thu, 3 Aug 2023 22:48:29 +0200 (CEST) Received: from begin (lfbn-bor-1-1163-184.w92-158.abo.wanadoo.fr [92.158.138.184]) (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 3CBFB200FB; Thu, 3 Aug 2023 22:48:29 +0200 (CEST) Received: from samy by begin with local (Exim 4.96) (envelope-from ) id 1qRfFE-0050ON-28; Thu, 03 Aug 2023 22:48:28 +0200 From: Samuel Thibault To: libc-alpha@sourceware.org Cc: Samuel Thibault , commit-hurd@gnu.org Subject: [hurd, commited 2/4] Subject: hurd: Make __realpath return EINVAL on NULL buf Date: Thu, 3 Aug 2023 22:48:25 +0200 Message-Id: <20230803204827.1193126-3-samuel.thibault@ens-lyon.org> X-Mailer: git-send-email 2.40.1 In-Reply-To: <20230803204827.1193126-1-samuel.thibault@ens-lyon.org> References: <20230803204827.1193126-1-samuel.thibault@ens-lyon.org> 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, RCVD_IN_DNSWL_NONE, SPF_HELO_PASS, 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: libc-alpha@sourceware.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Libc-alpha mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: libc-alpha-bounces+incoming=patchwork.ozlabs.org@sourceware.org Sender: "Libc-alpha" As Posix and stdlib/test-canon.c expects it, and rather than letting pathconf crash. --- debug/realpath_chk.c | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/debug/realpath_chk.c b/debug/realpath_chk.c index adfc09237c..8e734b534e 100644 --- a/debug/realpath_chk.c +++ b/debug/realpath_chk.c @@ -19,6 +19,7 @@ #include #include #include +#include char * @@ -30,7 +31,15 @@ __realpath_chk (const char *buf, char *resolved, size_t resolvedlen) return __realpath (buf, resolved); #else - long int pathmax =__pathconf (buf, _PC_PATH_MAX); + long int pathmax; + + if (buf == NULL) + { + __set_errno (EINVAL); + return NULL; + } + + pathmax = __pathconf (buf, _PC_PATH_MAX); if (pathmax != -1) { /* We do have a fixed limit. */