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

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


Index: acl.c
===================================================================
RCS file: /usr/cvsroot/asterisk/acl.c,v
retrieving revision 1.27.2.3
retrieving revision 1.27.2.4
diff -u -d -r1.27.2.3 -r1.27.2.4
--- acl.c       21 Feb 2005 03:57:26 -0000      1.27.2.3
+++ acl.c       15 May 2005 15:55:30 -0000      1.27.2.4
@@ -381,7 +381,7 @@
 
 int ast_find_ourip(struct in_addr *ourip, struct sockaddr_in bindaddr)
 {
-       char ourhost[256];
+       char ourhost[MAXHOSTNAMELEN]="";
        struct ast_hostent ahp;
        struct hostent *hp;
        struct in_addr saddr;
@@ -392,7 +392,7 @@
                return 0;
        }
        /* try to use our hostname */
-       if (gethostname(ourhost, sizeof(ourhost))) {
+       if (gethostname(ourhost, sizeof(ourhost)-1)) {
                ast_log(LOG_WARNING, "Unable to get hostname\n");
        } else {
                hp = ast_gethostbyname(ourhost, &ahp);

Index: asterisk.c
===================================================================
RCS file: /usr/cvsroot/asterisk/asterisk.c,v
retrieving revision 1.125.2.6
retrieving revision 1.125.2.7
diff -u -d -r1.125.2.6 -r1.125.2.7
--- asterisk.c  5 Apr 2005 09:37:02 -0000       1.125.2.6
+++ asterisk.c  15 May 2005 15:55:30 -0000      1.125.2.7
@@ -264,12 +264,12 @@
 static void *netconsole(void *vconsole)
 {
        struct console *con = vconsole;
-       char hostname[256];
+       char hostname[MAXHOSTNAMELEN]="";
        char tmp[512];
        int res;
        struct pollfd fds[2];
        
-       if (gethostname(hostname, sizeof(hostname)))
+       if (gethostname(hostname, sizeof(hostname)-1))
                strncpy(hostname, "<Unknown>", sizeof(hostname)-1);
        snprintf(tmp, sizeof(tmp), "%s/%d/%s\n", hostname, ast_mainpid, 
ASTERISK_VERSION);
        fdprint(con->fd, tmp);
@@ -964,7 +964,7 @@
                memset(prompt, 0, sizeof(prompt));
                while (*t != '\0' && *p < sizeof(prompt)) {
                        if (*t == '%') {
-                               char hostname[256];
+                               char hostname[MAXHOSTNAMELEN]="";
                                int i;
                                struct timeval tv;
                                struct tm tm;
@@ -1572,7 +1572,7 @@
 {
        int c;
        char filename[80] = "";
-       char hostname[256];
+       char hostname[MAXHOSTNAMELEN]="";
        char tmp[80];
        char * xarg = NULL;
        int x;
@@ -1597,7 +1597,7 @@
                option_remote++;
                option_nofork++;
        }
-       if (gethostname(hostname, sizeof(hostname)))
+       if (gethostname(hostname, sizeof(hostname)-1))
                strncpy(hostname, "<Unknown>", sizeof(hostname)-1);
        ast_mainpid = getpid();
        ast_ulaw_init();

Index: logger.c
===================================================================
RCS file: /usr/cvsroot/asterisk/logger.c,v
retrieving revision 1.45.2.5
retrieving revision 1.45.2.6
diff -u -d -r1.45.2.5 -r1.45.2.6
--- logger.c    5 Apr 2005 10:12:24 -0000       1.45.2.5
+++ logger.c    15 May 2005 15:55:30 -0000      1.45.2.6
@@ -65,7 +65,7 @@
        struct msglist *next;
 } *list = NULL, *last = NULL;
 
-static char hostname[256];
+static char hostname[MAXHOSTNAMELEN];
 
 struct logchannel {
        int logmask;
@@ -230,7 +230,7 @@
        ast_mutex_lock(&loglock);
        if ((s = ast_variable_retrieve(cfg, "general", "appendhostname"))) {
                if(ast_true(s)) {
-                       if(gethostname(hostname, sizeof(hostname))) {
+                       if(gethostname(hostname, sizeof(hostname)-1)) {
                                strncpy(hostname, "unknown", 
sizeof(hostname)-1);
                                ast_log(LOG_WARNING, "What box has no 
hostname???\n");
                        }

_______________________________________________
Asterisk-Cvs mailing list
[email protected]
http://lists.digium.com/mailman/listinfo/asterisk-cvs

Reply via email to