Re: [PATCH] fs - fix name overwrite in __register_chrdev_region

Cyrill Gorcunov
2008-12-16T06:45:40Z

On Tue, Dec 16, 2008 at 8:57 AM, Andrew Morton
<akpm@linux-foundation.org> wrote:
>
> OK.
>
> strlcpy() prodces a more pleasing result:
>
> --- a/fs/char_dev.c~fs-fix-name-overwrite-in-__register_chrdev_region
> +++ a/fs/char_dev.c
> @@ -120,7 +120,7 @@ __register_chrdev_region(unsigned int ma
> cd->major = major;
> cd->baseminor = baseminor;
> cd->minorct = minorct;
> - strncpy(cd->name,name, 64);
> + strlcpy(cd->name, name, sizeof(cd->name));
>
> i = major_to_index(major);
>
> _
>

Thanks, Andrew!