]> granicus.if.org Git - sudo/commitdiff
Avoid calling fclose(NULL) if the sudoers file is not secure and
authorTodd C. Miller <Todd.Miller@courtesan.com>
Thu, 5 May 2016 21:01:22 +0000 (15:01 -0600)
committerTodd C. Miller <Todd.Miller@courtesan.com>
Thu, 5 May 2016 21:01:22 +0000 (15:01 -0600)
restore_perms() fails.  Coverity CID 104090.

plugins/sudoers/sudoers.c

index 767d5a06d2324ba3f3a8cd69c1ccea759e5b0936..34631a260aba672864d1347d6bd4888d2726e5c2 100644 (file)
@@ -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);