]> www.infradead.org Git - mtd-utils.git/commit
mkfs.jffs2: fix integer underflow in jffs2_rtime_compress()
authorEnrico Scholz <enrico.scholz@sigma-chemnitz.de>
Thu, 24 Jun 2010 13:02:40 +0000 (15:02 +0200)
committerArtem Bityutskiy <Artem.Bityutskiy@nokia.com>
Sun, 18 Jul 2010 06:05:56 +0000 (09:05 +0300)
commite8457f16306ad6e2c8708275bf42b5dfff40fffd
tree79e85cbe35a5059f3e1a0ddd321fd633f678b041
parent5db0545e2858da5f79d6461544f94c88f6bf7af9
mkfs.jffs2: fix integer underflow in jffs2_rtime_compress()

When '*dstlen' is 0 or 1, comparison will return wrong result.  Reported
by valgrind as

==5919== Invalid write of size 1
==5919==    at 0x40564E: jffs2_rtime_compress (compr_rtime.c:51)
==5919==    by 0x40676B: jffs2_compress (compr.c:246)
==5919==    by 0x403EE4: recursive_populate_directory (mkfs.jffs2.c:884)
==5919==  Address 0x4e1bdb1 is 0 bytes after a block of size 1 alloc'd
==5919==    at 0x4A0515D: malloc (vg_replace_malloc.c:195)
==5919==    by 0x40671C: jffs2_compress (compr.c:229)
==5919==    by 0x403EE4: recursive_populate_directory (mkfs.jffs2.c:884)

Signed-off-by: Enrico Scholz <enrico.scholz@sigma-chemnitz.de>
Signed-off-by: Artem Bityutskiy <Artem.Bityutskiy@nokia.com>
compr_rtime.c