diff options
| author | Thomas Quinot <thomas@FreeBSD.org> | 2006-09-04 15:09:21 +0000 | 
|---|---|---|
| committer | Thomas Quinot <thomas@FreeBSD.org> | 2006-09-04 15:09:21 +0000 | 
| commit | 71219ddbd16cc509fa0b0613f0c7d4ca79dfc84b (patch) | |
| tree | 62782ca016f1ee462f7063433eedf18a5d7bf951 /lib/libutil/pw_util.c | |
| parent | 592777f6b66c22ed15bbf81d98139ce91950ad80 (diff) | |
Notes
Diffstat (limited to 'lib/libutil/pw_util.c')
| -rw-r--r-- | lib/libutil/pw_util.c | 13 | 
1 files changed, 11 insertions, 2 deletions
diff --git a/lib/libutil/pw_util.c b/lib/libutil/pw_util.c index 90c9d72f4f93..6d372c07c0a2 100644 --- a/lib/libutil/pw_util.c +++ b/lib/libutil/pw_util.c @@ -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;  | 
