Skip to contentSkip to conversation

jffs2_acl_count() tests < 0 on unsigned

PATCH In review [email protected] 1 participant 1 message Mar 4, 2009

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 15/15 jffs2_acl_count() tests < 0 on unsigned

From: Roel Kluin <[email protected]>

size_t s is unsigned and cannot be less than 0.

---

 fs/jffs2/acl.c |    4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
fs/jffs2/acl.c renamed from fs/jffs2/acl.c~jffs2_acl_count-tests-0-on-unsigned +2 -2
diff -puN fs/jffs2/acl.c~jffs2_acl_count-tests-0-on-unsigned fs/jffs2/acl.c
@@ -38,12 +38,12 @@ static int jffs2_acl_count(size_t size)
 	size_t s;
 
 	size -= sizeof(struct jffs2_acl_header);
-	s = size - 4 * sizeof(struct jffs2_acl_entry_short);
-	if (s < 0) {
+	if (size < 4 * sizeof(struct jffs2_acl_entry_short)) {
 		if (size % sizeof(struct jffs2_acl_entry_short))
 			return -1;
 		return size / sizeof(struct jffs2_acl_entry_short);
 	} else {
+		s = size - 4 * sizeof(struct jffs2_acl_entry_short);
 		if (s % sizeof(struct jffs2_acl_entry))
 			return -1;
 		return s / sizeof(struct jffs2_acl_entry) + 4;

_