[Asterisk-cvs] asterisk acl.c, 1.43, 1.44 asterisk.c, 1.151,
1.152 logger.c, 1.66, 1.67
markster at lists.digium.com
markster at lists.digium.com
Sun May 8 12:38:02 CDT 2005
Update of /usr/cvsroot/asterisk
In directory mongoose.digium.com:/tmp/cvs-serv23957
Modified Files:
acl.c asterisk.c logger.c
Log Message:
Fix gethostname calls (bug #4198, with mods)
Index: acl.c
===================================================================
RCS file: /usr/cvsroot/asterisk/acl.c,v
retrieving revision 1.43
retrieving revision 1.44
diff -u -d -r1.43 -r1.44
--- acl.c 4 May 2005 04:35:27 -0000 1.43
+++ acl.c 8 May 2005 16:44:25 -0000 1.44
@@ -405,7 +405,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;
@@ -416,7 +416,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.151
retrieving revision 1.152
diff -u -d -r1.151 -r1.152
--- asterisk.c 29 Apr 2005 17:24:58 -0000 1.151
+++ asterisk.c 8 May 2005 16:44:25 -0000 1.152
@@ -273,12 +273,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);
@@ -1026,7 +1026,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;
@@ -1668,7 +1668,7 @@
{
int c;
char filename[80] = "";
- char hostname[256];
+ char hostname[MAXHOSTNAMELEN]="";
char tmp[80];
char * xarg = NULL;
int x;
@@ -1693,7 +1693,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.66
retrieving revision 1.67
diff -u -d -r1.66 -r1.67
--- logger.c 22 Apr 2005 13:11:34 -0000 1.66
+++ logger.c 8 May 2005 16:44:25 -0000 1.67
@@ -75,7 +75,7 @@
struct msglist *next;
} *list = NULL, *last = NULL;
-static char hostname[256];
+static char hostname[MAXHOSTNAMELEN];
enum logtypes {
LOGTYPE_SYSLOG,
@@ -294,7 +294,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");
}
More information about the svn-commits
mailing list