[svn-commits] simon.perreault: branch group/v6 r84632 - /team/group/v6/trunk/channels/
SVN commits to the Digium repositories
svn-commits at lists.digium.com
Thu Oct 4 07:50:40 CDT 2007
Author: simon.perreault
Date: Thu Oct 4 07:50:40 2007
New Revision: 84632
URL: http://svn.digium.com/view/asterisk?view=rev&rev=84632
Log:
Trying to make name lookup errors more recognizable. Also fixes reading off the end of the
buffer in case of an error.
Modified:
team/group/v6/trunk/channels/chan_sip.c
Modified: team/group/v6/trunk/channels/chan_sip.c
URL: http://svn.digium.com/view/asterisk/team/group/v6/trunk/channels/chan_sip.c?view=diff&rev=84632&r1=84631&r2=84632
==============================================================================
--- team/group/v6/trunk/channels/chan_sip.c (original)
+++ team/group/v6/trunk/channels/chan_sip.c Thu Oct 4 07:50:40 2007
@@ -2146,7 +2146,7 @@
static int __sip_xmit(struct sip_pvt *p, char *data, int len)
{
int res;
- char hostport[NI_MAXHOST];
+ char hostport[NI_MAXHOST] = "<error>";
socklen_t dstlen = 0;
int sockfd = 0;
const struct sockaddr *dst = sip_real_dst(p, &dstlen);
@@ -2177,7 +2177,7 @@
/*! \brief Build a Via header for a request */
static void build_via(struct sip_pvt *p)
{
- char hostport[NI_MAXHOST];
+ char hostport[NI_MAXHOST] = "<error>";
/* Work around buggy UNIDEN UIP200 firmware */
const char *rport = ast_test_flag(&p->flags[0], SIP_NAT) & SIP_NAT_RFC3581 ? ";rport" : "";
@@ -2200,8 +2200,8 @@
{
struct ast_vinetsock* ns = NULL;
int portno = 0;
- char iabuf[NI_MAXHOST];
- char sbuf[NI_MAXSERV];
+ char iabuf[NI_MAXHOST] = "<error>";
+ char sbuf[NI_MAXSERV] = "<error>";
/* Sanity check */
if (!them || !them_len)
@@ -2293,7 +2293,7 @@
struct sip_pkt *pkt = (struct sip_pkt *)data, *prev, *cur = NULL;
int reschedule = DEFAULT_RETRANS;
int xmitres = 0;
- char hostport[NI_MAXHOST];
+ char hostport[NI_MAXHOST] = "<error>";
/* Lock channel PVT */
sip_pvt_lock(pkt->owner);
@@ -2639,7 +2639,7 @@
static int send_response(struct sip_pvt *p, struct sip_request *req, enum xmittype reliable, int seqno)
{
int res;
- char hostport[NI_MAXHOST];
+ char hostport[NI_MAXHOST] = "<error>";
add_blank(req);
if (sip_debug_test_pvt(p)) {
@@ -2669,7 +2669,7 @@
static int send_request(struct sip_pvt *p, struct sip_request *req, enum xmittype reliable, int seqno)
{
int res;
- char hostport[NI_MAXHOST];
+ char hostport[NI_MAXHOST] = "<error>";
/* If we have an outbound proxy, reset peer address
Only do this once.
@@ -2895,8 +2895,8 @@
socklen_t sa_len, const char *username,
const char *fullcontact, int expirey)
{
- char port[NI_MAXSERV];
- char ipaddr[NI_MAXHOST];
+ char port[NI_MAXSERV] = "<error>";
+ char ipaddr[NI_MAXHOST] = "<error>";
char regseconds[20];
char *tablename = NULL;
@@ -3077,9 +3077,9 @@
struct ast_variable *var = NULL;
struct ast_variable *varregs = NULL;
struct ast_variable *tmp;
- char ipaddr[NI_MAXHOST];
+ char ipaddr[NI_MAXHOST] = "<error>";
struct ast_config *peerlist = NULL;
- char portstring[NI_MAXSERV];
+ char portstring[NI_MAXSERV] = "<error>";
char *cat = NULL;
unsigned short portnum;
int realtimeregs = ast_check_realtime("sipregs");
@@ -3353,7 +3353,7 @@
*/
static int create_addr_from_peer(struct sip_pvt *dialog, struct sip_peer *peer)
{
- char iabuf[NI_MAXHOST];
+ char iabuf[NI_MAXHOST] = "<error>";
if(!peer)
return -1;
@@ -4937,7 +4937,7 @@
/*! \brief Build SIP Call-ID value for a non-REGISTER transaction */
static void build_callid_pvt(struct sip_pvt *pvt)
{
- char iabuf[NI_MAXHOST];
+ char iabuf[NI_MAXHOST] = "<error>";
char buf[33];
const char *host;
@@ -4952,7 +4952,7 @@
static void build_callid_registry(struct sip_registry *reg, struct sockaddr_storage *ourip, socklen_t ourip_len, const char *fromdomain)
{
char buf[33];
- char iabuf[NI_MAXHOST];
+ char iabuf[NI_MAXHOST] = "<error>";
const char *host;
ast_vinetsock_sa_getaddr((struct sockaddr*)ourip, ourip_len, iabuf, sizeof(iabuf));
@@ -4978,8 +4978,8 @@
{
struct sip_peer *p = 0;
struct sip_pvt *dialog = 0;
- char port[NI_MAXSERV];
- char host[NI_MAXHOST], *hostn;
+ char port[NI_MAXSERV] = "<error>";
+ char host[NI_MAXHOST] = "<error>", *hostn;
int portno;
char peer[256];
int result = -1;
@@ -5027,7 +5027,7 @@
portno = STANDARD_SIP_PORT;
if (global_srvlookup) {
- char service[NI_MAXHOST];
+ char service[NI_MAXHOST] = "<error>";
int tportno;
int ret;
@@ -5069,8 +5069,8 @@
int useglobal_nat, const int intended_method)
{
struct sip_pvt *p;
- char iabuf[NI_MAXHOST];
- char sbuf[NI_MAXSERV];
+ char iabuf[NI_MAXHOST] = "<error>";
+ char sbuf[NI_MAXSERV] = "<error>";
if (!(p = ast_calloc(1, sizeof(*p))))
return NULL;
@@ -5361,8 +5361,8 @@
int portnum = 0;
char username[256] = "";
char *hostname=NULL, *secret=NULL, *authuser=NULL;
- char host[NI_MAXHOST];
- char port[NI_MAXSERV];
+ char host[NI_MAXHOST] = "<error>";
+ char port[NI_MAXSERV] = "<error>";
char *callback=NULL;
if (!value)
@@ -5627,7 +5627,7 @@
int peert38capability = 0;
char s[256];
int old = 0;
- char hostport[NI_MAXHOST];
+ char hostport[NI_MAXHOST] = "<error>";
/* Peer capability is the capability in the SDP, non codec is RFC2833 DTMF (101) */
int peercapability = 0, peernoncodeccapability = 0;
@@ -6379,7 +6379,7 @@
{
int copied = 0;
int start = 0;
- char iabuf[NI_MAXHOST];
+ char iabuf[NI_MAXHOST] = "<error>";
for (;;) {
char new[256];
@@ -6473,10 +6473,10 @@
/*! \brief Set destination from SIP URI */
static void set_destination(struct sip_pvt *p, char *uri)
{
- char *h, *maddr, hostname[NI_MAXHOST];
- char sbuf[NI_MAXSERV], *ext;
+ char *h, *maddr, hostname[NI_MAXHOST] = "<error>";
+ char sbuf[NI_MAXSERV] = "<error>", *ext;
int debug=sip_debug_test_pvt(p);
- char hostport[NI_MAXHOST];
+ char hostport[NI_MAXHOST] = "<error>";
memset(hostname, '\0', sizeof(hostname));
memset(sbuf, '\0', sizeof(sbuf));
@@ -6755,8 +6755,8 @@
static int transmit_response_using_temp(ast_string_field callid, struct sockaddr *sa, socklen_t sa_len, struct ast_vinetsock *ns, int useglobal_nat, const int intended_method, const struct sip_request *req, const char *msg)
{
struct sip_pvt *p = NULL;
- char iabuf[NI_MAXHOST];
- char sbuf[NI_MAXSERV];
+ char iabuf[NI_MAXHOST] = "<error>";
+ char sbuf[NI_MAXSERV] = "<error>";
if (!(p = ast_threadstorage_get(&ts_temp_pvt, sizeof(*p)))) {
ast_log(LOG_NOTICE, "Failed to get temporary pvt\n");
@@ -7064,7 +7064,7 @@
socklen_t udptlsa_len=sizeof(udptlsa);
struct ast_str *m_modem = ast_str_alloca(1024);
struct ast_str *a_modem = ast_str_alloca(1024);
- char iabuf[NI_MAXHOST];
+ char iabuf[NI_MAXHOST] = "<error>";
struct sockaddr_storage udptldest;
socklen_t udptldestlen = 0;
int debug;
@@ -7258,7 +7258,7 @@
struct ast_str *a_video = ast_str_alloca(1024); /* Attributes for video */
struct ast_str *a_text = ast_str_alloca(1024); /* Attributes for text */
- char iabuf[NI_MAXHOST];
+ char iabuf[NI_MAXHOST] = "<error>";
int x;
int capability;
int needvideo = FALSE;
@@ -7698,7 +7698,7 @@
static void build_contact(struct sip_pvt *p)
{
/* Construct Contact: header */
- char hostport[NI_MAXHOST];
+ char hostport[NI_MAXHOST] = "<error>";
int port;
if((port = ast_vinetsock_sa_getport((struct sockaddr*)&p->ourip,
@@ -7722,7 +7722,7 @@
char buf[256];
const char *clid = default_callerid;
const char *clin = NULL;
- char host[NI_MAXHOST];
+ char host[NI_MAXHOST] = "<error>";
const char *fromdomain;
if (!ast_strlen_zero(p->rpid) || !ast_strlen_zero(p->rpid_from))
@@ -7802,7 +7802,7 @@
char to[256];
char tmp_n[BUFSIZ/2]; /* build a local copy of 'n' if needed */
char tmp_l[BUFSIZ/2]; /* build a local copy of 'l' if needed */
- char host[NI_MAXHOST];
+ char host[NI_MAXHOST] = "<error>";
int port;
const char *l = NULL; /* XXX what is this, exactly ? */
const char *n = NULL; /* XXX what is this, exactly ? */
@@ -8210,7 +8210,7 @@
{
struct sip_request req;
struct ast_str *out = ast_str_alloca(500);
- char iabuf[NI_MAXHOST];
+ char iabuf[NI_MAXHOST] = "<error>";
initreqprep(&req, p, SIP_NOTIFY);
add_header(&req, "Event", "message-summary");
@@ -8818,7 +8818,7 @@
char data[256];
int expiry;
char *scan, *addr, *port_str, *expiry_str, *username, *contact;
- char hostport[NI_MAXHOST];
+ char hostport[NI_MAXHOST] = "<error>";
if (peer->rt_fromcontact)
return;
@@ -8905,8 +8905,8 @@
{
int result;
char *hostport;
- char host[NI_MAXHOST];
- char port[NI_MAXSERV];
+ char host[NI_MAXHOST] = "<error>";
+ char port[NI_MAXSERV] = "<error>";
char *contact;
@@ -8952,9 +8952,9 @@
const char *expires = get_header(req, "Expires");
int expiry = atoi(expires);
char *curi, *domain;
- char host[NI_MAXHOST];
- char port[NI_MAXSERV];
- char hostport[NI_MAXHOST];
+ char host[NI_MAXHOST] = "<error>";
+ char port[NI_MAXSERV] = "<error>";
+ char hostport[NI_MAXHOST] = "<error>";
const char *useragent;
struct sockaddr_storage oldsa;
socklen_t oldsa_len;
@@ -9469,9 +9469,9 @@
enum check_auth_result res = AUTH_NOT_FOUND;
struct sip_peer *peer;
char tmp[256];
- char iabuf[NI_MAXHOST];
+ char iabuf[NI_MAXHOST] = "<error>";
char *name, *c;
- char domain[NI_MAXHOST];
+ char domain[NI_MAXHOST] = "<error>";
terminate_uri(uri); /* warning, overwrite the string */
@@ -9727,7 +9727,7 @@
char tmpf[256] = "", *from;
struct sip_request *req;
//char *colon;
- char dom[NI_MAXHOST];
+ char dom[NI_MAXHOST] = "<error>";
req = oreq;
if (!req)
@@ -10157,9 +10157,9 @@
{
char via[256];
char *c;
- char host[NI_MAXHOST];
- char port[NI_MAXSERV];
- char hostport[NI_MAXHOST];
+ char host[NI_MAXHOST] = "<error>";
+ char port[NI_MAXSERV] = "<error>";
+ char hostport[NI_MAXHOST] = "<error>";
ast_copy_string(via, get_header(req, "Via"), sizeof(via));
@@ -10426,7 +10426,7 @@
enum check_auth_result res;
int debug=sip_debug_test_addr(sa, sa_len);
struct sip_peer *peer;
- char hostport[NI_MAXHOST];
+ char hostport[NI_MAXHOST] = "<error>";
/* For subscribes, match on peer name only; for other methods,
* match on IP address-port of the incoming request.
@@ -10557,8 +10557,8 @@
char from[256];
char *dummy; /* dummy return value for parse_uri */
char *domain; /* dummy return value for parse_uri */
- char host[NI_MAXHOST];
- char port[NI_MAXSERV];
+ char host[NI_MAXHOST] = "<error>";
+ char port[NI_MAXSERV] = "<error>";
char *of;
char rpid_num[50];
const char *rpid;
@@ -10983,7 +10983,7 @@
#define FORMAT "%-25.25s %-39.39s %-3.3s %-3.3s %-3.3s %-8d %-10s %s\n"
char name[256];
- char iabuf[NI_MAXHOST];
+ char iabuf[NI_MAXHOST] = "<error>";
int total_peers = 0;
int peers_mon_online = 0;
int peers_mon_offline = 0;
@@ -11499,7 +11499,7 @@
{
char status[30] = "";
char cbuf[256];
- char hostport[NI_MAXHOST];
+ char hostport[NI_MAXHOST] = "<error>";
struct sip_peer *peer;
char codec_buf[512];
struct ast_codec_pref *pref;
@@ -11880,7 +11880,7 @@
int realtimeusers;
int realtimeregs;
char codec_buf[BUFSIZ];
- char hostport[NI_MAXHOST];
+ char hostport[NI_MAXHOST] = "<error>";
const char *msg; /* temporary msg pointer */
switch (cmd) {
@@ -11986,7 +11986,7 @@
{
struct ast_ha *d;
const char *prefix = "Localnet:";
- char addrbuf[NI_MAXHOST], maskbuf[NI_MAXHOST];
+ char addrbuf[NI_MAXHOST] = "<error>", maskbuf[NI_MAXHOST] = "<error>";
for (d = localaddr; d ; prefix = "", d = d->next) {
ast_vinetsock_sa_get_host((struct sockaddr*)&d->netaddr,
@@ -12111,7 +12111,7 @@
struct __show_chan_arg *arg = __arg;
socklen_t dst_len = 0;
const struct sockaddr *dst = sip_real_dst(cur, &dst_len);
- char iabuf[NI_MAXHOST];
+ char iabuf[NI_MAXHOST] = "<error>";
/* XXX indentation preserved to reduce diff. Will be fixed later */
if (cur->subscribed == NONE && !arg->subscriptions) {
@@ -12345,10 +12345,10 @@
static char *sip_show_channel(struct ast_cli_entry *e, int cmd, struct ast_cli_args *a)
{
struct sip_pvt *cur;
- char iabuf[NI_MAXHOST];
+ char iabuf[NI_MAXHOST] = "<error>";
size_t len;
int found = 0;
- char hostport[NI_MAXHOST];
+ char hostport[NI_MAXHOST] = "<error>";
switch (cmd) {
case CLI_INIT:
@@ -12646,8 +12646,8 @@
/*! \brief Enable SIP Debugging for a single IP */
static char *sip_do_debug_ip(int fd, char *arg)
{
- char host[NI_MAXHOST];
- char port[NI_MAXSERV];
+ char host[NI_MAXHOST] = "<error>";
+ char port[NI_MAXSERV] = "<error>";
char *end;
if (ast_vinetsock_str2hp(host, sizeof(host), port, sizeof(port), arg, 1, (void*)&end) || end[0] != '\0') {
@@ -12668,7 +12668,7 @@
/*! \brief sip_do_debug_peer: Turn on SIP debugging for a given peer */
static char *sip_do_debug_peer(int fd, char *arg)
{
- char hostport[NI_MAXHOST];
+ char hostport[NI_MAXHOST] = "<error>";
struct sip_peer *peer = find_peer(arg, NULL, 0, 1);
if (!peer)
@@ -12970,7 +12970,7 @@
char resp_hash[256];
char uri[256];
char cnonce[80];
- char iabuf[NI_MAXHOST];
+ char iabuf[NI_MAXHOST] = "<error>";
const char *username;
const char *secret;
const char *md5secret;
@@ -13125,7 +13125,7 @@
{
struct sip_peer *peer;
char *colname;
- char iabuf[NI_MAXHOST];
+ char iabuf[NI_MAXHOST] = "<error>";
if ((colname = strchr(data, ':'))) /*! \todo Will be deprecated after 1.4 */
*colname++ = '\0';
@@ -13227,7 +13227,7 @@
static int function_sipchaninfo_read(struct ast_channel *chan, const char *cmd, char *data, char *buf, size_t len)
{
struct sip_pvt *p;
- char iabuf[NI_MAXHOST];
+ char iabuf[NI_MAXHOST] = "<error>";
*buf = 0;
@@ -13661,7 +13661,7 @@
*/
static void handle_response_refer(struct sip_pvt *p, int resp, char *rest, struct sip_request *req, int seqno)
{
- char hostport[NI_MAXHOST];
+ char hostport[NI_MAXHOST] = "<error>";
/* If no refer structure exists, then do nothing */
if (!p->refer)
@@ -13930,12 +13930,12 @@
static void handle_response(struct sip_pvt *p, int resp, char *rest, struct sip_request *req, int seqno)
{
struct ast_channel *owner;
- char iabuf[NI_MAXHOST];
+ char iabuf[NI_MAXHOST] = "<error>";
int sipmethod;
int res = 1;
const char *c = get_header(req, "Cseq");
const char *msg = strchr(c, ' ');
- char hostport[NI_MAXHOST];
+ char hostport[NI_MAXHOST] = "<error>";
if (!msg)
msg = "";
@@ -15965,7 +15965,7 @@
struct ast_channel *c=NULL;
int res;
struct ast_channel *bridged_to;
- char iabuf[NI_MAXHOST];
+ char iabuf[NI_MAXHOST] = "<error>";
/* If we have an INCOMING invite that we haven't answered, terminate that transaction */
if (p->pendinginvite && !ast_test_flag(&p->flags[0], SIP_OUTGOING) && !req->ignore && !p->owner)
@@ -16077,7 +16077,7 @@
const char *eventheader = get_header(req, "Event"); /* Get Event package name */
const char *accept = get_header(req, "Accept");
int resubscribe = (p->subscribed != NONE);
- char iabuf[NI_MAXHOST];
+ char iabuf[NI_MAXHOST] = "<error>";
char *temp, *event;
if (p->initreq.headers) {
@@ -16368,7 +16368,7 @@
struct sockaddr *sa, socklen_t sa_len, char *e)
{
enum check_auth_result res;
- char iabuf[NI_MAXHOST];
+ char iabuf[NI_MAXHOST] = "<error>";
/* Use this as the basis */
copy_request(&p->initreq, req);
@@ -16432,7 +16432,7 @@
int len;
int respid;
int res = 0;
- char iabuf[NI_MAXHOST];
+ char iabuf[NI_MAXHOST] = "<error>";
int debug = sip_debug_test_pvt(p);
char *e;
int error = 0;
@@ -16651,7 +16651,7 @@
int recount = 0;
int lockretry;
struct ast_vinetsock* ns;
- char hostport[NI_MAXHOST];
+ char hostport[NI_MAXHOST] = "<error>";
sa_len = sizeof(sa);
memset(&sa, 0, sa_len);
@@ -17017,7 +17017,7 @@
{
struct sip_pvt *p;
int xmitres = 0;
- char iabuf[NI_MAXHOST];
+ char iabuf[NI_MAXHOST] = "<error>";
if (!peer->maxms || !peer->addr_len) {
/* IF we have no IP, or this isn't to be monitored, return
@@ -17787,7 +17787,7 @@
struct ast_flags mask[2] = {{(0)}};
char callback[256] = "";
int peerport = STANDARD_SIP_PORT;
- char hbuf[NI_MAXHOST], sbuf[NI_MAXSERV], *end;
+ char hbuf[NI_MAXHOST] = "<error>", sbuf[NI_MAXSERV] = "<error>", *end;
if (!realtime)
/* Note we do NOT use find_peer here, to avoid realtime recursion */
@@ -18393,8 +18393,8 @@
externexpire = time(NULL);
} else if (!strcasecmp(v->name, "bindaddr")) {
char *end;
- char iabuf[NI_MAXHOST];
- char sbuf[NI_MAXSERV];
+ char iabuf[NI_MAXHOST] = "<error>";
+ char sbuf[NI_MAXSERV] = "<error>";
if (ast_vinetsock_str2hp(iabuf, sizeof(iabuf), sbuf, sizeof(sbuf), v->value, 0, (void*)&end) || end[0] != '\0') {
ast_log(LOG_WARNING, "Invalid bindaddr entry '%s' at line %d (1)\n",
@@ -18614,7 +18614,7 @@
ast_vinetsock_list_set_defport(netsocks, defport);
if (ast_vinetsock_list_isempty(netsocks)) {
- char sbuf[NI_MAXSERV];
+ char sbuf[NI_MAXSERV] = "<error>";
snprintf(sbuf, sizeof(sbuf), "%d", defport);
if (option_verbose > 1)
@@ -18627,7 +18627,7 @@
ast_vinetsock_list_bind(netsocks, io, global_tos_sip, sipsock_read, NULL, 1, "SIP");
if ( stunaddr_len && ast_vinetsock_sa_is_ipv4((struct sockaddr*) &stunaddr) ) {
- char hostport[NI_MAXHOST];
+ char hostport[NI_MAXHOST] = "<error>";
ast_vinetsock_sa_get_hostport( (struct sockaddr*) &stunaddr,
stunaddr_len, hostport, sizeof(hostport) );
ast_debug(1, "stun to %s\n", hostport);
@@ -18661,7 +18661,7 @@
/* In order to *not* break backwards compatibility */
/* Some phones address us at IP only, some with additional port number */
if (auto_sip_domains) {
- char temp[NI_MAXHOST];
+ char temp[NI_MAXHOST] = "<error>";
/* First our default IP addresses */
ASTOBJ_CONTAINER_TRAVERSE(netsocks, 1, {
@@ -18723,7 +18723,7 @@
static int sip_set_viudptl_peer(struct ast_channel *chan, struct ast_viudptl *udptl)
{
struct sip_pvt *p;
- char hostport[NI_MAXHOST];
+ char hostport[NI_MAXHOST] = "<error>";
p = chan->tech_pvt;
if (!p)
@@ -18766,7 +18766,7 @@
{
struct sip_pvt *p;
int flag = 0;
- char hostport[NI_MAXHOST];
+ char hostport[NI_MAXHOST] = "<error>";
p = chan->tech_pvt;
if (!p || !pvt->udptl || ! ast_vinetsock_sa_is_ipv4((struct sockaddr*)&pvt->ourip))
@@ -18935,7 +18935,7 @@
{
struct sip_pvt *p;
int changed = 0;
- char iabuf[NI_MAXHOST];
+ char iabuf[NI_MAXHOST] = "<error>";
p = chan->tech_pvt;
if (!p)
@@ -19129,9 +19129,9 @@
{
char *cdest;
char *extension;
- char host[NI_MAXHOST];
- char port[NI_MAXSERV];
- char hostport[NI_MAXHOST];
+ char host[NI_MAXHOST] = "<error>";
+ char port[NI_MAXSERV] = "<error>";
+ char hostport[NI_MAXHOST] = "<error>";
char tmp[80];
cdest = ast_strdupa(dest);
@@ -19151,7 +19151,7 @@
return 0;
}
if ((localtmp = strcasestr(tmp, "sip:")) && (localtmp = strchr(localtmp, '@'))) {
- char lhost[NI_MAXHOST], lport[NI_MAXSERV];
+ char lhost[NI_MAXHOST] = "<error>", lport[NI_MAXSERV] = "<error>";
memset(lhost, 0, sizeof(lhost));
memset(lport, 0, sizeof(lport));
More information about the svn-commits
mailing list