]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
MINOR: ssl: Remove unnecessary alloc'ed trash chunk in show ocsp-response
authorRemi Tricot-Le Breton <rlebreton@haproxy.com>
Thu, 15 Dec 2022 14:44:36 +0000 (15:44 +0100)
committerWilliam Lallemand <wlallemand@haproxy.org>
Thu, 15 Dec 2022 15:33:36 +0000 (16:33 +0100)
When displaying the content of an OCSP response in the CLI, a buffer is
alloc'ed when a temporary buffer would be enough.

src/ssl_sock.c

index 9c08c6011575c42e87577059f018f53842eebfa2..65d0c857dc4d3d14767e235892c9eb4e60e285a0 100644 (file)
@@ -7921,30 +7921,18 @@ int ssl_get_ocspresponse_detail(unsigned char *ocsp_certid, struct buffer *out)
  */
 static int cli_io_handler_show_ocspresponse_detail(struct appctx *appctx)
 {
-       struct buffer *trash = alloc_trash_chunk();
+       struct buffer *trash = get_trash_chunk();
        struct certificate_ocsp *ocsp = appctx->svcctx;
 
-       if (trash == NULL)
-               return 1;
-
-       if (ssl_ocsp_response_print(&ocsp->response, trash)) {
-               free_trash_chunk(trash);
-               return 1;
-       }
+       if (ssl_ocsp_response_print(&ocsp->response, trash))
+               goto end;
 
        if (applet_putchk(appctx, trash) == -1)
-               goto yield;
+               return 0;
 
+end:
        appctx->svcctx = NULL;
-       if (trash)
-               free_trash_chunk(trash);
        return 1;
-
-yield:
-       if (trash)
-               free_trash_chunk(trash);
-
-       return 0;
 }
 #endif