mirror of
https://github.com/freebsd/freebsd-src.git
synced 2024-12-03 14:48:57 +00:00
(pw_copy): Handle the case of a malformed line in master.passwd
(copy it silently, do not dereference NULL pointer). PR: bin/102848 Reviewed by: security-officer (cperciva) MFC after: 1 week
This commit is contained in:
parent
592777f6b6
commit
71219ddbd1
Notes:
svn2git
2020-12-20 02:59:44 +00:00
svn path=/head/; revision=161997
@ -481,13 +481,22 @@ pw_copy(int ffd, int tfd, const struct passwd *pw, struct passwd *old_pw)
|
||||
}
|
||||
|
||||
/* is it the one we're looking for? */
|
||||
|
||||
t = *q;
|
||||
*q = '\0';
|
||||
|
||||
fpw = pw_scan(r, PWSCAN_MASTER);
|
||||
|
||||
/*
|
||||
* fpw is either the struct password for the current line,
|
||||
* or NULL if the line is malformed.
|
||||
*/
|
||||
|
||||
*q = t;
|
||||
if (strcmp(fpw->pw_name, pw->pw_name) != 0) {
|
||||
if (fpw == NULL || strcmp(fpw->pw_name, pw->pw_name) != 0) {
|
||||
/* nope */
|
||||
free(fpw);
|
||||
if (fpw != NULL)
|
||||
free(fpw);
|
||||
if (write(tfd, p, q - p + 1) != q - p + 1)
|
||||
goto err;
|
||||
++q;
|
||||
|
Loading…
Reference in New Issue
Block a user