Skip to content

Commit 26a1a75

Browse files
committed
digest_matches: plug fd leak on snprinf() failure
1 parent 55d3c99 commit 26a1a75

File tree

2 files changed

+6
-3
lines changed

2 files changed

+6
-3
lines changed

plugins/sudoers/match_command.c

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -272,7 +272,8 @@ command_matches_dir(struct sudoers_context *ctx, const char *sudoers_dir,
272272
len = snprintf(sdbuf, sizeof(sdbuf), "%s%s", runchroot, sudoers_dir);
273273
if (len >= ssizeof(sdbuf)) {
274274
errno = ENAMETOOLONG;
275-
debug_return_bool(false);
275+
sudo_warn("%s%s", runchroot, sudoers_dir);
276+
goto done;
276277
}
277278
sudoers_dir = sdbuf;
278279
chrootlen = strlen(runchroot);
@@ -536,7 +537,8 @@ command_matches_glob(struct sudoers_context *ctx, const char *sudoers_cmnd,
536537
snprintf(pathbuf, sizeof(pathbuf), "%s%s", runchroot, sudoers_cmnd);
537538
if (len >= ssizeof(pathbuf)) {
538539
errno = ENAMETOOLONG;
539-
debug_return_bool(false);
540+
sudo_warn("%s%s", runchroot, sudoers_cmnd);
541+
debug_return_int(DENY);
540542
}
541543
sudoers_cmnd = pathbuf;
542544
chrootlen = strlen(runchroot);

plugins/sudoers/match_digest.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,8 @@ digest_matches(int fd, const char *path, const char *runchroot,
7373
snprintf(pathbuf, sizeof(pathbuf), "%s%s", runchroot, path);
7474
if (len >= ssizeof(pathbuf)) {
7575
errno = ENAMETOOLONG;
76-
debug_return_bool(false);
76+
sudo_warn("%s%s", runchroot, path);
77+
goto done;
7778
}
7879
path = pathbuf;
7980
}

0 commit comments

Comments
 (0)