Index: channels/chan_sip.c =================================================================== --- channels/chan_sip.c (revision 417058) +++ channels/chan_sip.c (working copy) @@ -16038,7 +16038,8 @@ static enum sip_get_dest_result get_destination(struct sip_pvt *p, struct sip_request *oreq, int *cc_recall_core_id) { char tmp[256] = "", *uri, *unused_password, *domain; - char tmpf[256] = "", *from = NULL; + RAII_VAR(char *, tmpf, NULL, ast_free); + char *from = NULL; struct sip_request *req; char *decoded_uri; @@ -16078,7 +16079,7 @@ /* XXX Why is this done in get_destination? Isn't it already done? Needs to be checked */ - ast_copy_string(tmpf, get_header(req, "From"), sizeof(tmpf)); + tmpf = ast_strdup(get_header(req, "From")); if (!ast_strlen_zero(tmpf)) { from = get_in_brackets(tmpf); if (parse_uri_legacy_check(from, "sip:,sips:", &from, NULL, &domain, NULL)) { @@ -16862,21 +16863,23 @@ int sipmethod, const char *uri, enum xmittype reliable, struct ast_sockaddr *addr, struct sip_peer **authpeer) { - char from[256], *of, *name, *unused_password, *domain; + char *tmp, *of, *name, *unused_password, *domain; enum check_auth_result res = AUTH_DONT_KNOW; char calleridname[256]; char *uri2 = ast_strdupa(uri); terminate_uri(uri2); /* trim extra stuff */ - ast_copy_string(from, get_header(req, "From"), sizeof(from)); + tmp = ast_strdup(get_header(req, "From")); /* XXX here tries to map the username for invite things */ /* strip the display-name portion off the beginning of the FROM header. */ - if (!(of = (char *) get_calleridname(from, calleridname, sizeof(calleridname)))) { + if (!(of = (char *) get_calleridname(tmp, calleridname, sizeof(calleridname)))) { ast_log(LOG_ERROR, "FROM header can not be parsed \n"); + ast_free(tmp); return res; } + ast_free(tmp); if (calleridname[0]) { ast_string_field_set(p, cid_name, calleridname); @@ -16924,7 +16927,7 @@ name = domain; } else { /* Non-empty name, try to get caller id from it */ - char *tmp = ast_strdupa(name); + tmp = ast_strdupa(name); /* We need to be able to handle from-headers looking like */ @@ -16935,6 +16938,8 @@ ast_string_field_set(p, cid_num, tmp); } + tmp = NULL; + if (global_match_auth_username) { /* * XXX This is experimental code to grab the search key from the @@ -16950,14 +16955,15 @@ } if (!ast_strlen_zero(hdr) && (hdr = strstr(hdr, "username=\""))) { - ast_copy_string(from, hdr + strlen("username=\""), sizeof(from)); - name = from; + tmp = name = ast_strdup(hdr + strlen("username=\"")); name = strsep(&name, "\""); } } res = check_peer_ok(p, name, req, sipmethod, addr, authpeer, reliable, calleridname, uri2); + ast_free(tmp); + if (res != AUTH_DONT_KNOW) { return res; }