Skip to contentSkip to conversation

rt-tests: rt-utils: Fix potential 'debugfileprefix' overflow

PATCH New Ian K. Coolidge 1 participant 1 message Jun 29, 2022

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 rt-tests: rt-utils: Fix potential 'debugfileprefix' overflow

fscanf on line 73 amounts to
fscanf(fp, "... %256s ...", debugfileprefix)

This can result in 256 characters excluding nul.

Add 1 to buffer size to accomodate a maximum write + a nul.

---
 src/lib/rt-utils.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
src/lib/rt-utils.c +1 -1
index 6c0235d..bbc0b82 100644
@@ -32,7 +32,7 @@
 #define  MAX_COMMAND_LINE 4096
 #define  MAX_TS_SIZE 64
 
-static char debugfileprefix[MAX_PATH];
+static char debugfileprefix[MAX_PATH + 1];
 static char *fileprefix;
 static int trace_fd = -1;
 static int tracemark_fd = -1;
Signature · 1 line
2.37.0.rc0.161.g10f37bed90-goog