Use MAX_HOST_NAME+1 (limits.h) instead of MAXHOSTNAMELEN (sys/param.h
or netdb.h).
This commit is contained in:
@@ -788,8 +788,8 @@ netgr_matches(char *netgr, char *lhost, char *shost, char *user)
|
||||
#ifdef HAVE_GETDOMAINNAME
|
||||
/* get the domain name (if any) */
|
||||
if (!initialized) {
|
||||
domain = (char *) emalloc(MAXHOSTNAMELEN + 1);
|
||||
if (getdomainname(domain, MAXHOSTNAMELEN + 1) == -1 || *domain == '\0') {
|
||||
domain = (char *) emalloc(HOST_NAME_MAX + 1);
|
||||
if (getdomainname(domain, HOST_NAME_MAX + 1) == -1 || *domain == '\0') {
|
||||
efree(domain);
|
||||
domain = NULL;
|
||||
}
|
||||
|
@@ -128,7 +128,7 @@ main(int argc, char *argv[])
|
||||
struct privilege *priv;
|
||||
struct userspec *us;
|
||||
char *p, *grfile, *pwfile;
|
||||
char hbuf[MAXHOSTNAMELEN + 1];
|
||||
char hbuf[HOST_NAME_MAX + 1];
|
||||
int match, host_match, runas_match, cmnd_match;
|
||||
int ch, dflag, exitcode = 0;
|
||||
debug_decl(main, SUDO_DEBUG_MAIN)
|
||||
|
@@ -1040,7 +1040,7 @@ get_args(char *cmnd)
|
||||
static void
|
||||
get_hostname(void)
|
||||
{
|
||||
char *p, thost[MAXHOSTNAMELEN + 1];
|
||||
char *p, thost[HOST_NAME_MAX + 1];
|
||||
debug_decl(get_hostname, SUDO_DEBUG_UTIL)
|
||||
|
||||
if (gethostname(thost, sizeof(thost)) != -1) {
|
||||
|
Reference in New Issue
Block a user