]> git.ipfire.org Git - thirdparty/asterisk.git/commitdiff
http.c: Fix NULL pointer dereference bug
authorBoris P. Korzun <drtr0jan@yandex.ru>
Wed, 28 Dec 2022 19:33:42 +0000 (22:33 +0300)
committerFriendly Automation <jenkins2@gerrit.asterisk.org>
Wed, 4 Jan 2023 17:56:21 +0000 (11:56 -0600)
If native HTTP is disabled but HTTPS is enabled and status page enabled
too, Core/HTTP crashes while loading. 'global_http_server' references
to NULL, but the status page tries to dereference it.

The patch adds a check for HTTP is enabled.

ASTERISK-30379 #close

Change-Id: I11b02fc920b72aaed9c809fc43210523ccfdc249

main/http.c

index 7f1ffe0c570eb5c38ff9e4f892956be6dacc8b8f..80c00c52a103984dceb9ae48330229c133e23b31 100644 (file)
@@ -396,10 +396,12 @@ static int httpstatus_callback(struct ast_tcptls_session_instance *ser,
 
        ast_str_append(&out, 0, "<tr><td><i>Server</i></td><td><b>%s</b></td></tr>\r\n", http_server_name);
        ast_str_append(&out, 0, "<tr><td><i>Prefix</i></td><td><b>%s</b></td></tr>\r\n", prefix);
-       ast_str_append(&out, 0, "<tr><td><i>Bind Address</i></td><td><b>%s</b></td></tr>\r\n",
-                      ast_sockaddr_stringify_addr(&global_http_server->args.old_address));
-       ast_str_append(&out, 0, "<tr><td><i>Bind Port</i></td><td><b>%s</b></td></tr>\r\n",
-                      ast_sockaddr_stringify_port(&global_http_server->args.old_address));
+       if (global_http_server) {
+               ast_str_append(&out, 0, "<tr><td><i>Bind Address</i></td><td><b>%s</b></td></tr>\r\n",
+                              ast_sockaddr_stringify_addr(&global_http_server->args.old_address));
+               ast_str_append(&out, 0, "<tr><td><i>Bind Port</i></td><td><b>%s</b></td></tr>\r\n",
+                              ast_sockaddr_stringify_port(&global_http_server->args.old_address));
+       }
        if (http_tls_cfg.enabled) {
                ast_str_append(&out, 0, "<tr><td><i>SSL Bind Port</i></td><td><b>%s</b></td></tr>\r\n",
                               ast_sockaddr_stringify_port(&https_desc.old_address));