[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <20081215215706.7707315c.akpm@linux-foundation.org>
Date: Mon, 15 Dec 2008 21:57:06 -0800
From: Andrew Morton <akpm@...ux-foundation.org>
To: Cyrill Gorcunov <gorcunov@...il.com>
Cc: Alexander Viro <aviro@...hat.com>,
LKML <linux-kernel@...r.kernel.org>
Subject: Re: [PATCH] fs - fix name overwrite in __register_chrdev_region
On Sun, 14 Dec 2008 00:49:11 +0300 Cyrill Gorcunov <gorcunov@...il.com> wrote:
> It's possible to register chdev with a name size
> exactly the same as was allocated in structure.
> It seems it was not intedned behaviour.
>
> At least chrdev_show does not like it.
>
> Signed-off-by: Cyrill Gorcunov <gorcunov@...il.com>
> ---
>
> fs/char_dev.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> Index: linux-2.6.git/fs/char_dev.c
> ===================================================================
> --- linux-2.6.git.orig/fs/char_dev.c
> +++ linux-2.6.git/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);
> + strncpy(cd->name, name, sizeof(cd->name) - 1);
>
> i = major_to_index(major);
>
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);
_
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
Powered by blists - more mailing lists