read_all: Fix buffer too small for long paths
PATCH v2 1/1 read_all: Fix buffer too small for long paths
queue_pop() copies each path into popped[BUFFER_SIZE], but BUFFER_SIZE was 1024 while visit_dir() builds paths up to MAX_PATH (4096). Any path longer than 1023 bytes aborted the test with TBROK "Buffer is too small for path".
Set BUFFER_SIZE and MAX_PATH to PATH_MAX so all path buffers and size limits use the standard constant consistently.
Tested on smaller boards and then on local machines with deeply nested directories under /sys; read_all_sys now passes instead of aborting.
--- testcases/kernel/fs/read_all/read_all.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
testcases/kernel/fs/read_all/read_all.c +2 -2
@@ -51,8 +51,8 @@#include "tst_timer.h" #define QUEUE_SIZE 16384 -#define BUFFER_SIZE 1024 -#define MAX_PATH 4096 +#define BUFFER_SIZE PATH_MAX +#define MAX_PATH PATH_MAX#define MAX_DISPLAY 40struct queue {
Signature · 5 lines
2.55.0 -- Mailing list info: https://lists.linux.it/listinfo/ltp
Hi Michael,
Quoted 3 lines · Michael Menasherov
read_all: Fix buffer too small for long paths+#define
BUFFER_SIZEPATH_MAX
With the existing if (++j >= BUFFER_SIZE - 1) check, this still rejects a valid PATH_MAX - 1-character pathname and reports TBROK before writing its terminating NUL. A 4095-byte pathname reproduces this on PATH_MAX=4096; change the queue_pop() bound so PATH_MAX - 1 characters fit.
Verdict - Needs revision
---
Note:
The agent can sometimes produce false positives although often its findings are genuine. If you find issues with the review, please comment this email or ignore the suggestions.
Regards,
LTP AI Reviewer
Signature · 1 line
Mailing list info: https://lists.linux.it/listinfo/ltp