]> git.ipfire.org Git - thirdparty/libbsd.git/commitdiff
Do not confuse code analyzers with out-of-bounds array access look alike
authorGuillem Jover <guillem@hadrons.org>
Tue, 14 Nov 2023 18:09:25 +0000 (19:09 +0100)
committerGuillem Jover <guillem@hadrons.org>
Sun, 7 Jan 2024 15:45:42 +0000 (16:45 +0100)
The code is only getting the address, but we might be performing an
addressing that is out-of-bounds. Avoid it and use the address form
instead.

Warned-by: cppcheck (objectIndex)
src/setproctitle.c

index 3aff0649ca2f691b7833b00242463dcb16eaaeb2..d77d67f3b696b6c23d435d87ed5a4c68b791d9fa 100644 (file)
@@ -284,7 +284,7 @@ setproctitle_impl(const char *fmt, ...)
 
        if (nul < SPT.nul) {
                *SPT.nul = '.';
-       } else if (nul == SPT.nul && &nul[1] < SPT.end) {
+       } else if (nul == SPT.nul && (nul + 1) < SPT.end) {
                *SPT.nul = ' ';
                *++nul = '\0';
        }