]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
BUG/MINOR: listener: add an error check for unallocatable trash
authorWilly Tarreau <w@1wt.eu>
Sat, 16 Oct 2021 12:54:19 +0000 (14:54 +0200)
committerWilly Tarreau <w@1wt.eu>
Sat, 16 Oct 2021 12:54:19 +0000 (14:54 +0200)
Coverity noticed in issue #1416 that a missing allocation error was
introduced in tcp_bind_listener() with the rework of error messages by
commit ed1748553 ("MINOR: proto_tcp: use chunk_appendf() to ouput socket
setup errors"). In practice nobody will ever face it but better address
it anyway.

No backport is needed.

src/proto_tcp.c

index 18e9b80e492d04cf6057cd504055709044046d2e..a8b15b21adaf29651ce65aa61c4de018f98f1496 100644 (file)
@@ -589,6 +589,12 @@ int tcp_bind_listener(struct listener *listener, char *errmsg, int errlen)
 
        err = ERR_NONE;
 
+       if (!msg) {
+               if (errlen)
+                       snprintf(errmsg, errlen, "out of memory");
+               return ERR_ALERT | ERR_FATAL;
+       }
+
        /* ensure we never return garbage */
        if (errlen)
                *errmsg = 0;