DragonFly BSD
DragonFly bugs List (threaded) for 2004-09
[Date Prev][Date Next]  [Thread Prev][Thread Next]  [Date Index][Thread Index]

Re: typo in getmntopts.c?


From: Matthew Dillon <dillon@xxxxxxxxxxxxxxxxxxxx>
Date: Fri, 3 Sep 2004 21:35:06 -0700 (PDT)

:mount(8) currently allows e.g. "mount -u -o rough /tmp" to remount /tmp
:read-only. This seems to be because of a typo in getmntopts.c which could 
:be fixed as follows:
:
:Index: sbin/mount/getmntopts.c
:===================================================================
:RCS file: /home/dcvs/src/sbin/mount/getmntopts.c,v
:retrieving revision 1.3
:diff -u -r1.3 getmntopts.c
:--- sbin/mount/getmntopts.c	28 Sep 2003 14:39:18 -0000	1.3
:+++ sbin/mount/getmntopts.c	3 Sep 2004 20:56:18 -0000
:@@ -81,8 +81,8 @@
: 		for (m = m0; m->m_option != NULL; ++m) {
: 			len = strlen(m->m_option);
: 			if (strncasecmp(opt, m->m_option, len) == 0)
:-				if (   m->m_option[len]	== '\0'
:-				    || m->m_option[len]	== '='
:+				if (   opt[len]	== '\0'
:+				    || opt[len]	== '='
: 				   )
: 				break;
: 		}
:
:Regards,
:Johannes

    Hmm.  Well, that is certainly a bug, but the fix is a little different
    then what you have because the opt[] is already truncated at the first
    '=' just above that section.

    I think what we want is a standard unbounded case insensitive string
    compare, see below.  If nobody sees anything wrong with this change
    I will commit it on monday.

					-Matt


Index: getmntopts.c
===================================================================
RCS file: /cvs/src/sbin/mount/getmntopts.c,v
retrieving revision 1.3
diff -u -r1.3 getmntopts.c
--- getmntopts.c	28 Sep 2003 14:39:18 -0000	1.3
+++ getmntopts.c	4 Sep 2004 04:32:36 -0000
@@ -53,7 +53,7 @@
            int *altflagp)
 {
 	const struct mntopt *m;
-	int negative, len;
+	int negative;
 	char *opt, *optbuf, *p;
 	int *thisflagp;
 
@@ -79,11 +79,7 @@
 
 		/* Scan option table. */
 		for (m = m0; m->m_option != NULL; ++m) {
-			len = strlen(m->m_option);
-			if (strncasecmp(opt, m->m_option, len) == 0)
-				if (   m->m_option[len]	== '\0'
-				    || m->m_option[len]	== '='
-				   )
+			if (strcasecmp(opt, m->m_option) == 0)
 				break;
 		}
 



[Date Prev][Date Next]  [Thread Prev][Thread Next]  [Date Index][Thread Index]