[PATCH] linux: make getcwd(3) fail if it cannot obtain an absolute path [BZ #22679]

Dmitry V. Levin ldv@altlinux.org
Tue Feb 6 00:10:00 GMT 2018


On Mon, Feb 05, 2018 at 08:18:46PM +0100, Florian Weimer wrote:
> On 02/05/2018 08:03 PM, Andreas Schwab wrote:
> > 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.
> 
> That's a good point.  I still don't see how we can avoid fixing rsync.

I don't see why rsync shouldn't be fixed.


-- 
ldv
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 801 bytes
Desc: not available
URL: <http://sourceware.org/pipermail/libc-alpha/attachments/20180206/acb5574a/attachment.sig>


More information about the Libc-alpha mailing list