Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 3eac8778 authored by Al Viro's avatar Al Viro
Browse files

autofs4: use memchr() in invalid_string()



Signed-off-by: default avatarAl Viro <viro@zeniv.linux.org.uk>
parent 66672fef
Loading
Loading
Loading
Loading
+4 −6
Original line number Diff line number Diff line
@@ -54,10 +54,9 @@ 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++)
	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)",