Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
34 changes: 17 additions & 17 deletions plugins/sudoers/match_digest.c
Original file line number Diff line number Diff line change
Expand Up @@ -53,25 +53,25 @@ digest_matches(int fd, const char *path, const char *runchroot,
debug_return_int(ALLOW);
}

if (fd == -1) {
fd2 = open(path, O_RDONLY|O_NONBLOCK);
if (fd2 == -1) {
/* No file, no match. */
goto done;
}
fd = fd2;
if (runchroot != NULL) {
/* XXX - handle symlinks and '..' in path outside chroot */
const int len =
snprintf(pathbuf, sizeof(pathbuf), "%s%s", runchroot, path);
if (len >= ssizeof(pathbuf)) {
errno = ENAMETOOLONG;
sudo_warn("%s%s", runchroot, path);
goto done;
}
path = pathbuf;
}

if (runchroot != NULL) {
/* XXX - handle symlinks and '..' in path outside chroot */
const int len =
snprintf(pathbuf, sizeof(pathbuf), "%s%s", runchroot, path);
if (len >= ssizeof(pathbuf)) {
errno = ENAMETOOLONG;
sudo_warn("%s%s", runchroot, path);
goto done;
}
path = pathbuf;
if (fd == -1) {
fd2 = open(path, O_RDONLY|O_NONBLOCK);
if (fd2 == -1) {
/* No file, no match. */
goto done;
}
fd = fd2;
}

TAILQ_FOREACH(digest, digests, entries) {
Expand Down