dlm: fix dlm_dir_lookup() handling of too long names
authorAl Viro <viro@zeniv.linux.org.uk>
Sat, 26 Jan 2008 05:03:59 +0000 (00:03 -0500)
committerDavid Teigland <teigland@redhat.com>
Mon, 4 Feb 2008 07:30:19 +0000 (01:30 -0600)
... those can happen and BUG() from DLM_ASSERT() in allocate_direntry() is
not a good way to handle them.

Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
Signed-off-by: David Teigland <teigland@redhat.com>
fs/dlm/dir.c

index 831050e..85defeb 100644 (file)
@@ -319,6 +319,9 @@ static int get_entry(struct dlm_ls *ls, int nodeid, char *name,
 
        write_unlock(&ls->ls_dirtbl[bucket].lock);
 
+       if (namelen > DLM_RESNAME_MAXLEN)
+               return -EINVAL;
+
        de = kzalloc(sizeof(struct dlm_direntry) + namelen, GFP_KERNEL);
        if (!de)
                return -ENOMEM;