← KD100

Fix crash handler buffer truncation warnings

795b27be022a7333c521551d867e7244c39b7c00 · Claude · Jan 22, 2026 06:47

Fixed compiler warnings in DEBUG crash handler code about potential
buffer truncation when constructing command strings.

Changes:
- Increased cmd buffer from 512 to 1536 bytes (line 91)
- Increased gdb_cmd buffer from 512 to 1536 bytes (line 118)

This provides sufficient space for the full exe_path (max 1024 bytes)
plus command text, eliminating truncation warnings while maintaining
safety with -Wformat-truncation checks.

Debug build now compiles cleanly with zero warnings.

+2 −2 · 1 file changed

  • src/main.c +2 −2
diff --git a/src/main.c b/src/main.c
index 513d430..7bf56fe 100644
--- a/src/main.c
+++ b/src/main.c
@@ -88,7 +88,7 @@ void crash_handler(int sig) {
         fprintf(stderr, "  Runtime address: %p\n", array[i]);
         fprintf(stderr, "  File offset:     %p\n", file_offset);
 
-        char cmd[512];
+        char cmd[1536];
         snprintf(cmd, sizeof(cmd), "addr2line -e '%s' -f -C -p %p 2>&1",
                 exe_path, file_offset);
 
@@ -115,7 +115,7 @@ void crash_handler(int sig) {
     }
 
     fprintf(stderr, "\n=== Using gdb to get line info ===\n");
-    char gdb_cmd[512];
+    char gdb_cmd[1536];
     snprintf(gdb_cmd, sizeof(gdb_cmd),
             "gdb -q '%s' -ex 'info line *%p' -ex 'quit' 2>/dev/null | grep -E \"Line|at\"",
             exe_path, array[3]);