]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
BUG/MINOR: listener: fix off-by-one in state name check
authorWilly Tarreau <w@1wt.eu>
Wed, 11 Dec 2019 14:51:37 +0000 (15:51 +0100)
committerWilly Tarreau <w@1wt.eu>
Wed, 11 Dec 2019 14:51:37 +0000 (15:51 +0100)
As reported in issue #380, the state check in listener_state_str() is
invalid as it allows state value 9 to report crap. We don't use such
a state value so the issue should never happen unless the memory is
already corrupted, but better clean this now while it's harmless.

This should be backported to all maintained branches.

include/proto/listener.h

index e8f9ece5f44419b6b4a96168e0a5d4fe5a20b762..ca7dc9c7cfd42e0b6dd787f95927824dc5bdd6d5 100644 (file)
@@ -176,7 +176,7 @@ static inline const char *listener_state_str(const struct listener *l)
        };
        unsigned int st = l->state;
 
-       if (st > sizeof(states) / sizeof(*states))
+       if (st >= sizeof(states) / sizeof(*states))
                return "INVALID";
        return states[st];
 }