diff options
author | Todd C. Miller <Todd.Miller@sudo.ws> | 2023-05-08 14:18:56 -0600 |
---|---|---|
committer | Todd C. Miller <Todd.Miller@sudo.ws> | 2023-05-08 14:18:56 -0600 |
commit | 131e61b5ef0484ce10f418e0e19c4cf2b0b4abe6 (patch) | |
tree | aa03319aa5ef2da7f83555374597a2f629d039ab | |
parent | b0e1ffc45b20e3441ca58140525547c5ee04dae2 (diff) | |
download | sudo-131e61b5ef0484ce10f418e0e19c4cf2b0b4abe6.tar.gz |
push_include_int: Avoid passing close(2) a negative value on error.
Coverity CID 314108
-rw-r--r-- | plugins/sudoers/toke.c | 3 | ||||
-rw-r--r-- | plugins/sudoers/toke.l | 3 |
2 files changed, 4 insertions, 2 deletions
diff --git a/plugins/sudoers/toke.c b/plugins/sudoers/toke.c index f71712c29..670357600 100644 --- a/plugins/sudoers/toke.c +++ b/plugins/sudoers/toke.c @@ -5862,7 +5862,8 @@ push_include_int(const char *opath, bool isdir, int verbose) fd = sudo_open_conf_path(path, dname, sizeof(dname), NULL); status = sudo_secure_fd(fd, S_IFDIR, sudoers_uid, sudoers_gid, &sb); - close(fd); /* XXX use in read_dir_files? */ + if (fd != -1) + close(fd); /* XXX use in read_dir_files? */ if (status != SUDO_PATH_SECURE) { if (verbose > 0) { switch (status) { diff --git a/plugins/sudoers/toke.l b/plugins/sudoers/toke.l index 1d265f68c..fdcd27232 100644 --- a/plugins/sudoers/toke.l +++ b/plugins/sudoers/toke.l @@ -1315,7 +1315,8 @@ push_include_int(const char *opath, bool isdir, int verbose) fd = sudo_open_conf_path(path, dname, sizeof(dname), NULL); status = sudo_secure_fd(fd, S_IFDIR, sudoers_uid, sudoers_gid, &sb); - close(fd); /* XXX use in read_dir_files? */ + if (fd != -1) + close(fd); /* XXX use in read_dir_files? */ if (status != SUDO_PATH_SECURE) { if (verbose > 0) { switch (status) { |