mirror of
git://git.musl-libc.org/musl
synced 2025-03-06 20:48:29 +01:00
make getmntent_r discard long lines when it returns error, not seek back
seeking back can be performed by the caller, but if the caller doesn't expect it, it will result in an infinite loop of failures.
This commit is contained in:
parent
9cee9307e3
commit
ede5ae7b0b
1 changed files with 1 additions and 2 deletions
|
@ -25,8 +25,7 @@ struct mntent *getmntent_r(FILE *f, struct mntent *mnt, char *linebuf, int bufle
|
|||
fgets(linebuf, buflen, f);
|
||||
if (feof(f) || ferror(f)) return 0;
|
||||
if (!strchr(linebuf, '\n')) {
|
||||
if (fseeko(f, -(off_t)strlen(linebuf), SEEK_CUR))
|
||||
fscanf(f, "%*[^\n]%*[\n]");
|
||||
fscanf(f, "%*[^\n]%*[\n]");
|
||||
errno = ERANGE;
|
||||
return 0;
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue