autofs4: use memchr() in invalid_string()
authorAl Viro <viro@zeniv.linux.org.uk>
Tue, 7 Apr 2009 15:12:46 +0000 (11:12 -0400)
committerAl Viro <viro@zeniv.linux.org.uk>
Tue, 21 Apr 2009 03:02:50 +0000 (23:02 -0400)
Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
fs/autofs4/dev-ioctl.c

index 463f798f71b3580e0ae23e560a8f886f8df521b4..84168c0dcc2d2aa76d7a45233fe7164959e34091 100644 (file)
@@ -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)",