Re: [RFC][CFLART] ipmi procfs bogosity

From: viro
Date: Thu Sep 01 2005 - 14:32:20 EST


On Thu, Sep 01, 2005 at 11:41:42AM -0500, Corey Minyard wrote:
> Indeed, this function is badly written. In rewriting, I couldn't find a
> nice function for reading integers from userspace, and the proc_dointvec
> stuff didn't seem terribly suitable. So I wrote my own general
> function, which I can move someplace else if someone likes. Patch is
> attached. It should not affect correct usage of this file.

Eeeek... Much, _much_ simpler approach would be to have

char buf[10];
if (count > 9)
return -EINVAL;
if (copy_from_user(buf, buffer, count))
return -EFAULT;
buf[count] = '\0';
/* use sscanf() or anything normal */

Would that change behaviour in any cases you care about?
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/