]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
BUG/MINOR: ssl/cli: check trash allocation in cli_io_handler_commit_cert()
authorWilliam Lallemand <wlallemand@haproxy.com>
Thu, 31 Oct 2019 10:43:45 +0000 (11:43 +0100)
committerWilliam Lallemand <wlallemand@haproxy.org>
Thu, 31 Oct 2019 10:48:01 +0000 (11:48 +0100)
Possible NULL pointer dereference found by coverity.

Fix #350 #340.

src/ssl_sock.c

index 0e4244dc99a8e128d901d2bdb8d10cd2ac2b0053..772310b78ec92c81492a0c39db4022cb3ec05037 100644 (file)
@@ -10016,6 +10016,9 @@ static int cli_io_handler_commit_cert(struct appctx *appctx)
        struct ckch_inst *ckchi, *ckchis;
        struct buffer *trash = alloc_trash_chunk();
 
+       if (trash == NULL)
+               goto error;
+
        if (unlikely(si_ic(si)->flags & (CF_WRITE_ERROR|CF_SHUTW)))
                goto error;
 
@@ -10142,10 +10145,12 @@ yield:
 
 error:
        /* spin unlock and free are done in the release  function */
-       chunk_appendf(trash, "\n%sFailed!\n", err);
-       if (ci_putchk(si_ic(si), trash) == -1)
-               si_rx_room_blk(si);
-       free_trash_chunk(trash);
+       if (trash) {
+               chunk_appendf(trash, "\n%sFailed!\n", err);
+               if (ci_putchk(si_ic(si), trash) == -1)
+                       si_rx_room_blk(si);
+               free_trash_chunk(trash);
+       }
        /* error: call the release function and don't come back */
        return 1;
 }