lkml.org 
[lkml]   [2012]   [Mar]   [2]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
SubjectRE: Resend [PATCH] netfilter: Fix copy_to_user too small size parametre.
Date
From

> - if (copy_to_user(hlp, m->u.match->name,
> EBT_FUNCTION_MAXNAMELEN))
> + char name[EBT_FUNCTION_MAXNAMELEN] = {};
> +
> + strncpy(name, m->u.match->name, sizeof(name));
> + if (copy_to_user(hlp, name, EBT_FUNCTION_MAXNAMELEN))
> return -EFAULT;

strncpy() is very rarely the function you are looking for.
In this case it MIGHT be right (since you do a fixed size
copy_to_user).
OTOH there is no need to also initialise name[].
And it isn't entirely clear whether the application
is allowed to be given a non-terminated string.

David




\
 
 \ /
  Last update: 2012-03-02 10:09    [from the cache]
©2003-2014 Jasper Spaans. Advertise on this site