]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
BUILD/MINOR: peers: remove an impossible null test in intencode()
authorWilly Tarreau <w@1wt.eu>
Tue, 12 Feb 2019 10:59:35 +0000 (11:59 +0100)
committerWilly Tarreau <w@1wt.eu>
Tue, 12 Feb 2019 10:59:35 +0000 (11:59 +0100)
intencode() tests for the nullity of the target pointer passed in
argument, but the code calling intencode() never does so and happily
dereferences it. gcc at -O3 detects this as a potential null deref.
Let's remove this incorrect and misleading test. If this pointer was
null, the code would already crash in the calling functions.

This must be backported to stable versions.

src/peers.c

index 30cf94277d9001caea5993c92b19f12dc216e2e1..dc5bdeaf8d14bb1018e27cfb488581935e02fe3a 100644 (file)
@@ -213,9 +213,6 @@ int intencode(uint64_t i, char **str) {
        int idx = 0;
        unsigned char *msg;
 
-       if (!*str)
-               return 0;
-
        msg = (unsigned char *)*str;
        if (i < 240) {
                msg[0] = (unsigned char)i;