mirror of
https://github.com/asterisk/asterisk.git
synced 2025-09-03 11:25:35 +00:00
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
This commit is contained in:
@@ -30068,6 +30068,7 @@ static int sip_send_keepalive(const void *data)
|
||||
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 @@ static int sip_send_keepalive(const void *data)
|
||||
|
||||
/* 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 @@ static int sip_send_keepalive(const void *data)
|
||||
}
|
||||
}
|
||||
|
||||
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));
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user