Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

[JFFS2] jffs2_acl_count() tests < 0 on unsigned

size_t s is unsigned and cannot be less than 0.

Signed-off-by: Roel Kluin <roel.kluin@gmail.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: David Woodhouse <David.Woodhouse@intel.com>

authored by

Roel Kluin and committed by
David Woodhouse
fc371a25 a4b6d516

+2 -2
+2 -2
fs/jffs2/acl.c
··· 38 38 size_t s; 39 39 40 40 size -= sizeof(struct jffs2_acl_header); 41 - s = size - 4 * sizeof(struct jffs2_acl_entry_short); 42 - if (s < 0) { 41 + if (size < 4 * sizeof(struct jffs2_acl_entry_short)) { 43 42 if (size % sizeof(struct jffs2_acl_entry_short)) 44 43 return -1; 45 44 return size / sizeof(struct jffs2_acl_entry_short); 46 45 } else { 46 + s = size - 4 * sizeof(struct jffs2_acl_entry_short); 47 47 if (s % sizeof(struct jffs2_acl_entry)) 48 48 return -1; 49 49 return s / sizeof(struct jffs2_acl_entry) + 4;