This is the mail archive of the
libc-alpha@sourceware.org
mailing list for the glibc project.
Re: [PATCH] linux: make getcwd(3) fail if it cannot obtain an absolute path [BZ #22679]
- From: Andreas Schwab <schwab at linux-m68k dot org>
- To: Florian Weimer <fweimer at redhat dot com>
- Cc: libc-alpha at sourceware dot org
- Date: Mon, 05 Feb 2018 20:03:01 +0100
- Subject: Re: [PATCH] linux: make getcwd(3) fail if it cannot obtain an absolute path [BZ #22679]
- Authentication-results: sourceware.org; auth=none
- References: <20180107030543.GA7248@altlinux.org> <1b4f7d9a-627a-85ec-e87a-bab0dc57df90@redhat.com>
On Feb 05 2018, Florian Weimer <fweimer@redhat.com> wrote:
> /* Like chdir(), but it keeps track of the current directory (in the
> * global "curr_dir"), and ensures that the path size doesn't overflow.
> * Also cleans the path using the clean_fname() function. */
> int change_dir(const char *dir, int set_path_only)
> {
> static int initialised, skipped_chdir;
> unsigned int len;
>
> if (!initialised) {
> initialised = 1;
> if (getcwd(curr_dir, sizeof curr_dir - 1) == NULL) {
> rsyserr(FERROR, errno, "getcwd()");
> exit_cleanup(RERR_FILESELECT);
> }
> curr_dir_len = strlen(curr_dir);
> }
This will also fail when rsync is started from a directory that has
since been removed, where getcwd (even the syscall) has always returned
an error. So this isn't a new failure.
Andreas.
--
Andreas Schwab, schwab@linux-m68k.org
GPG Key fingerprint = 58CA 54C7 6D53 942B 1756 01D3 44D5 214B 8276 4ED5
"And now for something completely different."