[2.6 patch] fs/afs/vlocation.c: fix off-by-one

!MAILaRCHIVE_VOTE_RePLACE
Previous message: [thread] [date] [author]
Next message: [thread] [date] [author]
To: David Howells <dhowells@...>
Cc: <linux-kernel@...>
Date: Saturday, October 27, 2007 - 10:19 am

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')

-
Previous message: [thread] [date] [author]
Next message: [thread] [date] [author]

Messages in current thread:
[2.6 patch] fs/afs/vlocation.c: fix off-by-one, Adrian Bunk, (Sat Oct 27, 10:19 am)
Re: [2.6 patch] fs/afs/vlocation.c: fix off-by-one, David Howells, (Mon Oct 29, 9:00 am)
Re: [2.6 patch] fs/afs/vlocation.c: fix off-by-one, Adrian Bunk, (Mon Oct 29, 11:24 am)
Re: [2.6 patch] fs/afs/vlocation.c: fix off-by-one, David Howells, (Mon Oct 29, 11:30 am)