David Howells <[email protected]> wrote:
>
> +#define key_get_type_from_user(type, _type, error) \
> +do { \
> + ret = strncpy_from_user(type, _type, sizeof(type)); \
> + if (ret < 0) \
> + goto error; \
> + \
> + if (ret == 0 || ret > sizeof(type) - 1) { \
> + ret = -EINVAL; \
> + goto error; \
> + } \
> + \
> + ret = -EPERM; \
> + if (type[0] == '.') \
> + goto error; \
> + \
> + type[31] = '\0'; \
> +} while(0)
> +
> +#define key_get_description_from_user(desc, _desc, dlen, error, error2) \
> +do { \
> + ret = -EFAULT; \
> + dlen = strnlen_user(_desc, PAGE_SIZE); \
> + if (dlen <= 0) \
> + goto error; \
> + \
> + ret = -EINVAL; \
> + if (dlen > PAGE_SIZE) \
> + goto error; \
> + \
> + ret = -ENOMEM; \
> + desc = kmalloc(dlen, GFP_KERNEL); \
> + if (!desc) \
> + goto error; \
> + \
> + ret = -EFAULT; \
> + if (copy_from_user(desc, _desc, dlen - 1) != 0) \
> + goto error2; \
> + \
> + desc[dlen - 1] = '\0'; \
> +} while(0)
ug. Well it's your code ;)
It should really parameterise `ret' too.
Are you sure you want to do this? From my reading, doing it with plain old
subroutines would work?
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
[Index of Archives]
[Kernel Newbies]
[Netfilter]
[Bugtraq]
[Photo]
[Stuff]
[Gimp]
[Yosemite News]
[MIPS Linux]
[ARM Linux]
[Linux Security]
[Linux RAID]
[Video 4 Linux]
[Linux for the blind]
[Linux Resources]