[Asterisk-code-review] main/stun.c: fix crash upon STUN request timeout (asterisk[19])

Friendly Automation asteriskteam at digium.com
Fri Oct 15 10:00:08 CDT 2021


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

Change subject: main/stun.c: fix crash upon STUN request timeout
......................................................................

main/stun.c: fix crash upon STUN request timeout

Some ast_stun_request users do not provide a destination address when
sending to a connection-mode socket.

ASTERISK-29691

Change-Id: Idd9114c3380216ba48abfc3c68619e79ad37defc
---
M main/stun.c
1 file changed, 11 insertions(+), 4 deletions(-)

Approvals:
  Joshua Colp: 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/stun.c b/main/stun.c
index 4e9dac1..7a8e0e5 100644
--- a/main/stun.c
+++ b/main/stun.c
@@ -239,17 +239,24 @@
 
 static void handle_stun_timeout(int retry, struct sockaddr_in *dst)
 {
+	char *stun_destination = "";
+	if (dst) {
+		ast_asprintf(&stun_destination, "to '%s' ", ast_inet_ntoa(dst->sin_addr));
+	}
 	if (retry < STUN_MAX_RETRIES) {
 		ast_log(LOG_NOTICE,
-			"Attempt %d to send STUN request to '%s' timed out.",
+			"Attempt %d to send STUN request %stimed out.\n",
 			retry,
-			ast_inet_ntoa(dst->sin_addr));
+			stun_destination);
 	} else {
 		ast_log(LOG_WARNING,
-			"Attempt %d to send STUN request to '%s' timed out."
+			"Attempt %d to send STUN request %stimed out. "
 			"Check that the server address is correct and reachable.\n",
 			retry,
-			ast_inet_ntoa(dst->sin_addr));
+			stun_destination);
+	}
+	if (dst) {
+		ast_free(stun_destination);
 	}
 }
 

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

Gerrit-Project: asterisk
Gerrit-Branch: 19
Gerrit-Change-Id: Idd9114c3380216ba48abfc3c68619e79ad37defc
Gerrit-Change-Number: 16610
Gerrit-PatchSet: 2
Gerrit-Owner: Sébastien Duthil <sduthil at wazo.community>
Gerrit-Reviewer: Friendly Automation
Gerrit-Reviewer: George Joseph <gjoseph at digium.com>
Gerrit-Reviewer: Joshua Colp <jcolp at sangoma.com>
Gerrit-MessageType: merged
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.digium.com/pipermail/asterisk-code-review/attachments/20211015/9e5b5d38/attachment.html>


More information about the asterisk-code-review mailing list