summaryrefslogtreecommitdiff
path: root/misc
diff options
context:
space:
mode:
authorJakub Jelinek <jakub@redhat.com>2007-01-12 17:20:09 +0000
committerJakub Jelinek <jakub@redhat.com>2007-01-12 17:20:09 +0000
commit4570029c28345fa7e35f5b0250a6747b9a41019e (patch)
tree642b1d11a9627b4cb0e64432447f2a7df20e1d67 /misc
parentb6c657f557a6416b408d8fb178aaf856aa367661 (diff)
* misc/mntent_r.c (__hasmntopt): Check p[optlen] even when p == rest.
Start searching for next comma at p rather than rest. * misc/Makefile (tests): Add tst-mntent2. * misc/tst-mntent2.c: New test.
Diffstat (limited to 'misc')
-rw-r--r--misc/Makefile2
-rw-r--r--misc/mntent_r.c12
2 files changed, 6 insertions, 8 deletions
diff --git a/misc/Makefile b/misc/Makefile
index f9ad0b76fc..9eac1b6275 100644
--- a/misc/Makefile
+++ b/misc/Makefile
@@ -78,7 +78,7 @@ endif
gpl2lgpl := error.c error.h
tests := tst-dirname tst-tsearch tst-fdset tst-efgcvt tst-mntent tst-hsearch \
- tst-error1 tst-pselect tst-insremque
+ tst-error1 tst-pselect tst-insremque tst-mntent2
ifeq (no,$(cross-compiling))
tests: $(objpfx)tst-error1-mem
endif
diff --git a/misc/mntent_r.c b/misc/mntent_r.c
index 1476c86ee2..829750b395 100644
--- a/misc/mntent_r.c
+++ b/misc/mntent_r.c
@@ -1,5 +1,6 @@
/* Utilities for reading/writing fstab, mtab, etc.
- Copyright (C) 1995-2000, 2001, 2002, 2003 Free Software Foundation, Inc.
+ Copyright (C) 1995-2000, 2001, 2002, 2003, 2006
+ Free Software Foundation, Inc.
This file is part of the GNU C Library.
The GNU C Library is free software; you can redistribute it and/or
@@ -278,14 +279,11 @@ __hasmntopt (const struct mntent *mnt, const char *opt)
while ((p = strstr (rest, opt)) != NULL)
{
- if (p == rest
- || (p[-1] == ','
- && (p[optlen] == '\0' ||
- p[optlen] == '=' ||
- p[optlen] == ',')))
+ if ((p == rest || p[-1] == ',')
+ && (p[optlen] == '\0' || p[optlen] == '=' || p[optlen] == ','))
return p;
- rest = strchr (rest, ',');
+ rest = strchr (p, ',');
if (rest == NULL)
break;
++rest;