From patchwork Wed Mar 4 20:01:41 2009 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: [15/15] jffs2_acl_count() tests < 0 on unsigned Date: Wed, 04 Mar 2009 10:01:41 -0000 From: Andrew Morton X-Patchwork-Id: 24059 Message-Id: <200903042001.n24K1f2p028801@imap1.linux-foundation.org> To: dwmw2@infradead.org Cc: roel.kluin@gmail.com, akpm@linux-foundation.org, linux-mtd@lists.infradead.org From: Roel Kluin size_t s is unsigned and cannot be less than 0. Signed-off-by: Roel Kluin Cc: David Woodhouse Signed-off-by: Andrew Morton --- fs/jffs2/acl.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff -puN fs/jffs2/acl.c~jffs2_acl_count-tests-0-on-unsigned fs/jffs2/acl.c --- a/fs/jffs2/acl.c~jffs2_acl_count-tests-0-on-unsigned +++ a/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;