* strings.h (strechr): New function.
* uinfo.cc (pwdgrp::next_str): Search only for input char in string. Return EOS on failure. Don't check for NULL since it shouldn't be possible. (pwdgrp::add_line): Revert to replacing '\n' in input line with '\0'. (pwdgrp::next_num): Pass explicit separator character to next_str. * grp.cc (pwdgrp::parse_group): Ditto. * passwd.cc (pwdgrp::parse_passwd): Ditto. Revamp test for garbage input. * pwdgrp.h (pwdgrp::next_str): Don't use default parameter.
This commit is contained in:
@@ -38,18 +38,17 @@ bool
|
||||
pwdgrp::parse_passwd ()
|
||||
{
|
||||
# define res (*passwd_buf)[curr_lines]
|
||||
res.pw_name = next_str ();
|
||||
res.pw_passwd = next_str ();
|
||||
|
||||
if (res.pw_name == res.pw_passwd)
|
||||
return false;
|
||||
|
||||
res.pw_name = next_str (':');
|
||||
res.pw_passwd = next_str (':');
|
||||
char *p = raw_ptr ();
|
||||
(void) next_num (res.pw_uid);
|
||||
if (p == raw_ptr ())
|
||||
return false; /* parsing did not advance. line is garbage */
|
||||
(void) next_num (res.pw_gid);
|
||||
res.pw_comment = NULL;
|
||||
res.pw_gecos = next_str ();
|
||||
res.pw_dir = next_str ();
|
||||
res.pw_shell = next_str ();
|
||||
res.pw_gecos = next_str (':');
|
||||
res.pw_dir = next_str (':');
|
||||
res.pw_shell = next_str (':');
|
||||
return true;
|
||||
# undef res
|
||||
}
|
||||
|
Reference in New Issue
Block a user