[rtems commit] jffs2: Fix return code of rtime compress

Sebastian Huber sebh at rtems.org
Thu Jan 12 13:25:53 UTC 2023


Module:    rtems
Branch:    master
Commit:    2ea03be47c41fc83d47eeecb53deaf2e66ef772c
Changeset: http://git.rtems.org/rtems/commit/?id=2ea03be47c41fc83d47eeecb53deaf2e66ef772c

Author:    Sebastian Huber <sebastian.huber at embedded-brains.de>
Date:      Thu Jan 12 14:38:36 2023 +0100

jffs2: Fix return code of rtime compress

The RTEMS and Linux JFFS2 compression support have a slightly different
interface.  This fixes a bug introduced by:

commit 17c3d536ca8ee17d36ea251eade884e07ff1ee75
Author: Yang Yang <yang.yang29 at zte.com.cn>
Date:   Thu Jan 28 02:55:35 2021 -0800

    jffs2: check the validity of dstlen in jffs2_zlib_compress()

    KASAN reports a BUG when download file in jffs2 filesystem.It is
    because when dstlen == 1, cpage_out will write array out of bounds.
    Actually, data will not be compressed in jffs2_zlib_compress() if
    data's length less than 4.

---

 cpukit/libfs/src/jffs2/src/compr_rtime.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/cpukit/libfs/src/jffs2/src/compr_rtime.c b/cpukit/libfs/src/jffs2/src/compr_rtime.c
index 35fe2cd2a5..e3c761dcfe 100644
--- a/cpukit/libfs/src/jffs2/src/compr_rtime.c
+++ b/cpukit/libfs/src/jffs2/src/compr_rtime.c
@@ -45,7 +45,7 @@ uint16_t rtems_jffs2_compressor_rtime_compress(
 	(void) self;
 
 	if (*dstlen <= 3)
-		return -1;
+		return JFFS2_COMPR_NONE;
 
 	memset(positions,0,sizeof(positions));
 



More information about the vc mailing list