Blame SOURCES/autofs-5.0.8-fix-options-compare.patch

306fa1
autofs-5.0.8 - fix options compare
306fa1
306fa1
From: Ian Kent <raven@themaw.net>
306fa1
306fa1
When checking for options in mount locations incorrect matches
306fa1
can occur when the length of the option string is not also used
306fa1
for the check.
306fa1
---
306fa1
 CHANGELOG              |    1 +
306fa1
 include/automount.h    |    1 +
306fa1
 lib/cat_path.c         |    9 +++++++++
306fa1
 modules/mount_autofs.c |   12 ++++++------
306fa1
 modules/mount_bind.c   |    2 +-
306fa1
 modules/mount_ext2.c   |    2 +-
306fa1
 modules/mount_nfs.c    |   34 +++++++++++++++++-----------------
306fa1
 modules/parse_sun.c    |   20 ++++++++++----------
306fa1
 8 files changed, 46 insertions(+), 35 deletions(-)
306fa1
306fa1
--- autofs-5.0.7.orig/CHANGELOG
306fa1
+++ autofs-5.0.7/CHANGELOG
306fa1
@@ -73,6 +73,7 @@
306fa1
 - fix negative status being reset on map read.
306fa1
 - fix fix negative status being reset on map read.
306fa1
 - check for non existent negative entries in lookup_ghost().
306fa1
+- fix options compare.
306fa1
 
306fa1
 25/07/2012 autofs-5.0.7
306fa1
 =======================
306fa1
--- autofs-5.0.7.orig/include/automount.h
306fa1
+++ autofs-5.0.7/include/automount.h
306fa1
@@ -335,6 +335,7 @@ size_t _strlen(const char *str, size_t m
306fa1
 int cat_path(char *buf, size_t len, const char *dir, const char *base);
306fa1
 int ncat_path(char *buf, size_t len,
306fa1
               const char *dir, const char *base, size_t blen);
306fa1
+int _strncmp(const char *s1, const char *s2, size_t n);
306fa1
 
306fa1
 /* Core automount definitions */
306fa1
 
306fa1
--- autofs-5.0.7.orig/lib/cat_path.c
306fa1
+++ autofs-5.0.7/lib/cat_path.c
306fa1
@@ -87,3 +87,12 @@ int ncat_path(char *buf, size_t len,
306fa1
 	return cat_path(buf, len, dir, name);
306fa1
 }
306fa1
 
306fa1
+/* Compare first n bytes of s1 and s2 and that n == strlen(s1) */
306fa1
+int _strncmp(const char *s1, const char *s2, size_t n)
306fa1
+{
306fa1
+	size_t len = strlen(s1);
306fa1
+
306fa1
+	if (n != len)
306fa1
+		return n - len;
306fa1
+	return strncmp(s1, s2, n);
306fa1
+}
306fa1
--- autofs-5.0.7.orig/modules/mount_autofs.c
306fa1
+++ autofs-5.0.7/modules/mount_autofs.c
306fa1
@@ -116,17 +116,17 @@ int mount_mount(struct autofs_point *ap,
306fa1
 			while (*comma != '\0' && *comma != ',')
306fa1
 				comma++;
306fa1
 
306fa1
-			if (strncmp(cp, "nobrowse", 8) == 0)
306fa1
+			if (_strncmp(cp, "nobrowse", 8) == 0)
306fa1
 				ghost = 0;
306fa1
-			else if (strncmp(cp, "nobind", 6) == 0)
306fa1
+			else if (_strncmp(cp, "nobind", 6) == 0)
306fa1
 				nobind = 1;
306fa1
-			else if (strncmp(cp, "browse", 6) == 0)
306fa1
+			else if (_strncmp(cp, "browse", 6) == 0)
306fa1
 				ghost = 1;
306fa1
-			else if (strncmp(cp, "symlink", 7) == 0)
306fa1
+			else if (_strncmp(cp, "symlink", 7) == 0)
306fa1
 				symlnk = 1;
306fa1
-			else if (strncmp(cp, "hosts", 5) == 0)
306fa1
+			else if (_strncmp(cp, "hosts", 5) == 0)
306fa1
 				hosts = 1;
306fa1
-			else if (strncmp(cp, "timeout=", 8) == 0) {
306fa1
+			else if (_strncmp(cp, "timeout=", 8) == 0) {
306fa1
 				char *val = strchr(cp, '=');
306fa1
 				unsigned tout;
306fa1
 				if (val) {
306fa1
--- autofs-5.0.7.orig/modules/mount_bind.c
306fa1
+++ autofs-5.0.7/modules/mount_bind.c
306fa1
@@ -107,7 +107,7 @@ int mount_mount(struct autofs_point *ap,
306fa1
 				end--;
306fa1
 
306fa1
 			o_len = end - cp + 1;
306fa1
-			if (strncmp("symlink", cp, o_len) == 0)
306fa1
+			if (_strncmp("symlink", cp, o_len) == 0)
306fa1
 				symlnk = 1;
306fa1
 		}
306fa1
 	}
306fa1
--- autofs-5.0.7.orig/modules/mount_ext2.c
306fa1
+++ autofs-5.0.7/modules/mount_ext2.c
306fa1
@@ -77,7 +77,7 @@ int mount_mount(struct autofs_point *ap,
306fa1
 
306fa1
 	if (options && options[0]) {
306fa1
 		for (p = options; (p1 = strchr(p, ',')); p = p1)
306fa1
-			if (!strncmp(p, "ro", p1 - p) && ++p1 - p == sizeof("ro"))
306fa1
+			if (!_strncmp(p, "ro", p1 - p) && ++p1 - p == sizeof("ro"))
306fa1
 				ro = 1;
306fa1
 		if (!strcmp(p, "ro"))
306fa1
 			ro = 1;
306fa1
--- autofs-5.0.7.orig/modules/mount_nfs.c
306fa1
+++ autofs-5.0.7/modules/mount_nfs.c
306fa1
@@ -126,32 +126,32 @@ int mount_mount(struct autofs_point *ap,
306fa1
 
306fa1
 			o_len = end - cp + 1;
306fa1
 
306fa1
-			if (strncmp("proto=rdma", cp, o_len) == 0 ||
306fa1
-				   strncmp("rdma", cp, o_len) == 0)
306fa1
+			if (_strncmp("proto=rdma", cp, o_len) == 0 ||
306fa1
+				   _strncmp("rdma", cp, o_len) == 0)
306fa1
 				rdma = 1;
306fa1
 
306fa1
-			if (strncmp("nosymlink", cp, o_len) == 0) {
306fa1
+			if (_strncmp("nosymlink", cp, o_len) == 0) {
306fa1
 				warn(ap->logopt, MODPREFIX
306fa1
 				     "the \"nosymlink\" option is depricated "
306fa1
 				     "and will soon be removed, "
306fa1
 				     "use the \"nobind\" option instead");
306fa1
 				nosymlink = 1;
306fa1
-			} else if (strncmp("nobind", cp, o_len) == 0) {
306fa1
+			} else if (_strncmp("nobind", cp, o_len) == 0) {
306fa1
 				nobind = 1;
306fa1
-			} else if (strncmp("no-use-weight-only", cp, o_len) == 0) {
306fa1
+			} else if (_strncmp("no-use-weight-only", cp, o_len) == 0) {
306fa1
 				flags &= ~MOUNT_FLAG_USE_WEIGHT_ONLY;
306fa1
-			} else if (strncmp("use-weight-only", cp, o_len) == 0) {
306fa1
+			} else if (_strncmp("use-weight-only", cp, o_len) == 0) {
306fa1
 				flags |= MOUNT_FLAG_USE_WEIGHT_ONLY;
306fa1
 			} else {
306fa1
-				if (strncmp("vers=4", cp, o_len) == 0 ||
306fa1
-				    strncmp("nfsvers=4", cp, o_len) == 0)
306fa1
+				if (_strncmp("vers=4", cp, o_len) == 0 ||
306fa1
+				    _strncmp("nfsvers=4", cp, o_len) == 0)
306fa1
 					vers = NFS4_VERS_MASK | TCP_SUPPORTED;
306fa1
-				else if (strncmp("vers=3", cp, o_len) == 0 ||
306fa1
-					 strncmp("nfsvers=3", cp, o_len) == 0) {
306fa1
+				else if (_strncmp("vers=3", cp, o_len) == 0 ||
306fa1
+					 _strncmp("nfsvers=3", cp, o_len) == 0) {
306fa1
 					vers &= ~(NFS4_VERS_MASK | NFS_VERS_MASK);
306fa1
 					vers |= NFS3_REQUESTED;
306fa1
-				} else if (strncmp("vers=2", cp, o_len) == 0 ||
306fa1
-					 strncmp("nfsvers=2", cp, o_len) == 0) {
306fa1
+				} else if (_strncmp("vers=2", cp, o_len) == 0 ||
306fa1
+					 _strncmp("nfsvers=2", cp, o_len) == 0) {
306fa1
 					vers &= ~(NFS4_VERS_MASK | NFS_VERS_MASK);
306fa1
 					vers |= NFS2_REQUESTED;
306fa1
 				} else if (strstr(cp, "port=") == cp &&
306fa1
@@ -164,16 +164,16 @@ int mount_mount(struct autofs_point *ap,
306fa1
 					if (port < 0)
306fa1
 						port = 0;
306fa1
 					port_opt = cp;
306fa1
-				} else if (strncmp("proto=udp", cp, o_len) == 0 ||
306fa1
-					   strncmp("udp", cp, o_len) == 0) {
306fa1
+				} else if (_strncmp("proto=udp", cp, o_len) == 0 ||
306fa1
+					   _strncmp("udp", cp, o_len) == 0) {
306fa1
 					vers &= ~TCP_SUPPORTED;
306fa1
-				} else if (strncmp("proto=tcp", cp, o_len) == 0 ||
306fa1
-					   strncmp("tcp", cp, o_len) == 0) {
306fa1
+				} else if (_strncmp("proto=tcp", cp, o_len) == 0 ||
306fa1
+					   _strncmp("tcp", cp, o_len) == 0) {
306fa1
 					vers &= ~UDP_SUPPORTED;
306fa1
 				}
306fa1
 				/* Check for options that also make sense
306fa1
 				   with bind mounts */
306fa1
-				else if (strncmp("ro", cp, o_len) == 0)
306fa1
+				else if (_strncmp("ro", cp, o_len) == 0)
306fa1
 					ro = 1;
306fa1
 				/* and jump over trailing white space */
306fa1
 				memcpy(nfsp, cp, comma - cp + 1);
306fa1
--- autofs-5.0.7.orig/modules/parse_sun.c
306fa1
+++ autofs-5.0.7/modules/parse_sun.c
306fa1
@@ -549,29 +549,29 @@ static int sun_mount(struct autofs_point
306fa1
 			while (*comma != '\0' && *comma != ',')
306fa1
 				comma++;
306fa1
 
306fa1
-			if (strncmp("fstype=", cp, 7) == 0) {
306fa1
+			if (_strncmp("fstype=", cp, 7) == 0) {
306fa1
 				int typelen = comma - (cp + 7);
306fa1
 				fstype = alloca(typelen + 1);
306fa1
 				memcpy(fstype, cp + 7, typelen);
306fa1
 				fstype[typelen] = '\0';
306fa1
-			} else if (strncmp("nonstrict", cp, 9) == 0) {
306fa1
+			} else if (_strncmp("nonstrict", cp, 9) == 0) {
306fa1
 				nonstrict = 1;
306fa1
-			} else if (strncmp("strict", cp, 6) == 0) {
306fa1
+			} else if (_strncmp("strict", cp, 6) == 0) {
306fa1
 				nonstrict = 0;
306fa1
-			} else if (strncmp("nobrowse", cp, 8) == 0 ||
306fa1
-				   strncmp("browse", cp, 6) == 0 ||
306fa1
-				   strncmp("timeout=", cp, 8) == 0) {
306fa1
+			} else if (_strncmp("nobrowse", cp, 8) == 0 ||
306fa1
+				   _strncmp("browse", cp, 6) == 0 ||
306fa1
+				   _strncmp("timeout=", cp, 8) == 0) {
306fa1
 				if (strcmp(fstype, "autofs") == 0 ||
306fa1
 				    strstr(cp, "fstype=autofs")) {
306fa1
 					memcpy(np, cp, comma - cp + 1);
306fa1
 					np += comma - cp + 1;
306fa1
 				}
306fa1
-			} else if (strncmp("no-use-weight-only", cp, 18) == 0) {
306fa1
+			} else if (_strncmp("no-use-weight-only", cp, 18) == 0) {
306fa1
 				use_weight_only = -1;
306fa1
-			} else if (strncmp("use-weight-only", cp, 15) == 0) {
306fa1
+			} else if (_strncmp("use-weight-only", cp, 15) == 0) {
306fa1
 				use_weight_only = MOUNT_FLAG_USE_WEIGHT_ONLY;
306fa1
-			} else if (strncmp("bg", cp, 2) == 0 ||
306fa1
-				   strncmp("nofg", cp, 4) == 0) {
306fa1
+			} else if (_strncmp("bg", cp, 2) == 0 ||
306fa1
+				   _strncmp("nofg", cp, 4) == 0) {
306fa1
 				continue;
306fa1
 			} else {
306fa1
 				memcpy(np, cp, comma - cp + 1);