Skip to content

Commit

Permalink
autofs4: use memchr() in invalid_string()
Browse files Browse the repository at this point in the history
Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
  • Loading branch information
Al Viro committed Apr 21, 2009
1 parent 66672fe commit 3eac877
Showing 1 changed file with 4 additions and 6 deletions.
10 changes: 4 additions & 6 deletions fs/autofs4/dev-ioctl.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

Expand Down Expand Up @@ -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)",
Expand Down

0 comments on commit 3eac877

Please sign in to comment.