public inbox for linux-mtd@lists.infradead.org
 help / color / mirror / Atom feed
* [PATCH] jffs2_acl_count() tests < 0 on unsigned
@ 2009-03-01 20:35 Roel Kluin
  0 siblings, 0 replies; only message in thread
From: Roel Kluin @ 2009-03-01 20:35 UTC (permalink / raw)
  To: dwmw2; +Cc: Andrew Morton, linux-mtd

This patch wasn't tested in any way.
------------------------------>8-------------8<---------------------------------
size_t s is unsigned and cannot be less than 0.

Signed-off-by: Roel Kluin <roel.kluin@gmail.com>
---
diff --git a/fs/jffs2/acl.c b/fs/jffs2/acl.c
index d987137..6e63e8b 100644
--- a/fs/jffs2/acl.c
+++ b/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;

^ permalink raw reply related	[flat|nested] only message in thread

only message in thread, other threads:[~2009-03-01 20:35 UTC | newest]

Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2009-03-01 20:35 [PATCH] jffs2_acl_count() tests < 0 on unsigned Roel Kluin

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox