From patchwork Tue May 16 14:37:44 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andreas Schwab X-Patchwork-Id: 69478 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 8502E3856DE8 for ; Tue, 16 May 2023 14:38:07 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 8502E3856DE8 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1684247887; bh=n5SfaCUC97xEv5FdNoiGVoSVjyXG4OMmoll5dx17AyI=; h=To:Subject:Date:List-Id:List-Unsubscribe:List-Archive:List-Post: List-Help:List-Subscribe:From:Reply-To:From; b=T9i2ss8MKseuYcrKj7nBVMoNCoYW+JIeMu9O/+WILu5Z1wJ/UO41cPkRCYrE197md oDVBEVfPqpcuoyEjJNk5TLwug4PtZccMOpgBd79As9QF6sdyvqX+5cODccFRxisNWs d4DKAfI0TaNztshTKMhOkzVvrkpIDlCnf/3OXr7U= X-Original-To: libc-alpha@sourceware.org Delivered-To: libc-alpha@sourceware.org Received: from smtp-out1.suse.de (smtp-out1.suse.de [IPv6:2001:67c:2178:6::1c]) by sourceware.org (Postfix) with ESMTPS id B9AEC385783F for ; Tue, 16 May 2023 14:37:45 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org B9AEC385783F Received: from relay2.suse.de (relay2.suse.de [149.44.160.134]) by smtp-out1.suse.de (Postfix) with ESMTP id E281921D68 for ; Tue, 16 May 2023 14:37:44 +0000 (UTC) Received: from hawking.suse.de (unknown [10.168.4.11]) by relay2.suse.de (Postfix) with ESMTP id D565B2C141 for ; Tue, 16 May 2023 14:37:44 +0000 (UTC) Received: by hawking.suse.de (Postfix, from userid 17005) id C95F14A04D3; Tue, 16 May 2023 16:37:44 +0200 (CEST) To: libc-alpha@sourceware.org Subject: [PATCH] rtld: properly handle root directory in load path (bug 30435) X-Yow: Is a tattoo real, like a curb or a battleship? Or are we suffering in Safeway? Date: Tue, 16 May 2023 16:37:44 +0200 Message-ID: User-Agent: Gnus/5.13 (Gnus v5.13) MIME-Version: 1.0 X-Spam-Status: No, score=-9.1 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, 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: 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: , X-Patchwork-Original-From: Andreas Schwab via Libc-alpha From: Andreas Schwab Reply-To: Andreas Schwab Errors-To: libc-alpha-bounces+patchwork=sourceware.org@sourceware.org Sender: "Libc-alpha" Don't strip the trailing slash when checking for existence of a load path element to handle the special case of the root directory. Reviewed-by: Siddhesh Poyarekar --- elf/dl-load.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/elf/dl-load.c b/elf/dl-load.c index 39c63ff1b3..2aa487b49a 100644 --- a/elf/dl-load.c +++ b/elf/dl-load.c @@ -1859,7 +1859,7 @@ open_path (const char *name, size_t namelen, int mode, test whether there is any directory at all. */ struct __stat64_t64 st; - buf[buflen - namelen - 1] = '\0'; + buf[buflen - namelen] = '\0'; if (__stat64_time64 (buf, &st) != 0 || ! S_ISDIR (st.st_mode))