getdomainname() isn't guaranteed to null terminate the string if it was
truncated for length. SVN 14135 made sure that the truncated version would always be null terminated. SVN 14144 broke this for no readily apparent reason, and I have no idea what it was even trying to accomplish. Reverted.
This commit is contained in:
parent
b4ec339ac2
commit
081d6d4380
@ -37,7 +37,7 @@ void print_login_issue(const char *issue_file, const char *tty)
|
|||||||
{
|
{
|
||||||
FILE *fd;
|
FILE *fd;
|
||||||
int c;
|
int c;
|
||||||
char buf[256+2];
|
char buf[256];
|
||||||
const char *outbuf;
|
const char *outbuf;
|
||||||
time_t t;
|
time_t t;
|
||||||
struct utsname uts;
|
struct utsname uts;
|
||||||
@ -82,8 +82,8 @@ void print_login_issue(const char *issue_file, const char *tty)
|
|||||||
|
|
||||||
case 'D':
|
case 'D':
|
||||||
case 'o':
|
case 'o':
|
||||||
buf[0] = '\0';
|
getdomainname(buf, sizeof(buf));
|
||||||
getdomainname(buf, sizeof(buf) - 1);
|
buf[sizeof(buf) - 1] = '\0';
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 'd':
|
case 'd':
|
||||||
@ -95,8 +95,8 @@ void print_login_issue(const char *issue_file, const char *tty)
|
|||||||
break;
|
break;
|
||||||
|
|
||||||
case 'h':
|
case 'h':
|
||||||
buf[0] = '\0';
|
|
||||||
gethostname(buf, sizeof(buf) - 1);
|
gethostname(buf, sizeof(buf) - 1);
|
||||||
|
buf[sizeof(buf) - 1] = '\0';
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 'l':
|
case 'l':
|
||||||
@ -120,7 +120,7 @@ void print_login_prompt(void)
|
|||||||
{
|
{
|
||||||
char buf[MAXHOSTNAMELEN+1];
|
char buf[MAXHOSTNAMELEN+1];
|
||||||
|
|
||||||
if(gethostname(buf, MAXHOSTNAMELEN) == 0)
|
gethostname(buf, MAXHOSTNAMELEN);
|
||||||
fputs(buf, stdout);
|
fputs(buf, stdout);
|
||||||
|
|
||||||
fputs(LOGIN, stdout);
|
fputs(LOGIN, stdout);
|
||||||
|
Loading…
Reference in New Issue
Block a user