mirror of
https://git.FreeBSD.org/src.git
synced 2025-01-30 16:51:41 +00:00
Fix some minor bugs, namely:
- Initialize "rval", which would be used uninitialized if al or pl options were set. - Don't pass an empty string to login(1) as a user name (this could be triggered by entering a name and then killing it with backspace or ^U.) - Don't loop endlessly if the al option specifies a bogus (i.e., not alphanumeric) auto-login name. - Don't pass a bogus user name to login(1) if a good name were entered and then killed with ^U. - Exit with status 0, not 1, on receiving an EOF character, since it's not a error condition. MFC after: 1 week
This commit is contained in:
parent
5b63e8fcf0
commit
f648dfd929
Notes:
svn2git
2020-12-20 02:59:44 +00:00
svn path=/head/; revision=115900
@ -344,6 +344,8 @@ main(int argc, char *argv[])
|
||||
signal(SIGALRM, dingdong);
|
||||
alarm(TO);
|
||||
}
|
||||
|
||||
rval = 0;
|
||||
if (AL) {
|
||||
const char *p = AL;
|
||||
char *q = name;
|
||||
@ -374,12 +376,20 @@ main(int argc, char *argv[])
|
||||
oflush();
|
||||
alarm(0);
|
||||
signal(SIGALRM, SIG_DFL);
|
||||
if (name[0] == '\0')
|
||||
continue;
|
||||
if (name[0] == '-') {
|
||||
puts("user names may not start with '-'.");
|
||||
continue;
|
||||
}
|
||||
if (!(upper || lower || digit))
|
||||
continue;
|
||||
if (!(upper || lower || digit)) {
|
||||
if (AL) {
|
||||
syslog(LOG_ERR,
|
||||
"invalid auto-login name: %s", AL);
|
||||
exit(1);
|
||||
} else
|
||||
continue;
|
||||
}
|
||||
set_flags(2);
|
||||
if (crmod) {
|
||||
tmode.c_iflag |= ICRNL;
|
||||
@ -564,7 +574,7 @@ getname(void)
|
||||
}
|
||||
|
||||
if (c == EOT || c == CTRL('d'))
|
||||
exit(1);
|
||||
exit(0);
|
||||
if (c == '\r' || c == '\n' || np >= &name[sizeof name-1]) {
|
||||
putf("\r\n");
|
||||
break;
|
||||
@ -590,6 +600,7 @@ getname(void)
|
||||
else if (np > name)
|
||||
puts(" \r");
|
||||
prompt();
|
||||
digit = lower = upper = 0;
|
||||
np = name;
|
||||
continue;
|
||||
} else if (isdigit(c))
|
||||
|
Loading…
Reference in New Issue
Block a user