From: Todd C. Miller Date: Tue, 7 Oct 2014 16:56:50 +0000 (-0600) Subject: Avoid comparing new cwd with old one if getcwd() failed. X-Git-Tag: SUDO_1_8_12^2~160 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=dc67442151470bf14274ec6178e415ca8a73be1d;p=sudo Avoid comparing new cwd with old one if getcwd() failed. Bug #670 --- diff --git a/src/sudo.c b/src/sudo.c index 05d5214a5..ee306774a 100644 --- a/src/sudo.c +++ b/src/sudo.c @@ -1003,8 +1003,9 @@ exec_setup(struct command_details *details, const char *ptyname, int ptyfd) * Only change cwd if we have chroot()ed or the policy modules * specifies a different cwd. Must be done after uid change. */ - if (details->cwd) { - if (details->chroot || strcmp(details->cwd, user_details.cwd) != 0) { + if (details->cwd != NULL) { + if (details->chroot || user_details.cwd == NULL || + strcmp(details->cwd, user_details.cwd) != 0) { /* Note: cwd is relative to the new root, if any. */ if (chdir(details->cwd) != 0) { sudo_warn(U_("unable to change directory to %s"), details->cwd);