From: Todd C. Miller Date: Thu, 5 May 2016 21:01:22 +0000 (-0600) Subject: Avoid calling fclose(NULL) if the sudoers file is not secure and X-Git-Tag: SUDO_1_8_17^2~114 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=64142f9da2a47477eceeb4c2162a68c51bcf5609;p=sudo Avoid calling fclose(NULL) if the sudoers file is not secure and restore_perms() fails. Coverity CID 104090. --- diff --git a/plugins/sudoers/sudoers.c b/plugins/sudoers/sudoers.c index 767d5a06d..34631a260 100644 --- a/plugins/sudoers/sudoers.c +++ b/plugins/sudoers/sudoers.c @@ -939,8 +939,10 @@ open_sudoers(const char *sudoers, bool doedit, bool *keepopen) if (!restore_perms()) { /* unable to change back to root */ - fclose(fp); - fp = NULL; + if (fp != NULL) { + fclose(fp); + fp = NULL; + } } debug_return_ptr(fp);