autofs4: use memchr() in invalid_string()

Previous message: [thread] [date] [author]
Next message: [thread] [date] [author]
From: Linux Kernel Mailing List
Date: Tuesday, April 21, 2009 - 2:59 pm

Gitweb:     http://git.kernel.org/linus/3eac8778a237d83a1e553eba0c6f4fd4b39eeec0
Commit:     3eac8778a237d83a1e553eba0c6f4fd4b39eeec0
Parent:     66672fefaa91802fec51c3fe0cc55bc9baea5a2d
Author:     Al Viro <viro@zeniv.linux.org.uk>
AuthorDate: Tue Apr 7 11:12:46 2009 -0400
Committer:  Al Viro <viro@zeniv.linux.org.uk>
CommitDate: Mon Apr 20 23:02:50 2009 -0400

    autofs4: use memchr() in invalid_string()
    
    Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
---
 fs/autofs4/dev-ioctl.c |   10 ++++------
 1 files changed, 4 insertions(+), 6 deletions(-)

diff --git a/fs/autofs4/dev-ioctl.c b/fs/autofs4/dev-ioctl.c
index 463f798..84168c0 100644
--- a/fs/autofs4/dev-ioctl.c
+++ b/fs/autofs4/dev-ioctl.c
@@ -54,11 +54,10 @@ static int check_name(const char *name)
  * Check a string doesn't overrun the chunk of
  * memory we copied from user land.
  */
-static int invalid_str(char *str, void *end)
+static int invalid_str(char *str, size_t size)
 {
-	while ((void *) str <= end)
-		if (!*str++)
-			return 0;
+	if (memchr(str, 0, size))
+		return 0;
 	return -EINVAL;
 }
 
@@ -138,8 +137,7 @@ static int validate_dev_ioctl(int cmd, struct autofs_dev_ioctl *param)
 	}
 
 	if (param->size > sizeof(*param)) {
-		err = invalid_str(param->path,
-				 (void *) ((size_t) param + param->size));
+		err = invalid_str(param->path, param->size - sizeof(*param));
 		if (err) {
 			AUTOFS_WARN(
 			  "path string terminator missing for cmd(0x%08x)",
--
To unsubscribe from this list: send the line "unsubscribe git-commits-head" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Previous message: [thread] [date] [author]
Next message: [thread] [date] [author]

Messages in current thread:
autofs4: use memchr() in invalid_string(), Linux Kernel Mailing ..., (Tue Apr 21, 2:59 pm)