1
0
mirror of https://github.com/openbsd/src.git synced 2026-05-01 17:46:35 +00:00

when processing readdir(), this incorrectly did fstatat() against "..".

observed during experimental work with O_BELOW
ok millert, who may want to refactor this further.
This commit is contained in:
deraadt
2025-05-31 14:21:07 +00:00
parent 4ea7651800
commit b1475176e6

View File

@@ -1,4 +1,4 @@
/* $OpenBSD: at.c,v 1.85 2024/11/05 16:26:01 sobrado Exp $ */
/* $OpenBSD: at.c,v 1.86 2025/05/31 14:21:07 deraadt Exp $ */
/*
* at.c : Put file into atrun queue
@@ -495,6 +495,8 @@ list_jobs(int argc, char **argv, int count_only, int csort)
/* Loop over every file in the directory. */
while ((dirent = readdir(spool)) != NULL) {
if (strcmp(dirent->d_name, "..") == 0)
continue;
if (fstatat(dfd, dirent->d_name, &stbuf, AT_SYMLINK_NOFOLLOW) != 0)
fatal("%s", dirent->d_name);
@@ -653,6 +655,8 @@ process_jobs(int argc, char **argv, int what)
/* Loop over every file in the directory */
changed = 0;
while ((dirent = readdir(spool)) != NULL) {
if (strcmp(dirent->d_name, "..") == 0)
continue;
if (fstatat(dfd, dirent->d_name, &stbuf, AT_SYMLINK_NOFOLLOW) != 0)
fatal("%s", dirent->d_name);