mirror of
https://github.com/asterisk/asterisk.git
synced 2025-11-17 15:29:05 +00:00
Resolve FORWARD_NULL static analysis warnings
This resolves core findings from ASTERISK-19650 numbers 0-2, 6, 7, 9-11, 14-20, 22-24, 28, 30-32, 34-36, 42-56, 82-84, 87, 89-90, 93-102, 104, 105, 109-111, and 115. Finding numbers 26, 33, and 29 were already resolved. Those skipped were either extended/deprecated or in areas of code that shouldn't be disturbed. (Closes issue ASTERISK-19650) ........ Merged revisions 366167 from http://svn.asterisk.org/svn/asterisk/branches/1.8 ........ Merged revisions 366168 from http://svn.asterisk.org/svn/asterisk/branches/10 git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@366169 65c4cc65-6c06-0410-ace0-fbb531ad65f3
This commit is contained in:
@@ -3188,7 +3188,7 @@ static int method_match(enum sipmethod id, const char *name)
|
||||
int len = strlen(sip_methods[id].text);
|
||||
int l_name = name ? strlen(name) : 0;
|
||||
/* true if the string is long enough, and ends with whitespace, and matches */
|
||||
return (l_name >= len && name[len] < 33 &&
|
||||
return (l_name >= len && name && name[len] < 33 &&
|
||||
!strncasecmp(sip_methods[id].text, name, len));
|
||||
}
|
||||
|
||||
@@ -3492,7 +3492,7 @@ static void ast_sip_ouraddrfor(const struct ast_sockaddr *them, struct ast_socka
|
||||
}
|
||||
ast_debug(1, "Target address %s is not local, substituting externaddr\n",
|
||||
ast_sockaddr_stringify(them));
|
||||
} else if (p) {
|
||||
} else {
|
||||
/* no remapping, but we bind to a specific address, so use it. */
|
||||
switch (p->socket.type) {
|
||||
case SIP_TRANSPORT_TCP:
|
||||
@@ -3523,8 +3523,6 @@ static void ast_sip_ouraddrfor(const struct ast_sockaddr *them, struct ast_socka
|
||||
ast_sockaddr_set_port(us, ast_sockaddr_port(&bindaddr));
|
||||
}
|
||||
}
|
||||
} else if (!ast_sockaddr_is_any(&bindaddr)) {
|
||||
ast_sockaddr_copy(us, &bindaddr);
|
||||
}
|
||||
ast_debug(3, "Setting SIP_TRANSPORT_%s with address %s\n", sip_get_transport(p->socket.type), ast_sockaddr_stringify(us));
|
||||
}
|
||||
@@ -3667,7 +3665,7 @@ static int retrans_pkt(const void *data)
|
||||
|
||||
pkt->retransid = -1; /* Kill this scheduler item */
|
||||
|
||||
if (pkt->owner && pkt->method != SIP_OPTIONS && xmitres == 0) {
|
||||
if (pkt->method != SIP_OPTIONS && xmitres == 0) {
|
||||
if (pkt->is_fatal || sipdebug) { /* Tell us if it's critical or if we're debugging */
|
||||
ast_log(LOG_WARNING, "Retransmission timeout reached on transmission %s for seqno %u (%s %s) -- See https://wiki.asterisk.org/wiki/display/AST/SIP+Retransmissions\n"
|
||||
"Packet timed out after %dms with no response\n",
|
||||
@@ -7224,6 +7222,8 @@ static struct ast_channel *sip_new(struct sip_pvt *i, int state, const char *tit
|
||||
if (i->rtp) {
|
||||
ast_channel_set_fd(tmp, 0, ast_rtp_instance_fd(i->rtp, 0));
|
||||
ast_channel_set_fd(tmp, 1, ast_rtp_instance_fd(i->rtp, 1));
|
||||
ast_rtp_instance_set_write_format(i->rtp, &fmt);
|
||||
ast_rtp_instance_set_read_format(i->rtp, &fmt);
|
||||
}
|
||||
if (needvideo && i->vrtp) {
|
||||
ast_channel_set_fd(tmp, 2, ast_rtp_instance_fd(i->vrtp, 0));
|
||||
@@ -7243,11 +7243,9 @@ static struct ast_channel *sip_new(struct sip_pvt *i, int state, const char *tit
|
||||
|
||||
ast_format_copy(ast_channel_writeformat(tmp), &fmt);
|
||||
ast_format_copy(ast_channel_rawwriteformat(tmp), &fmt);
|
||||
ast_rtp_instance_set_write_format(i->rtp, &fmt);
|
||||
|
||||
ast_format_copy(ast_channel_readformat(tmp), &fmt);
|
||||
ast_format_copy(ast_channel_rawreadformat(tmp), &fmt);
|
||||
ast_rtp_instance_set_read_format(i->rtp, &fmt);
|
||||
|
||||
ast_channel_tech_pvt_set(tmp, dialog_ref(i, "sip_new: set chan->tech_pvt to i"));
|
||||
|
||||
@@ -8511,7 +8509,7 @@ static int sip_subscribe_mwi(const char *value, int lineno)
|
||||
int portnum = 0;
|
||||
enum sip_transport transport = SIP_TRANSPORT_UDP;
|
||||
char buf[256] = "";
|
||||
char *username = NULL, *hostname = NULL, *secret = NULL, *authuser = NULL, *porta = NULL, *mailbox = NULL, *at = NULL;
|
||||
char *username = NULL, *hostname = NULL, *secret = NULL, *authuser = NULL, *porta = NULL, *mailbox = NULL;
|
||||
|
||||
if (!value) {
|
||||
return -1;
|
||||
@@ -8519,13 +8517,12 @@ static int sip_subscribe_mwi(const char *value, int lineno)
|
||||
|
||||
ast_copy_string(buf, value, sizeof(buf));
|
||||
|
||||
if (!(at = strstr(buf, "@"))) {
|
||||
return -1;
|
||||
}
|
||||
username = buf;
|
||||
|
||||
if ((hostname = strrchr(buf, '@'))) {
|
||||
*hostname++ = '\0';
|
||||
username = buf;
|
||||
} else {
|
||||
return -1;
|
||||
}
|
||||
|
||||
if ((secret = strchr(username, ':'))) {
|
||||
@@ -27283,8 +27280,12 @@ enum st_refresher st_get_refresher(struct sip_pvt *p)
|
||||
*/
|
||||
enum st_mode st_get_mode(struct sip_pvt *p, int no_cached)
|
||||
{
|
||||
if (!p->stimer)
|
||||
if (!p->stimer) {
|
||||
sip_st_alloc(p);
|
||||
if (!p->stimer) {
|
||||
return SESSION_TIMER_MODE_INVALID;
|
||||
}
|
||||
}
|
||||
|
||||
if (!no_cached && p->stimer->st_cached_mode != SESSION_TIMER_MODE_INVALID)
|
||||
return p->stimer->st_cached_mode;
|
||||
|
||||
Reference in New Issue
Block a user