[Asterisk-code-review] chan sip: Don't send trailing \0 on keep alive packets (asterisk[13])

Jenkins2 asteriskteam at digium.com
Wed Dec 13 06:56:36 CST 2017


Jenkins2 has submitted this change and it was merged. ( https://gerrit.asterisk.org/7537 )

Change subject: chan_sip: Don't send trailing \0 on keep alive packets
......................................................................

chan_sip: Don't send trailing \0 on keep alive packets

This is a partial fix for ASTERISK~25817 but does not address the
comments regarding RFC 5626.

Change-Id: I227e2d10c0035bbfa1c6e46ae2318fd1122d8420
---
M channels/chan_sip.c
1 file changed, 5 insertions(+), 4 deletions(-)

Approvals:
  Benjamin Keith Ford: Looks good to me, but someone else must approve
  Corey Farrell: Looks good to me, but someone else must approve
  Joshua Colp: Looks good to me, approved
  Jenkins2: Approved for Submit



diff --git a/channels/chan_sip.c b/channels/chan_sip.c
index b8cc7bf..6432728 100644
--- a/channels/chan_sip.c
+++ b/channels/chan_sip.c
@@ -30068,6 +30068,7 @@
 	struct sip_peer *peer = (struct sip_peer*) data;
 	int res = 0;
 	const char keepalive[] = "\r\n";
+	size_t count = sizeof(keepalive) - 1;
 
 	peer->keepalivesend = -1;
 
@@ -30078,13 +30079,13 @@
 
 	/* Send the packet out using the proper method for this peer */
 	if ((peer->socket.fd != -1) && (peer->socket.type == AST_TRANSPORT_UDP)) {
-		res = ast_sendto(peer->socket.fd, keepalive, sizeof(keepalive), 0, &peer->addr);
+		res = ast_sendto(peer->socket.fd, keepalive, count, 0, &peer->addr);
 	} else if ((peer->socket.type & (AST_TRANSPORT_TCP | AST_TRANSPORT_TLS)) &&
 		   (peer->socket.tcptls_session) &&
 		   (peer->socket.tcptls_session->fd != -1)) {
-		res = sip_tcptls_write(peer->socket.tcptls_session, keepalive, sizeof(keepalive));
+		res = sip_tcptls_write(peer->socket.tcptls_session, keepalive, count);
 	} else if (peer->socket.type == AST_TRANSPORT_UDP) {
-		res = ast_sendto(sipsock, keepalive, sizeof(keepalive), 0, &peer->addr);
+		res = ast_sendto(sipsock, keepalive, count, 0, &peer->addr);
 	}
 
 	if (res == -1) {
@@ -30098,7 +30099,7 @@
 		}
 	}
 
-	if (res != sizeof(keepalive)) {
+	if (res != count) {
 		ast_log(LOG_WARNING, "sip_send_keepalive to %s returned %d: %s\n", ast_sockaddr_stringify(&peer->addr), res, strerror(errno));
 	}
 

-- 
To view, visit https://gerrit.asterisk.org/7537
To unsubscribe, visit https://gerrit.asterisk.org/settings

Gerrit-Project: asterisk
Gerrit-Branch: 13
Gerrit-MessageType: merged
Gerrit-Change-Id: I227e2d10c0035bbfa1c6e46ae2318fd1122d8420
Gerrit-Change-Number: 7537
Gerrit-PatchSet: 2
Gerrit-Owner: Sean Bright <sean.bright at gmail.com>
Gerrit-Reviewer: Benjamin Keith Ford <bford at digium.com>
Gerrit-Reviewer: Corey Farrell <git at cfware.com>
Gerrit-Reviewer: Jenkins2
Gerrit-Reviewer: Joshua Colp <jcolp at digium.com>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.digium.com/pipermail/asterisk-code-review/attachments/20171213/9347831e/attachment.html>


More information about the asterisk-code-review mailing list