]> git.neil.brown.name Git - LaFS.git/commitdiff
stateblock: fix range check on maxsnapshot
authorNeilBrown <neilb@suse.de>
Fri, 4 Mar 2011 01:47:31 +0000 (12:47 +1100)
committerNeilBrown <neilb@suse.de>
Fri, 4 Mar 2011 01:47:31 +0000 (12:47 +1100)
Signed-off-by: NeilBrown <neilb@suse.de>
super.c

diff --git a/super.c b/super.c
index 574952c05ed9d119c43e618222c3c81953ce71ce..53ca54272d9b37548b39e637758774ce06c65ef4 100644 (file)
--- a/super.c
+++ b/super.c
@@ -199,9 +199,10 @@ valid_stateblock(struct lafs_state *st, struct lafs_dev *dv)
 
        if (memcmp(st->uuid, dv->uuid, 16))
                return 0;
-       /* FIXME cannot quite be that big! */
-       if (le32_to_cpu(st->maxsnapshot) > (1<<(dv->statebits-3)))
-               return 0;
+
+       if (sizeof(*st) + le32_to_cpu(st->maxsnapshot) * 8
+           > (1<<dv->statebits))
+               return 0;
 
        return 1;
 }