Commit 2ba5e2c66007d66c40b37af63e76d6fe1596a6a3

Martin Mitas 2024-01-17T14:48:57

Make --replay-fuzz friendlier to work with in debugger. We make effectively input zero-terminated so debugger doesn't attempt to write more than what's really provided.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
diff --git a/md2html/md2html.c b/md2html/md2html.c
index 39d3501..9376300 100644
--- a/md2html/md2html.c
+++ b/md2html/md2html.c
@@ -160,6 +160,10 @@ process_file(const char* in_path, FILE* in, FILE* out)
         memmove(buf_in.data, buf_in.data + 2 * sizeof(unsigned),
                     buf_in.size - 2 * sizeof(unsigned));
         buf_in.size -= 2 * sizeof(unsigned);
+
+        /* Zero the tail we have moved the contents from.
+         * It helps in debugging if make it actually a zero-terminated string. */
+        memset(buf_in.data + buf_in.size, 0, 2 * sizeof(unsigned));
     }
 
     /* Parse the document. This shall call our callbacks provided via the