push_include_int: Avoid passing close(2) a negative value on error.

Coverity CID 314108
This commit is contained in:
Todd C. Miller
2023-05-08 14:18:56 -06:00
parent f722272b7c
commit fb9d0d79a7
2 changed files with 4 additions and 2 deletions

View File

@@ -5862,6 +5862,7 @@ push_include_int(const char *opath, bool isdir, int verbose)
fd = sudo_open_conf_path(path, dname, sizeof(dname), NULL); fd = sudo_open_conf_path(path, dname, sizeof(dname), NULL);
status = sudo_secure_fd(fd, S_IFDIR, sudoers_uid, sudoers_gid, &sb); status = sudo_secure_fd(fd, S_IFDIR, sudoers_uid, sudoers_gid, &sb);
if (fd != -1)
close(fd); /* XXX use in read_dir_files? */ close(fd); /* XXX use in read_dir_files? */
if (status != SUDO_PATH_SECURE) { if (status != SUDO_PATH_SECURE) {
if (verbose > 0) { if (verbose > 0) {

View File

@@ -1315,6 +1315,7 @@ push_include_int(const char *opath, bool isdir, int verbose)
fd = sudo_open_conf_path(path, dname, sizeof(dname), NULL); fd = sudo_open_conf_path(path, dname, sizeof(dname), NULL);
status = sudo_secure_fd(fd, S_IFDIR, sudoers_uid, sudoers_gid, &sb); status = sudo_secure_fd(fd, S_IFDIR, sudoers_uid, sudoers_gid, &sb);
if (fd != -1)
close(fd); /* XXX use in read_dir_files? */ close(fd); /* XXX use in read_dir_files? */
if (status != SUDO_PATH_SECURE) { if (status != SUDO_PATH_SECURE) {
if (verbose > 0) { if (verbose > 0) {