DPDK-dev Archive on lore.kernel.org
 help / color / mirror / Atom feed
From: Kai Ji <kai.ji@intel.com>
To: dev@dpdk.org
Cc: Kai Ji <kai.ji@intel.com>
Subject: [PATCH] app/wycheproof: avoid path check before opening vectors
Date: Tue, 17 Nov 2026 15:49:49 +0000	[thread overview]
Message-ID: <20261117154949.4153145-1-kai.ji@intel.com> (raw)

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


                 reply	other threads:[~2026-11-17 15:49 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20261117154949.4153145-1-kai.ji@intel.com \
    --to=kai.ji@intel.com \
    --cc=dev@dpdk.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox