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

From: Adrian Bunk
Date: Sat Oct 27 2007 - 10:19:59 EST


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

Signed-off-by: Adrian Bunk <bunk@xxxxxxxxxx>

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

-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/