From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from EUR02-VI1-obe.outbound.protection.outlook.com (mail-vi1eur02on2047.outbound.protection.outlook.com [40.107.241.47]) by sourceware.org (Postfix) with ESMTPS id DC9283858C2D for ; Mon, 13 Nov 2023 16:55:11 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org DC9283858C2D Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=arm.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=arm.com ARC-Filter: OpenARC Filter v1.0.0 sourceware.org DC9283858C2D Authentication-Results: server2.sourceware.org; arc=pass smtp.remote-ip=40.107.241.47 ARC-Seal: i=3; a=rsa-sha256; d=sourceware.org; s=key; t=1699894514; cv=pass; b=oDk5Ly7pokFfKeQFmyf2YJkp9CXSr1vwku8a47XGaUrK+N1ARVOeWw8wuQLQ/EFIXmvIKkJnoSV+z0X4MpnlQDdO7EWvIEzqQrMUubx3wSu0qHRI6sOZ7pl4WtSp6jg0myPzkkFRVTadXV2UUuAmZB63Uog2R1Jb+5ijb3tWiww= ARC-Message-Signature: i=3; a=rsa-sha256; d=sourceware.org; s=key; t=1699894514; c=relaxed/simple; bh=hk2Kgody2p9miwZPlQPFWB7daNST0aibNujAnWlWDrg=; h=DKIM-Signature:DKIM-Signature:Date:From:To:Subject:Message-ID: MIME-Version; b=MIKtAPzSVJdptCMbxotTOo4Q2oqdc502CILRj94bPfTTG45WxKHyjo4eLZ81k3y23zbQZhPPYzavvNkcvG67RWL4C9lsKC7/7d56VXDTxtomJTBYrCVpNMGsTbBKOO88f+FxO4tlV1kEOxPMoLytu7Y4Wt/JNQU1Y32o74PTEtA= ARC-Authentication-Results: i=3; server2.sourceware.org ARC-Seal: i=2; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=pass; b=VvpjIamGkvVGK4abZeGDQ80uA712530xtSJWtemUNycKEPabar2vHHErrULtlukSul9Qq0kDeRRhb/WWmK/IDhLhgAU45KFMJdksD9+TN7M/d9CypTA9Wj2R+xxITkvB7DeFWHkJS5Ub0aqaEe/iuTAUBGtAujCUjI8nmZHir2wbTXNgOo6jq4AhOhsWN3FxvrDbBVJy0iNIyRdFxvuEc9q/bTMptf5A6gdpCUHoFCN0VdalDAhjR1nVMt5z7FnSx2S/919V/KBAfD/pJY0MPYaj6YgVR1qmt6iey/gi4d/Wuwgp32anWo83lVMleOLedKLNpCabo/6BdgdhMfZfjw== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=xxYzoRPzNavuv4F+iasBjChV7jziAXBiBrDTFwDEFmU=; b=IfNPj/jfRgCeGj6Bmne4rwKiVduJXCPXVvX6a+BZxv4py2dqrO5+kJXedNYpmHYBMzdhnJVc1qz8sXn0XCV4YRBSKNKxTQG71+FRccM6IsrXMgwxXJeWXo0cyCLKfxovKa5OEPKb3ml4y5cNORrO+M/o05I4ys2av38jYxxLUWt8PXn/SpCMupOAtnj44R6MK/lZVHcUyArOULuNqdYtQZ9em9u2eUpe5/ZfAlZ2WwDADNh1TBUEksDu0wtBUXjQmxzeFch1AV6tymZAc9brpvCgSr06dpkGwLkrbSyE/g640KFTRFNuPsLf6mzoB/pZtkDJImvHQl+veMuaLVaWAQ== ARC-Authentication-Results: i=2; mx.microsoft.com 1; spf=pass (sender ip is 63.35.35.123) smtp.rcpttodomain=sourceware.org smtp.mailfrom=arm.com; dmarc=pass (p=none sp=none pct=100) action=none header.from=arm.com; dkim=pass (signature was verified) header.d=armh.onmicrosoft.com; arc=pass (0 oda=1 ltdi=1 spf=[1,1,smtp.mailfrom=arm.com] dkim=[1,1,header.d=arm.com] dmarc=[1,1,header.from=arm.com]) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=armh.onmicrosoft.com; s=selector2-armh-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=xxYzoRPzNavuv4F+iasBjChV7jziAXBiBrDTFwDEFmU=; b=hfJaH4jT7TzdtqVaWsCY4UTgzMfYp0uYleMXy1bpOGon2SbPZ4QtIDRP5haVYXJxp719NNYfEL3tT4B90gDpwhmOe8xj0s4x/kH7QP+5vomOHKbuRF5V2mYA7/FFdApK8gGtCvuwHYyLD7pK+twDSR4R8c+5giPNsXSiL2XVw4g= Received: from DU7PR01CA0023.eurprd01.prod.exchangelabs.com (2603:10a6:10:50f::20) by AM0PR08MB5522.eurprd08.prod.outlook.com (2603:10a6:208:18c::8) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6977.29; Mon, 13 Nov 2023 16:55:06 +0000 Received: from DU2PEPF0001E9C4.eurprd03.prod.outlook.com (2603:10a6:10:50f:cafe::cd) by DU7PR01CA0023.outlook.office365.com (2603:10a6:10:50f::20) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6977.31 via Frontend Transport; Mon, 13 Nov 2023 16:55:04 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 63.35.35.123) smtp.mailfrom=arm.com; dkim=pass (signature was verified) header.d=armh.onmicrosoft.com;dmarc=pass action=none header.from=arm.com; Received-SPF: Pass (protection.outlook.com: domain of arm.com designates 63.35.35.123 as permitted sender) receiver=protection.outlook.com; client-ip=63.35.35.123; helo=64aa7808-outbound-1.mta.getcheckrecipient.com; pr=C Received: from 64aa7808-outbound-1.mta.getcheckrecipient.com (63.35.35.123) by DU2PEPF0001E9C4.mail.protection.outlook.com (10.167.8.73) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7002.13 via Frontend Transport; Mon, 13 Nov 2023 16:55:04 +0000 Received: ("Tessian outbound e243565b0037:v228"); Mon, 13 Nov 2023 16:55:04 +0000 X-CheckRecipientChecked: true X-CR-MTA-CID: 71ce8e77bcce58ab X-CR-MTA-TID: 64aa7808 Received: from b214871a842e.1 by 64aa7808-outbound-1.mta.getcheckrecipient.com id 94870D25-76F5-4EA8-BEAC-1AE78E99F378.1; Mon, 13 Nov 2023 16:54:57 +0000 Received: from EUR04-VI1-obe.outbound.protection.outlook.com by 64aa7808-outbound-1.mta.getcheckrecipient.com with ESMTPS id b214871a842e.1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384); Mon, 13 Nov 2023 16:54:57 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=cx1DYZmKzTHtSZ2PPmf//mbSRxB9eY6afnBUs+Och3XNe8J79kv+TU3iKJP98KkitigPUkCGiuUEfPUf+gNZUaEE6wLyxuYn5zolwBS2giAWnfD4BJOTaHLEw+tF4SunTTjWT/K1Me5o/FJK6D2iFK0unEtZ7/FuyJUzgMdAyTWA0tdnGS/I8i73tdxuN84TX8XGZq0JPlFY/6hEu+9lb2i9thhnvp0YOt5Mn/sUo4wOGzOqrh7CcmBjGXgLYeiSh9TuUZlxRQ9X2fjJq7RwLx+j42cEsnWoq2wmqdvrJSycrmE2K/P0dO7v/zsOrloIFGglDagFU9zG/xE+IU43Ew== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=xxYzoRPzNavuv4F+iasBjChV7jziAXBiBrDTFwDEFmU=; b=d5bbiMoQjNVAqkXeLy+XXumzzxWCM6CDFoWL6P9ah4+rNek9wqLDxXM/R5YgDCiXKfdpiwTcQhAFF4tSQ7BZqTJhxTCYqN6A0uHBu3LxqQUo0hZ32J4FJ9gYuRnTrU+jXq3pOCbIszaZKTb4WsQCXlBhq/32Fc2n0zvLhGxwP50ZYlKfktHQ0u2XoRd+dOYYmIBQWYgxMktHRVNcHGgIv3POiVpnCJCaMceI9LHACaO46w4jYmTkaLz136fSgIi2BCupiyU2owR212Ea71pgObtOP7Z12euG6DaO0/zVnh94izzSYhFno9/+ujQsEvqVYiKaF8lNgNvoE5IlIpbjYQ== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=arm.com; dmarc=pass action=none header.from=arm.com; dkim=pass header.d=arm.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=armh.onmicrosoft.com; s=selector2-armh-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=xxYzoRPzNavuv4F+iasBjChV7jziAXBiBrDTFwDEFmU=; b=hfJaH4jT7TzdtqVaWsCY4UTgzMfYp0uYleMXy1bpOGon2SbPZ4QtIDRP5haVYXJxp719NNYfEL3tT4B90gDpwhmOe8xj0s4x/kH7QP+5vomOHKbuRF5V2mYA7/FFdApK8gGtCvuwHYyLD7pK+twDSR4R8c+5giPNsXSiL2XVw4g= Authentication-Results-Original: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=arm.com; Received: from DB9PR08MB7179.eurprd08.prod.outlook.com (2603:10a6:10:2cc::19) by PAWPR08MB9495.eurprd08.prod.outlook.com (2603:10a6:102:2eb::17) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6977.29; Mon, 13 Nov 2023 16:54:55 +0000 Received: from DB9PR08MB7179.eurprd08.prod.outlook.com ([fe80::a991:ac53:e218:e554]) by DB9PR08MB7179.eurprd08.prod.outlook.com ([fe80::a991:ac53:e218:e554%3]) with mapi id 15.20.6977.029; Mon, 13 Nov 2023 16:54:55 +0000 Date: Mon, 13 Nov 2023 16:54:40 +0000 From: Szabolcs Nagy To: Adhemerval Zanella , libc-alpha@sourceware.org Cc: Matthew Malcomson Subject: Re: [PATCH] elf: Handle non-directory name in search path (BZ 31035) Message-ID: References: <20231110140348.1206879-1-adhemerval.zanella@linaro.org> Content-Type: text/plain; charset=utf-8 Content-Disposition: inline In-Reply-To: <20231110140348.1206879-1-adhemerval.zanella@linaro.org> X-ClientProxiedBy: LO4P123CA0411.GBRP123.PROD.OUTLOOK.COM (2603:10a6:600:189::20) To DB9PR08MB7179.eurprd08.prod.outlook.com (2603:10a6:10:2cc::19) MIME-Version: 1.0 X-MS-TrafficTypeDiagnostic: DB9PR08MB7179:EE_|PAWPR08MB9495:EE_|DU2PEPF0001E9C4:EE_|AM0PR08MB5522:EE_ X-MS-Office365-Filtering-Correlation-Id: e7453270-8cda-42ba-bb55-08dbe46948bf x-checkrecipientrouted: true NoDisclaimer: true X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam-Untrusted: BCL:0; X-Microsoft-Antispam-Message-Info-Original: 0HkaKzs9jM9wFL4A1vMUzT+rSbtRwFMvcHi5joYl54w2kdZeOoGJsnX43Cl4ske7YAQfWazuIpme415WqYMrnvYfZQjMNVsfaXS9FqhrSozLqe/cme3cUFUido3xN/Dmu1fIgNbPNXki/ZUOJaZdUpqbJyAMZwBKobBvmSBKfJ11TNfZMjxQzuqXHSMYAgtwlRoIdhTa+M3NTvezdkDCKAL5DwONnDulLIa/7tYaYS7GPf8KQOxgyDtwgB+3DP+T2BS7he6GjDSDUK3Vjhf5fszACvL9WENUNG7GY4JFx5eHdf3j8TWyxvQPnt0lZQvfn2ZK+W+fL62JyN4kNSJ59XTYQqsAxUc4ITwWEIXj4iNffcmom/+yrpa4LfVmno9BSSoqvQO3DPnZTXnZO5qNw6ZM+Xc0lyzAZUqrDbLdAW5e8pyJbXHU1uBzx39Hoi6BrGBmb49U+0YaiyeA8qcRST/ppUpZav6F2VtQ94HhLeSZ7zK939CMB7vg9CFFuVqtt+vHYKC61rxKCLD/XIQ4YyvTDeop3wDqX7H3mIA9X5z3oQyJ7YGcHs7pFeJJGNLn8IPQx3MUEjihwAHbqLZGd0+4bz7b5c4/lgQhke8sICI= X-Forefront-Antispam-Report-Untrusted: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:DB9PR08MB7179.eurprd08.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230031)(136003)(376002)(346002)(366004)(396003)(39860400002)(230922051799003)(186009)(1800799009)(64100799003)(451199024)(66476007)(66946007)(66556008)(86362001)(36756003)(38100700002)(6512007)(83380400001)(26005)(6506007)(6666004)(2616005)(41300700001)(2906002)(478600001)(316002)(6486002)(44832011)(5660300002)(4326008)(8936002)(8676002)(2004002);DIR:OUT;SFP:1101; X-MS-Exchange-Transport-CrossTenantHeadersStamped: PAWPR08MB9495 Original-Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=arm.com; X-EOPAttributedMessage: 0 X-MS-Exchange-Transport-CrossTenantHeadersStripped: DU2PEPF0001E9C4.eurprd03.prod.outlook.com X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id-Prvs: e40e0282-a015-45cf-58a9-08dbe46942e6 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: s1pkFkeAU7zI2xhQRqLqOs9U0nSpZjodMp0rktQPiwlamzB1lMR2JjQFGSDEPq6yxmgtARL+da+fwLdzPb2dEJT/HnArC+7WQ7P829xOpzAcqsEhTNJZMwVpbQjkq/4k5PxpeuIu9Bnw1nmeNmw+k/6osk2E8BAUSYMEupY6yxWffZEXa5p+H481D0jA36nD/B8ZIakSHROOxgIEIS3J13F7J5/D+YU8acQy9s4wAqLtT82YvxiHskwIBPClVFeURV6qu8Yxv9y4qITMKzM1irLFsVPPid2hEJYc94xqwrgbLYSoxQUl+SPdGNoNbf2XK7yyswwPKwtEjSsyzM80Rxy5e1/yR2KqDokF3sKW7q9nG8FenPLX3yWOVpFY1fZRpHp2cCuuo30+aQ3cH6x3TtW9xJ+LnCnsfFFQK3oWyuijRMBQ5+zY6s1iQJ70/NL5nnoP4ixbs8+akVok5KIvSQpR86nNa/v5DLufazGnJwR5pm3TfVTTLIig0MZqH1uc+EESvfYeM5Ap+lD8zA+eQRwSH4pj03CE6OFqhFcFh9OObwsqftA1/uLIHdBJV+R6RJ/yICtPgfcUzKHJvJSfYFKDPvwDHyRndJlycOQbJZNNW88z9RZ5HhwhftxHEZmRnQs17zqaBNv7URaP45keLs+IRxNWrTzJeyiA8KjUhqK+I2ytQ2yvu6Vd8aRemFCybttavnOAKjDR36IZ8l7or6MtSiMHKtkX4edxiT+iElu438X8KineAy6DOOqv7xaM X-Forefront-Antispam-Report: CIP:63.35.35.123;CTRY:IE;LANG:en;SCL:1;SRV:;IPV:CAL;SFV:NSPM;H:64aa7808-outbound-1.mta.getcheckrecipient.com;PTR:ec2-63-35-35-123.eu-west-1.compute.amazonaws.com;CAT:NONE;SFS:(13230031)(4636009)(39860400002)(346002)(396003)(136003)(376002)(230922051799003)(64100799003)(82310400011)(451199024)(1800799009)(186009)(46966006)(40470700004)(36840700001)(316002)(6512007)(70586007)(70206006)(83380400001)(82740400003)(8676002)(40480700001)(8936002)(4326008)(6486002)(81166007)(478600001)(36756003)(356005)(6506007)(6666004)(44832011)(40460700003)(5660300002)(86362001)(2616005)(36860700001)(2906002)(47076005)(26005)(336012)(41300700001)(2004002);DIR:OUT;SFP:1101; X-OriginatorOrg: arm.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 13 Nov 2023 16:55:04.6281 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: e7453270-8cda-42ba-bb55-08dbe46948bf X-MS-Exchange-CrossTenant-Id: f34e5979-57d9-4aaa-ad4d-b122a662184d X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=f34e5979-57d9-4aaa-ad4d-b122a662184d;Ip=[63.35.35.123];Helo=[64aa7808-outbound-1.mta.getcheckrecipient.com] X-MS-Exchange-CrossTenant-AuthSource: DU2PEPF0001E9C4.eurprd03.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM0PR08MB5522 X-Spam-Status: No, score=-11.5 required=5.0 tests=BAYES_00,DKIM_SIGNED,DKIM_VALID,FORGED_SPF_HELO,GIT_PATCH_0,KAM_DMARC_NONE,KAM_SHORT,RCVD_IN_DNSWL_NONE,RCVD_IN_MSPIKE_H2,SPF_HELO_PASS,SPF_NONE,TXREP,T_SCC_BODY_TEXT_LINE,UNPARSEABLE_RELAY autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org List-Id: The 11/10/2023 11:03, Adhemerval Zanella wrote: > The open_path stops if a relative path in search patch contains a > component that is a non directory (for instance, if the component > is an existing file). > > For instance: > > $ cat > lib.c < > void foo (void) {} > > EOF > $ gcc -shared -fPIC -o lib.so lib.c > $ cat > main.c < extern void foo (); > int main () { foo (); return 0; } > EOF > $ gcc -o main main.c lib.so > $ LD_LIBRARY_PATH=. ./main > $ LD_LIBRARY_PATH=non-existing/path:. ./main > $ LD_LIBRARY_PATH=$(pwd)/main:. ./main > $ LD_LIBRARY_PATH=./main:. ./main > ./main: error while loading shared libraries: lib.so: cannot open shared object file: No such file or directory > > The invalid './main' should be ignored and a non-existent one, > instead as a valid but non acessible file. > > Aboslute pathd do not triger this issue because its status are > initialized as 'unknown' and open_path check if this is a directory. > > Checked on x86_64-linux-gnu. > --- > elf/Makefile | 12 ++++++ > elf/dl-load.c | 9 ++-- > elf/tst-non-directory-mod.c | 1 + > elf/tst-non-directory-path.c | 4 ++ > elf/tst-non-directory-path.sh | 77 +++++++++++++++++++++++++++++++++++ > 5 files changed, 100 insertions(+), 3 deletions(-) > create mode 100644 elf/tst-non-directory-mod.c > create mode 100644 elf/tst-non-directory-path.c > create mode 100755 elf/tst-non-directory-path.sh > > diff --git a/elf/Makefile b/elf/Makefile > index f9bd86a05a..f70ec7cb84 100644 > --- a/elf/Makefile > +++ b/elf/Makefile > @@ -428,6 +428,7 @@ tests += \ > tst-nodelete-opened \ > tst-nodelete2 \ > tst-noload \ > + tst-non-directory-path \ > tst-null-argv \ > tst-p_align1 \ > tst-p_align2 \ > @@ -856,6 +857,7 @@ modules-names += \ > tst-nodelete-dlclose-plugin \ > tst-nodelete-opened-lib \ > tst-nodelete2mod \ > + tst-non-directory-mod \ > tst-null-argv-lib \ > tst-p_alignmod-base \ > tst-p_alignmod3 \ > @@ -1122,6 +1124,7 @@ ifeq (yes,$(build-shared)) > ifeq ($(run-built-tests),yes) > tests-special += \ > $(objpfx)argv0test.out \ > + $(objpfx)tst-non-directory-path.out \ > $(objpfx)tst-pathopt.out \ > $(objpfx)tst-rtld-help.out \ > $(objpfx)tst-rtld-list-diagnostics.out \ > @@ -2987,3 +2990,12 @@ $(objpfx)tst-decorate-maps: $(shared-thread-library) > tst-decorate-maps-ENV = \ > GLIBC_TUNABLES=glibc.malloc.arena_max=8:glibc.malloc.mmap_threshold=1024:glibc.mem.decorate_maps=1 > tst-decorate-maps-ARGS = 8 > + > +LDFLAGS-tst-non-directory-mod.so = -Wl,-soname,tst-non-directory-mod.so > +$(objpfx)tst-non-directory-path: $(objpfx)tst-non-directory-mod.so > +$(objpfx)tst-non-directory-path.out: tst-non-directory-path.sh \ > + $(objpfx)tst-non-directory-path > + $(SHELL) tst-non-directory-path.sh $(objpfx)ld.so $(objpfx)tst-non-directory-path \ > + '$(test-wrapper-env)' '$(run_program_env)' \ > + '$(rpath-link)' $(objpfx) > $@; \ > + $(evaluate-test) > diff --git a/elf/dl-load.c b/elf/dl-load.c > index 2923b1141d..8d351153c8 100644 > --- a/elf/dl-load.c > +++ b/elf/dl-load.c > @@ -1810,7 +1810,6 @@ open_path (const char *name, size_t namelen, int mode, > size_t cnt; > char *edp; > int here_any = 0; > - int err; > > /* If we are debugging the search for libraries print the path > now if it hasn't happened now. */ > @@ -1911,8 +1910,12 @@ open_path (const char *name, size_t namelen, int mode, > return -1; > } > } > - if (here_any && (err = errno) != ENOENT && err != EACCES) > - /* The file exists and is readable, but something went wrong. */ > + > + /* Continue the search if the file does not exist (ENOENT), if it can > + not be accessed (EACCES), or if the a component in the path is not a > + directory (for instance, if the component is a existing file meaning > + essentially that the pathname is invalid - ENOTDIR). */ > + if (here_any && errno != ENOENT && errno != EACCES && errno != ENOTDIR) > return -1; OK. > --- /dev/null > +++ b/elf/tst-non-directory-mod.c > @@ -0,0 +1 @@ > +void foo (void) {} > diff --git a/elf/tst-non-directory-path.c b/elf/tst-non-directory-path.c > new file mode 100644 > index 0000000000..cb54289a07 > --- /dev/null > +++ b/elf/tst-non-directory-path.c > @@ -0,0 +1,4 @@ > +int main (int argc, char *argv[]) > +{ > + return 0; > +} i think there should be a reference to foo. (otherwise a compiler that defaults to --as-needed would not include the module as dependency.) > diff --git a/elf/tst-non-directory-path.sh b/elf/tst-non-directory-path.sh > new file mode 100755 > index 0000000000..b21cae30c6 > --- /dev/null > +++ b/elf/tst-non-directory-path.sh > @@ -0,0 +1,77 @@ > +#!/bin/sh > +# Test if library search path does not terminates with non-directory > +# components. > +# Copyright (C) 2023 Free Software Foundation, Inc. > +# This file is part of the GNU C Library. > +# > +# The GNU C Library is free software; you can redistribute it and/or > +# modify it under the terms of the GNU Lesser General Public > +# License as published by the Free Software Foundation; either > +# version 2.1 of the License, or (at your option) any later version. > +# > +# The GNU C Library is distributed in the hope that it will be useful, > +# but WITHOUT ANY WARRANTY; without even the implied warranty of > +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU > +# Lesser General Public License for more details. > +# > +# You should have received a copy of the GNU Lesser General Public > +# License along with the GNU C Library; if not, see > +# . > + > +set -e > + > +rtld=$1 > +test_program=$2 > +test_wrapper_env=$3 > +run_program_env=$4 > +# Remove the last space to allow concatenate extra paths. > +library_path=$(echo $5 | tr -d '[:space:]') i'd expect that "$(echo $5)" alone would strip whitespace. > +objpfx=$6 > + > +test_binary=$(basename ${test_program}) > +test_libpath=${test_binary}-x > + > +mkdir -p ${objpfx}/${test_libpath} > +mv ${objpfx}/tst-non-directory-mod.so ${objpfx}/${test_libpath} > + > +# Check with absolute paths. > +${test_wrapper_env} \ > +${run_program_env} \ > +$rtld --inhibit-cache \ > + --library-path \ > + "$library_path":"${objpfx}"tst-non-directory-invalid:"${objpfx}"${test_libpath} \ > + $test_program 2>&1 && rc=0 || rc=$? > + > +${test_wrapper_env} \ > +${run_program_env} \ > +$rtld --inhibit-cache \ > + --library-path \ > + "$library_path":"${objpfx}"${test_binary}:"${objpfx}"${test_libpath} \ > + $test_program 2>&1 && rc=0 || rc=$? > + > +# Rlative paths along with non-existent path in search list. typo. > +cd "$objpfx" > +${test_wrapper_env} \ > +${run_program_env} \ > +$rtld --inhibit-cache \ > + --library-path \ > + "$library_path":../elf/tst-non-directory-invalid::../elf/${test_libpath} \ > + $test_program 2>&1 && rc=0 || rc=$? > + > +# Relative paths along with component in the path is not a directory in search list. > +${test_wrapper_env} \ > +${run_program_env} \ > +$rtld --inhibit-cache \ > + --library-path \ > + "$library_path":../elf/${test_binary}:../elf/${test_libpath} \ > + $test_program 2>&1 && rc=0 || rc=$? > + > +# Relative paths along with non-existent path and a component in the path that is not a directory. > +${test_wrapper_env} \ > +${run_program_env} \ > +$rtld --inhibit-cache \ > + --library-path \ > + "$library_path":../elf/tst-non-directory-invalid:../elf/${test_binary}:../elf/${test_libpath} \ > + $test_program 2>&1 && rc=0 || rc=$? > + > +exit $rc rest of the test looks ok.