[Asterisk-code-review] http.c: Fix NULL pointer dereference bug (asterisk[20])

Friendly Automation asteriskteam at digium.com
Tue Jan 3 09:55:43 CST 2023


Friendly Automation has submitted this change. ( https://gerrit.asterisk.org/c/asterisk/+/19800 )

Change subject: http.c: Fix NULL pointer dereference bug
......................................................................

http.c: Fix NULL pointer dereference bug

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
---
M main/http.c
1 file changed, 23 insertions(+), 4 deletions(-)

Approvals:
  Sean Bright: Looks good to me, but someone else must approve
  George Joseph: Looks good to me, approved
  Friendly Automation: Approved for Submit




diff --git a/main/http.c b/main/http.c
index 7f1ffe0..80c00c5 100644
--- a/main/http.c
+++ b/main/http.c
@@ -396,10 +396,12 @@
 
 	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));

-- 
To view, visit https://gerrit.asterisk.org/c/asterisk/+/19800
To unsubscribe, or for help writing mail filters, visit https://gerrit.asterisk.org/settings

Gerrit-Project: asterisk
Gerrit-Branch: 20
Gerrit-Change-Id: I11b02fc920b72aaed9c809fc43210523ccfdc249
Gerrit-Change-Number: 19800
Gerrit-PatchSet: 2
Gerrit-Owner: Boris P. Korzun <drtr0jan at yandex.ru>
Gerrit-Reviewer: Friendly Automation
Gerrit-Reviewer: George Joseph <gjoseph at digium.com>
Gerrit-Reviewer: Sean Bright <sean at seanbright.com>
Gerrit-MessageType: merged
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.digium.com/pipermail/asterisk-code-review/attachments/20230103/ff6b41e9/attachment.html>


More information about the asterisk-code-review mailing list