From: Karel Zak Date: Mon, 14 Jun 2021 14:29:21 +0000 (+0200) Subject: include/strutils: fix heap-buffer-overflow in normalize_whitespace() X-Git-Tag: v2.37.1~115 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=bef5ab005e6c2ec2f604739b7bc75edea8d02315;p=thirdparty%2Futil-linux.git include/strutils: fix heap-buffer-overflow in normalize_whitespace() Signed-off-by: Karel Zak --- diff --git a/include/strutils.h b/include/strutils.h index 7969a84d0c..2e5a2aad4c 100644 --- a/include/strutils.h +++ b/include/strutils.h @@ -334,7 +334,7 @@ static inline size_t normalize_whitespace(unsigned char *str) else str[x++] = str[i++]; } - if (nsp) /* tailing space */ + if (nsp && x > 0) /* tailing space */ x--; str[x] = '\0'; return x;