]> git.ipfire.org Git - thirdparty/util-linux.git/commitdiff
include/strutils: fix heap-buffer-overflow in normalize_whitespace()
authorKarel Zak <kzak@redhat.com>
Mon, 14 Jun 2021 14:29:21 +0000 (16:29 +0200)
committerKarel Zak <kzak@redhat.com>
Mon, 14 Jun 2021 14:29:21 +0000 (16:29 +0200)
Signed-off-by: Karel Zak <kzak@redhat.com>
include/strutils.h

index 7969a84d0ccaa357f0fc34aa26e77d134c5ce650..2e5a2aad4cec0620c4d5911fbed985bb58d03b1d 100644 (file)
@@ -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;