[Asterisk-cvs] asterisk/channels chan_mgcp.c, 1.79.2.13, 1.79.2.14 chan_sip.c, 1.510.2.60, 1.510.2.61

russell at lists.digium.com russell at lists.digium.com
Sun May 15 11:50:05 CDT 2005


Update of /usr/cvsroot/asterisk/channels
In directory mongoose.digium.com:/tmp/cvs-serv16483/channels

Modified Files:
      Tag: v1-0
	chan_mgcp.c chan_sip.c 
Log Message:
ensure that calls to gethostbyname are null terminated,
also use MAXHOSTNAMELEN where appropriate (bug #4198) (bug #4212)


Index: chan_mgcp.c
===================================================================
RCS file: /usr/cvsroot/asterisk/channels/chan_mgcp.c,v
retrieving revision 1.79.2.13
retrieving revision 1.79.2.14
diff -u -d -r1.79.2.13 -r1.79.2.14
--- chan_mgcp.c	12 May 2005 02:22:56 -0000	1.79.2.13
+++ chan_mgcp.c	15 May 2005 15:55:30 -0000	1.79.2.14
@@ -239,7 +239,7 @@
 static int capability = AST_FORMAT_ULAW;
 static int nonCodecCapability = AST_RTP_DTMF;
 
-static char ourhost[256];
+static char ourhost[MAXHOSTNAMELEN];
 static struct in_addr __ourip;
 static int ourport;
 
@@ -3944,7 +3944,7 @@
 	struct ast_hostent ahp; struct hostent *hp;
 	int format;
 	
-	if (gethostname(ourhost, sizeof(ourhost))) {
+	if (gethostname(ourhost, sizeof(ourhost)-1)) {
 		ast_log(LOG_WARNING, "Unable to get hostname, MGCP disabled\n");
 		return 0;
 	}

Index: chan_sip.c
===================================================================
RCS file: /usr/cvsroot/asterisk/channels/chan_sip.c,v
retrieving revision 1.510.2.60
retrieving revision 1.510.2.61
diff -u -d -r1.510.2.60 -r1.510.2.61
--- chan_sip.c	15 Apr 2005 07:24:34 -0000	1.510.2.60
+++ chan_sip.c	15 May 2005 15:55:30 -0000	1.510.2.61
@@ -205,7 +205,7 @@
 static int global_promiscredir;
 
 static char global_musicclass[MAX_LANGUAGE] = "";	/* Global music on hold class */
-static char global_realm[AST_MAX_EXTENSION] = "asterisk"; 	/* Default realm */
+static char global_realm[MAXHOSTNAMELEN] = "asterisk"; 	/* Default realm */
 static char regcontext[AST_MAX_EXTENSION] = "";
 
 /* Expire slowly */
@@ -299,10 +299,10 @@
 	char from[256];				/* The From: header */
 	char useragent[256];			/* User agent in SIP request */
 	char context[AST_MAX_EXTENSION];	/* Context for this call */
-	char fromdomain[AST_MAX_EXTENSION];	/* Domain to show in the from field */
+	char fromdomain[MAXHOSTNAMELEN];	/* Domain to show in the from field */
 	char fromuser[AST_MAX_EXTENSION];	/* User to show in the user field */
 	char fromname[AST_MAX_EXTENSION];	/* Name to show in the user field */
-	char tohost[AST_MAX_EXTENSION];		/* Host we should put in the "to" field */
+	char tohost[MAXHOSTNAMELEN];		/* Host we should put in the "to" field */
 	char language[MAX_LANGUAGE];		/* Default language for this call */
 	char musicclass[MAX_LANGUAGE];          /* Music on Hold class */
 	char rdnis[256];			/* Referring DNIS */
@@ -316,14 +316,14 @@
 	char callerid[256];			/* Caller*ID */
 	int restrictcid;			/* hide presentation from remote user */
 	char via[256];
-	char fullcontact[128];		/* Extra parameters to go in the "To" header */
+	char fullcontact[128];			/* Extra parameters to go in the "To" header */
 	char accountcode[20];			/* Account code */
 	char our_contact[256];			/* Our contact header */
-	char realm[256];			/* Authorization realm */
+	char realm[MAXHOSTNAMELEN];		/* Authorization realm */
 	char nonce[256];			/* Authorization nonce */
 	char opaque[256];			/* Opaque nonsense */
 	char qop[80];				/* Quality of Protection, since SIP wasn't complicated enough yet. */
-	char domain[256];			/* Authorization domain */
+	char domain[MAXHOSTNAMELEN];		/* Authorization domain */
 	char lastmsg[256];			/* Last Message sent/received */
 	int amaflags;				/* AMA Flags */
 	int pendinginvite;			/* Any pending invite */
@@ -385,7 +385,7 @@
 	char name[80];
 	char secret[80];
         char md5secret[80];
-	char context[80];
+	char context[AST_MAX_EXTENSION];
 	char callerid[80];
 	char accountcode[20];
 	char language[MAX_LANGUAGE];
@@ -424,13 +424,13 @@
 	char name[80];
 	char secret[80];
 	char md5secret[80];
-	char context[80];		/* JK02: peers need context too to allow parking etc */
+	char context[AST_MAX_EXTENSION];	/* JK02: peers need context too to allow parking etc */
 	char username[80];
-	char tohost[80];
+	char tohost[MAXHOSTNAMELEN];
 	char regexten[AST_MAX_EXTENSION];	/* Extension to register (if regcontext is used) */
 	char fromuser[80];
-	char fromdomain[80];
-	char fullcontact[128];
+	char fromdomain[MAXHOSTNAMELEN];
+	char fullcontact[256];
 	char mailbox[AST_MAX_EXTENSION];
 	char language[MAX_LANGUAGE];
 	char musicclass[MAX_LANGUAGE];  /* Music on Hold class */
@@ -496,10 +496,10 @@
 	int portno;				/* Optional port override */
 	char username[80];		/* Who we are registering as */
 	char authuser[80];		/* Who we *authenticate* as */
-	char hostname[80];
+	char hostname[MAXHOSTNAMELEN];
 	char secret[80];		/* Password or key name in []'s */	
 	char md5secret[80];
-	char contact[80];		/* Contact extension */
+	char contact[256];		/* Contact extension */
 	char random[80];
 	int expire;			/* Sched ID of expiration */
 	int timeout; 			/* sched id of sip_reg_timeout */
@@ -512,9 +512,9 @@
 	struct sockaddr_in us;		/* Who the server thinks we are */
  	
  					/* Saved headers */
- 	char realm[256];		/* Authorization realm */
+ 	char realm[MAXHOSTNAMELEN];	/* Authorization realm */
  	char nonce[256];		/* Authorization nonce */
- 	char domain[256];		/* Authorization domain */
+ 	char domain[MAXHOSTNAMELEN];	/* Authorization domain */
  	char opaque[256];		/* Opaque nonsense */
  	char qop[80];			/* Quality of Protection. */
  
@@ -1289,7 +1289,7 @@
 	char *port;
 	char *callhost;
 	int portno;
-	char host[256], *hostn;
+	char host[MAXHOSTNAMELEN], *hostn;
 	char peer[256]="";
 
 	strncpy(peer, opeer, sizeof(peer) - 1);
@@ -1378,7 +1378,7 @@
 		else
 			portno = DEFAULT_SIP_PORT;
 		if (srvlookup) {
-			char service[256];
+			char service[MAXHOSTNAMELEN];
 			int tportno;
 			int ret;
 			snprintf(service, sizeof(service), "_sip._udp.%s", peer);




More information about the svn-commits mailing list