public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* [2.6 patch] fs/afs/vlocation.c: fix off-by-one
@ 2007-10-27 14:19 Adrian Bunk
  2007-10-29 13:00 ` David Howells
  0 siblings, 1 reply; 4+ messages in thread
From: Adrian Bunk @ 2007-10-27 14:19 UTC (permalink / raw)
  To: David Howells; +Cc: linux-kernel

This patch fixes an off-by-one error spotted by the Coverity checker.

Signed-off-by: Adrian Bunk <bunk@kernel.org>

---
d88aac5aa6057a8d784934dc5035e9e853b16203 
diff --git a/fs/afs/vlocation.c b/fs/afs/vlocation.c
index 7b4bbe4..849fc31 100644
--- a/fs/afs/vlocation.c
+++ b/fs/afs/vlocation.c
@@ -376,19 +376,19 @@ struct afs_vlocation *afs_vlocation_lookup(struct afs_cell *cell,
 					   size_t namesz)
 {
 	struct afs_vlocation *vl;
 	int ret;
 
 	_enter("{%s},{%x},%*.*s,%zu",
 	       cell->name, key_serial(key),
 	       (int) namesz, (int) namesz, name, namesz);
 
-	if (namesz > sizeof(vl->vldb.name)) {
+	if (namesz >= sizeof(vl->vldb.name)) {
 		_leave(" = -ENAMETOOLONG");
 		return ERR_PTR(-ENAMETOOLONG);
 	}
 
 	/* see if we have an in-memory copy first */
 	down_write(&cell->vl_sem);
 	spin_lock(&cell->vl_lock);
 	list_for_each_entry(vl, &cell->vl_list, link) {
 		if (vl->vldb.name[namesz] != '\0')


^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: [2.6 patch] fs/afs/vlocation.c: fix off-by-one
  2007-10-27 14:19 [2.6 patch] fs/afs/vlocation.c: fix off-by-one Adrian Bunk
@ 2007-10-29 13:00 ` David Howells
  2007-10-29 15:24   ` Adrian Bunk
  0 siblings, 1 reply; 4+ messages in thread
From: David Howells @ 2007-10-29 13:00 UTC (permalink / raw)
  To: Adrian Bunk; +Cc: dhowells, linux-kernel

Adrian Bunk <bunk@kernel.org> wrote:

> This patch fixes an off-by-one error spotted by the Coverity checker.

NAK.

Why do you assume it's a NUL-terminated string?  It's not.  It's a fixed
length character array that gets padded out with NULs.

Look 9 lines further down in the file from the change you made.  You'll notice
it is using memcmp() not strcmp().

David

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [2.6 patch] fs/afs/vlocation.c: fix off-by-one
  2007-10-29 13:00 ` David Howells
@ 2007-10-29 15:24   ` Adrian Bunk
  2007-10-29 15:30     ` David Howells
  0 siblings, 1 reply; 4+ messages in thread
From: Adrian Bunk @ 2007-10-29 15:24 UTC (permalink / raw)
  To: David Howells; +Cc: linux-kernel

On Mon, Oct 29, 2007 at 01:00:26PM +0000, David Howells wrote:
> Adrian Bunk <bunk@kernel.org> wrote:
> 
> > This patch fixes an off-by-one error spotted by the Coverity checker.
> 
> NAK.
> 
> Why do you assume it's a NUL-terminated string?  It's not.  It's a fixed
> length character array that gets padded out with NULs.
> 
> Look 9 lines further down in the file from the change you made.  You'll notice
> it is using memcmp() not strcmp().

Check the last line of the patch I sent:
  if (vl->vldb.name[namesz] != '\0')

> David

cu
Adrian

-- 

       "Is there not promise of rain?" Ling Tan asked suddenly out
        of the darkness. There had been need of rain for many days.
       "Only a promise," Lao Er said.
                                       Pearl S. Buck - Dragon Seed


^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [2.6 patch] fs/afs/vlocation.c: fix off-by-one
  2007-10-29 15:24   ` Adrian Bunk
@ 2007-10-29 15:30     ` David Howells
  0 siblings, 0 replies; 4+ messages in thread
From: David Howells @ 2007-10-29 15:30 UTC (permalink / raw)
  To: Adrian Bunk; +Cc: dhowells, linux-kernel

Adrian Bunk <bunk@kernel.org> wrote:

> Check the last line of the patch I sent:
>   if (vl->vldb.name[namesz] != '\0')

Seems I forgotten some of what my own code does:-)

Actually, you're right.  I added in a gap for the NUL.  Okay, I retract my
NAK.  Consider it ACK'd instead.

David

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2007-10-29 15:31 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2007-10-27 14:19 [2.6 patch] fs/afs/vlocation.c: fix off-by-one Adrian Bunk
2007-10-29 13:00 ` David Howells
2007-10-29 15:24   ` Adrian Bunk
2007-10-29 15:30     ` David Howells

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox