lkml.org 
[lkml]   [2006]   [Feb]   [16]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
SubjectRe: [PATCH 0/2] strndup_user, v2
From
Date
On Iau, 2006-02-16 at 00:56 -0300, Davi Arnaut wrote:
> strlen_user returns _0_ on exception. If you don't belive me,
> kernel/module.c or arch/x86_64/lib/usercopy.c are a good starting
> point.

My fault, I forgot that someone made strnlen_user weird, the rest looks
correct.

In fact drivers/s390/char/keyboard.c like me appears to have a rather
confused understanding of the return code, but can now make good use of
your strndup_user function.

len = strnlen_user(u_kbs->kb_string,
sizeof(u_kbs->kb_string) - 1);
if (!len)
return -EFAULT;
if (len > sizeof(u_kbs->kb_string) - 1)
return -EINVAL;
p = kmalloc(len + 1, GFP_KERNEL);
if (!p)
return -ENOMEM;
if (copy_from_user(p, u_kbs->kb_string, len)) {
kfree(p);
return -EFAULT;
}
p[len] = 0;


Alan

-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/

\
 
 \ /
  Last update: 2006-02-16 15:43    [W:0.094 / U:0.204 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site