[WIP] [PATCH 07/12] erofs-utils: fuse: refuse a undefined shifted cluster behavior

Gao Xiang hsiangkao at aol.com
Sat Oct 17 16:16:16 AEDT 2020


[ let's fold in to the original patch. ]
Cc: Huang Jianan <huangjianan at oppo.com>
Signed-off-by: Gao Xiang <hsiangkao at aol.com>
---
 fuse/decompress.c | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/fuse/decompress.c b/fuse/decompress.c
index 4b7cf3211319..4a9f8e7995c1 100644
--- a/fuse/decompress.c
+++ b/fuse/decompress.c
@@ -18,8 +18,11 @@ static int z_erofs_shifted_transform(struct z_erofs_decompress_req *rq)
 	char *dest = rq->out;
 	char *src = rq->in + rq->ofs_head;
 
-	memcpy(dest, src, rq->outputsize - rq->ofs_head);
+	if (rq->inputsize != EROFS_BLKSIZ)
+		return -EFSCORRUPTED;
 
+	DBG_BUGON(rq->outputsize > EROFS_BLKSIZ);
+	memcpy(dest, src, rq->outputsize - rq->ofs_head);
 	return 0;
 }
 
-- 
2.24.0



More information about the Linux-erofs mailing list