aboutsummaryrefslogtreecommitdiffstats
path: root/channels
diff options
context:
space:
mode:
authorrizzo <rizzo@f38db490-d61c-443f-a65b-d21fe96a405b>2006-10-23 21:46:15 +0000
committerrizzo <rizzo@f38db490-d61c-443f-a65b-d21fe96a405b>2006-10-23 21:46:15 +0000
commitebf91ac473d8dadfb0f8c3e74f68765f3c550f5c (patch)
tree3e7f028320399ca51eeac06f09947a664abec237 /channels
parentccd427b13eac68878d4a1f87e6fbb66db23c957b (diff)
Unlike ast_strdup(), ast_strdupa() does not take a NULL pointer as argument,
so fix the places where this might happen. This is also a fix that ought to go into 1.4 [The difference between the two functions is a bit confusing, and in asterisk i believe all string handling functions should be able to handl a NULL string as argument, but changing the API in trunk and not in 1.4 would make backporting harder.] git-svn-id: http://svn.digium.com/svn/asterisk/trunk@46045 f38db490-d61c-443f-a65b-d21fe96a405b
Diffstat (limited to 'channels')
-rw-r--r--channels/chan_sip.c13
1 files changed, 8 insertions, 5 deletions
diff --git a/channels/chan_sip.c b/channels/chan_sip.c
index 549e73f1e..d888fa19a 100644
--- a/channels/chan_sip.c
+++ b/channels/chan_sip.c
@@ -1304,7 +1304,6 @@ static struct sip_auth *find_realm_authentication(struct sip_auth *authlist, con
static int sip_do_reload(enum channelreloadreason reason);
static int reload_config(enum channelreloadreason reason);
static int expire_register(void *data);
-static int sip_sipredirect(struct sip_pvt *p, const char *dest);
static void *do_monitor(void *data);
static int restart_monitor(void);
static int sip_send_mwi_to_peer(struct sip_peer *peer);
@@ -1649,12 +1648,13 @@ static int find_sip_method(const char *msg)
static unsigned int parse_sip_options(struct sip_pvt *pvt, const char *supported)
{
char *next, *sep;
- char *temp = ast_strdupa(supported);
+ char *temp;
unsigned int profile = 0;
int i, found;
if (ast_strlen_zero(supported) )
return 0;
+ temp = ast_strdupa(supported);
if (option_debug > 2 && sipdebug)
ast_log(LOG_DEBUG, "Begin: parsing SIP \"Supported: %s\"\n", supported);
@@ -3650,6 +3650,8 @@ static int sip_transfer(struct ast_channel *ast, const char *dest)
struct sip_pvt *p = ast->tech_pvt;
int res;
+ if (dest == NULL) /* functions below do not take a NULL */
+ dest = "";
sip_pvt_lock(p);
if (ast->_state == AST_STATE_RING)
res = sip_sipredirect(p, dest);
@@ -15036,7 +15038,8 @@ static int sip_devicestate(void *data)
int res = AST_DEVICE_INVALID;
- host = ast_strdupa(data);
+ /* make sure data is not null. Maybe unnecessary, but better be safe */
+ host = ast_strdupa(data ? data : "");
if ((tmp = strchr(host, '@')))
host = tmp + 1;
@@ -16782,13 +16785,13 @@ static int sip_sipredirect(struct sip_pvt *p, const char *dest)
char *cdest;
char *extension, *host, *port;
char tmp[80];
-
+
cdest = ast_strdupa(dest);
extension = strsep(&cdest, "@");
host = strsep(&cdest, ":");
port = strsep(&cdest, ":");
- if (!extension) {
+ if (ast_strlen_zero(extension)) {
ast_log(LOG_ERROR, "Missing mandatory argument: extension\n");
return 0;
}