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

@@ -862,7 +862,7 @@ static int sendmail(char *srcemail, struct ast_vm_user *vmu, int msgnum, char *m
FILE *p=NULL;
int pfd;
char date[256];
char host[256];
char host[MAXHOSTNAMELEN] = "";
char who[256];
char bound[256];
char fname[256];
@@ -890,7 +890,7 @@ static int sendmail(char *srcemail, struct ast_vm_user *vmu, int msgnum, char *m
}
}
if (p) {
gethostname(host, sizeof(host));
gethostname(host, sizeof(host)-1);
if (strchr(srcemail, '@'))
strncpy(who, srcemail, sizeof(who)-1);
else {
@@ -1020,7 +1020,7 @@ static int sendpage(char *srcemail, char *pager, int msgnum, char *mailbox, char
FILE *p=NULL;
int pfd;
char date[256];
char host[256];
char host[MAXHOSTNAMELEN]="";
char who[256];
char dur[256];
char tmp[80] = "/tmp/astmail-XXXXXX";
@@ -1039,7 +1039,7 @@ static int sendpage(char *srcemail, char *pager, int msgnum, char *mailbox, char
}
if (p) {
gethostname(host, sizeof(host));
gethostname(host, sizeof(host)-1);
if (strchr(srcemail, '@'))
strncpy(who, srcemail, sizeof(who)-1);
else {