aboutsummaryrefslogtreecommitdiffstats
path: root/asterisk.c
diff options
context:
space:
mode:
authorrussell <russell@f38db490-d61c-443f-a65b-d21fe96a405b>2005-05-15 15:55:31 +0000
committerrussell <russell@f38db490-d61c-443f-a65b-d21fe96a405b>2005-05-15 15:55:31 +0000
commit1404859ff2fa4ddc9bca65bddb2935d2e3dc24b4 (patch)
treedef1590c6c6430e694368a719f221a2d27d72ac0 /asterisk.c
parent3341a7391021a9b83b01ffda66588bd15dc04945 (diff)
ensure that calls to gethostbyname are null terminated,
also use MAXHOSTNAMELEN where appropriate (bug #4198) (bug #4212) git-svn-id: http://svn.digium.com/svn/asterisk/branches/v1-0@5675 f38db490-d61c-443f-a65b-d21fe96a405b
Diffstat (limited to 'asterisk.c')
-rwxr-xr-xasterisk.c10
1 files changed, 5 insertions, 5 deletions
diff --git a/asterisk.c b/asterisk.c
index 1bf800d4c..146f43a71 100755
--- a/asterisk.c
+++ b/asterisk.c
@@ -264,12 +264,12 @@ static pthread_t lthread;
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 @@ static char *cli_prompt(EditLine *el)
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 main(int argc, char *argv[])
{
int c;
char filename[80] = "";
- char hostname[256];
+ char hostname[MAXHOSTNAMELEN]="";
char tmp[80];
char * xarg = NULL;
int x;
@@ -1597,7 +1597,7 @@ int main(int argc, char *argv[])
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();