1
0
mirror of https://sourceware.org/git/glibc.git synced 2025-07-30 22:43:12 +03:00

Fix incorrect mount table entry parsing in __getmntent_r

When mount entry contains only four fields and have more then one space or
tab at the and, mp.mnt_freq and mp.mnt_passno will be set to some specific
values as side effect from parsing of previus mount entry. It is because
sscanf(""," %d %d ", &a, &b) returns -1, but this case is unprocessed.
Values of mp.mnt_freq and  mp.mnt_passno stays unchanged. This patch is
attempt to fix described issue by removing trailing tabs and spaces.
This commit is contained in:
Vladimir A. Nazarenko
2015-01-06 19:19:44 -08:00
committed by H.J. Lu
parent 01238691bb
commit fb87ee96d7
4 changed files with 41 additions and 9 deletions

View File

@ -135,7 +135,11 @@ __getmntent_r (FILE *stream, struct mntent *mp, char *buffer, int bufsiz)
end_ptr = strchr (buffer, '\n');
if (end_ptr != NULL) /* chop newline */
*end_ptr = '\0';
{
while (end_ptr[-1] == ' ' || end_ptr[-1] == '\t')
end_ptr--;
*end_ptr = '\0';
}
else
{
/* Not the whole line was read. Do it now but forget it. */