Skip to content

Commit

Permalink
autofs4: fix string validation check order
Browse files Browse the repository at this point in the history
In function validate_dev_ioctl() we check that the string we've been sent
is a valid path.  The function that does this check assumes the string is
NULL terminated but our NULL termination check isn't done until after this
call.  This patch changes the order of the check.

Signed-off-by: Ian Kent <[email protected]>
Acked-by: Jeff Moyer <[email protected]>
Signed-off-by: Andrew Morton <[email protected]>
Signed-off-by: Linus Torvalds <[email protected]>
  • Loading branch information
raven-au authored and torvalds committed Jan 6, 2009
1 parent a92daf6 commit bae8ec6
Showing 1 changed file with 7 additions and 6 deletions.
13 changes: 7 additions & 6 deletions fs/autofs4/dev-ioctl.c
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@ static inline void free_dev_ioctl(struct autofs_dev_ioctl *param)

/*
* Check sanity of parameter control fields and if a path is present
* check that it has a "/" and is terminated.
* check that it is terminated and contains at least one "/".
*/
static int validate_dev_ioctl(int cmd, struct autofs_dev_ioctl *param)
{
Expand All @@ -138,15 +138,16 @@ static int validate_dev_ioctl(int cmd, struct autofs_dev_ioctl *param)
}

if (param->size > sizeof(*param)) {
err = check_name(param->path);
err = invalid_str(param->path,
(void *) ((size_t) param + param->size));
if (err) {
AUTOFS_WARN("invalid path supplied for cmd(0x%08x)",
cmd);
AUTOFS_WARN(
"path string terminator missing for cmd(0x%08x)",
cmd);
goto out;
}

err = invalid_str(param->path,
(void *) ((size_t) param + param->size));
err = check_name(param->path);
if (err) {
AUTOFS_WARN("invalid path supplied for cmd(0x%08x)",
cmd);
Expand Down

0 comments on commit bae8ec6

Please sign in to comment.