ensure that calls to gethostbyname are null terminated,

also use MAXHOSTNAMELEN where appropriate (bug #4198) (bug #4212)


git-svn-id: https://origsvn.digium.com/svn/asterisk/branches/v1-0@5675 65c4cc65-6c06-0410-ace0-fbb531ad65f3
This commit is contained in:
Russell Bryant
2005-05-15 15:55:31 +00:00
parent fcb8ab5da6
commit 43e32456ca
7 changed files with 79 additions and 43 deletions

View File

@@ -65,7 +65,7 @@ static struct msglist {
struct msglist *next;
} *list = NULL, *last = NULL;
static char hostname[256];
static char hostname[MAXHOSTNAMELEN];
struct logchannel {
int logmask;
@@ -230,7 +230,7 @@ static void init_logger_chain(void)
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");
}