Skip to content

Commit f51b3e2

Browse files
committed
ts_secure_opendir: Check for a NULL path
This prevents a NULL dereference if for some reason _PATH_SUDO_LOGDIR or _PATH_SUDO_LECTURE_DIR is not defined.
1 parent 8e0b9a9 commit f51b3e2

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

plugins/sudoers/timestamp.c

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -243,6 +243,12 @@ ts_secure_opendir(const char *path, bool make_it, bool quiet)
243243
struct stat sb;
244244
debug_decl(ts_secure_opendir, SUDOERS_DEBUG_AUTH);
245245

246+
/* Timestamp or lecture dir not defined? */
247+
if (path == NULL) {
248+
errno = ENOENT;
249+
debug_return_int(-1);
250+
}
251+
246252
sudo_debug_printf(SUDO_DEBUG_INFO|SUDO_DEBUG_LINENO, "checking %s", path);
247253
fd = sudo_secure_open_dir(path, timestamp_uid, timestamp_gid, &sb, &error);
248254
if (fd == -1) {

0 commit comments

Comments
 (0)