From 3c8feee4d92e89a9e8ae19f1100fdc1dbad80b3f Mon Sep 17 00:00:00 2001 From: Chris Sarbora Date: Tue, 5 Dec 2023 14:59:29 -0800 Subject: [PATCH] Fix `#define` parsing bug Commit eb41365233c19537e2d2971cab0007780abfabaf introduced a bug in `#define` parsing wherein a null terminator would be written into the parse input stream after the expanded definition. The intention of the buggy commit was to eliminate a (wise) warning about using the source length as the buffer length in a `strncpy` operation; using memcpy here is probably the more-correct solution as we already know all the lengths involved. --- lex.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lex.c b/lex.c index b790efa..7449112 100644 --- a/lex.c +++ b/lex.c @@ -1909,7 +1909,7 @@ add_input(char *p) } outp -= l; nbuf += l; - strcpy(outp, p); + memcpy(outp, p, l); } #define DEFHASH 1999