aboutsummaryrefslogtreecommitdiff
path: root/misc/mntent_r.c
diff options
context:
space:
mode:
authorVladimir A. Nazarenko <naszar@ya.ru>2015-01-06 19:19:44 -0800
committerH.J. Lu <hjl.tools@gmail.com>2015-01-06 19:51:01 -0800
commitfb87ee96d7dd0714d52004e4676629f8d9db732f (patch)
tree650a8563ae0ea966709d998aeb4391f81df4b87f /misc/mntent_r.c
parent01238691bb03f0110455b663439eecf9a58c8f83 (diff)
downloadglibc-fb87ee96d7dd0714d52004e4676629f8d9db732f.tar
glibc-fb87ee96d7dd0714d52004e4676629f8d9db732f.tar.gz
glibc-fb87ee96d7dd0714d52004e4676629f8d9db732f.tar.bz2
glibc-fb87ee96d7dd0714d52004e4676629f8d9db732f.zip
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.
Diffstat (limited to 'misc/mntent_r.c')
-rw-r--r--misc/mntent_r.c6
1 files changed, 5 insertions, 1 deletions
diff --git a/misc/mntent_r.c b/misc/mntent_r.c
index 152a9a2ea5..615987347a 100644
--- a/misc/mntent_r.c
+++ b/misc/mntent_r.c
@@ -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. */