Use MAXHOSTNAMELEN+1 when allocating host/domain name since some
systems do not include space for the NUL in the size. Also manually NUL-terminate buffer from gethostname() since POSIX is wishy-washy on this.
This commit is contained in:
3
sudo.c
3
sudo.c
@@ -576,7 +576,7 @@ init_vars(sudo_mode, envp)
|
||||
int sudo_mode;
|
||||
char **envp;
|
||||
{
|
||||
char *p, **ep, thost[MAXHOSTNAMELEN];
|
||||
char *p, **ep, thost[MAXHOSTNAMELEN + 1];
|
||||
int nohostname;
|
||||
|
||||
/* Sanity check command from user. */
|
||||
@@ -602,6 +602,7 @@ init_vars(sudo_mode, envp)
|
||||
if (nohostname)
|
||||
user_host = user_shost = "localhost";
|
||||
else {
|
||||
thost[sizeof(thost) - 1] = '\0';
|
||||
user_host = estrdup(thost);
|
||||
if (def_fqdn) {
|
||||
/* Defer call to set_fqdn() until log_error() is safe. */
|
||||
|
Reference in New Issue
Block a user