DPDK-dev Archive on lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] app/wycheproof: avoid path check before opening vectors
@ 2026-11-17 15:49 Kai Ji
  0 siblings, 0 replies; only message in thread
From: Kai Ji @ 2026-11-17 15:49 UTC (permalink / raw)
  To: dev; +Cc: Kai Ji

Checking the vector path with stat() before opening it leaves a
check/use race if the path changes between the two operations.

Open the directory directly and fall back to file processing only
when opendir() fails with ENOTDIR. Propagate other directory-open
errors and remove the unused stat header.

Coverity issue: 360736

Signed-off-by: Kai Ji <kai.ji@intel.com>
---
 app/wycheproof_validation/main.c | 12 ++++--------
 1 file changed, 4 insertions(+), 8 deletions(-)

diff --git a/app/wycheproof_validation/main.c b/app/wycheproof_validation/main.c
index 9b8182f15b..41ae182803 100644
--- a/app/wycheproof_validation/main.c
+++ b/app/wycheproof_validation/main.c
@@ -12,7 +12,6 @@
 #include <stdio.h>
 #include <stdlib.h>
 #include <string.h>
-#include <sys/stat.h>
 
 #include <jansson.h>
 
@@ -2031,19 +2030,16 @@ process_file(const char *path, struct app_stats *stats)
 static int
 process_path(const char *path, struct app_stats *stats)
 {
-	struct stat path_stat;
 	DIR *directory;
 	struct dirent *entry;
 	int ret = 0;
 
-	if (stat(path, &path_stat) != 0)
-		return -errno;
-	if (!S_ISDIR(path_stat.st_mode))
-		return process_file(path, stats);
-
 	directory = opendir(path);
-	if (directory == NULL)
+	if (directory == NULL) {
+		if (errno == ENOTDIR)
+			return process_file(path, stats);
 		return -errno;
+	}
 	while ((entry = readdir(directory)) != NULL) {
 		char file_path[PATH_MAX];
 		size_t name_length = strlen(entry->d_name);
-- 
2.34.1


^ permalink raw reply related	[flat|nested] only message in thread

only message in thread, other threads:[~2026-11-17 15:49 UTC | newest]

Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-11-17 15:49 [PATCH] app/wycheproof: avoid path check before opening vectors Kai Ji

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox