From: Lukas Krickl Date: Tue, 19 Dec 2023 14:34:30 +0000 (+0100) Subject: Fixed buffer underflow in trimend X-Git-Url: https://git.krickl.dev/?a=commitdiff_plain;h=8afc3a35073be9ea05f997ffe69c7b334116f57c;p=ulas%2F.git Fixed buffer underflow in trimend --- 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';