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

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