Re: getcwd() returns with stale errno value upon error
From:
Chet Ramey
Subject:
Re: getcwd() returns with stale errno value upon error
Date:
Thu, 26 Jun 2025 10:25:03 -0400
User-agent:
Mozilla Thunderbird
On 6/25/25 3:44 AM, Richard Weinberger wrote:
Bash Version: 5.2
Patch Level: 37
Release Status: release
Description:
getcwd() as implemented in lib/sh/getcwd.c can return with NULL and a
stale errno value if the algorithm fails. It aborts if readdir()
returns NULL and no matching directory entry was found.
But bash's getcwd() assumes that NULL from readdir() is always an
error,
which is not the case.
This can happen on filesystems where d_ino != st_ino such as
on Linux's OverlayFS.
Thanks for the report. I'll look at this after bash-5.3 is released.
Chet
--
``The lyf so short, the craft so long to lerne.'' - Chaucer
``Ars longa, vita brevis'' - Hippocrates
Chet Ramey, UTech, CWRU chet@case.edu http://tiswww.cwru.edu/~chet/