From 8afc3a35073be9ea05f997ffe69c7b334116f57c Mon Sep 17 00:00:00 2001 From: Lukas Krickl Date: Tue, 19 Dec 2023 15:34:30 +0100 Subject: [PATCH] Fixed buffer underflow in trimend --- src/ulas.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/ulas.c b/src/ulas.c index d69f2e4..f516a27 100644 --- a/src/ulas.c +++ b/src/ulas.c @@ -682,6 +682,9 @@ int ulas_preproclws(struct ulas_preproc *pp, const char *praw_line, void ulas_trimend(char c, char *buf, unsigned long n) { unsigned long buflen = strnlen(buf, n); + if (buflen == 0) { + return; + } // remove trailing new line if present while (buf[buflen - 1] == '\n') { buf[buflen - 1] = '\0'; -- 2.30.2