An error while reading the existing /etc/passwd should be properly
handled to avoid truncation due to a bad read.
Signed-off-by: Tobias Stoeckmann <tobias@stoeckmann.org>
/* Nothing in particular happened, copy input to output */
fputs(linebuf, fp);
}
+ if (!feof(pwf))
+ goto fail;
+ fclose(pwf); /* I don't think I want to know if this failed */
+ pwf = NULL;
/* xfmkstemp is too restrictive by default for passwd file */
if (fchmod(fileno(fp), 0644) < 0)
if (rc != 0)
goto fail;
- fclose(pwf); /* I don't think I want to know if this failed */
- pwf = NULL;
-
if (!found) {
errno = ENOENT; /* give me something better */
goto fail;