erofs-utils: refuse block sizes larger than EROFS_MAX_BLOCK_SIZE
PATCH 1/2 erofs-utils: refuse block sizes larger than EROFS_MAX_BLOCK_SIZE
The maximum supported block size is EROFS_MAX_BLOCK_SIZE.
Signed-off-by Gao Xiang <[email protected]>
--- lib/super.c | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-)
lib/super.c +4 -5
@@ -88,15 +88,14 @@ int erofs_read_superblock(void) sbi.feature_compat =le32_to_cpu (dsb->feature_compat); sbi.blkszbits = dsb->blkszbits; -/* 9(512 bytes) + LOG_SECTORS_PER_BLOCK == LOG_BLOCK_SIZE */ -if (sbi.blkszbits <9 ) { +if (sbi.blkszbits <9 || + (1 << sbi.blkszbits) >EROFS_MAX_BLOCK_SIZE ) {erofs_err ("blksize %d isn't supported on this platform" ,erofs_blksiz ());return ret; - } - -if (!check_layout_compatibility (&sbi, dsb)) + }else if (!check_layout_compatibility (&sbi, dsb)) {return ret; + } sbi.primarydevice_blocks =le32_to_cpu (dsb->blocks); sbi.meta_blkaddr =le32_to_cpu (dsb->meta_blkaddr);
Signature · 1 line
2.24.4
PATCH 2/2 erofs-utils: fix EOD behavior when len is too large
Otherwise, read_count could be overflow and causes unexpected behaviors.
Signed-off-by Gao Xiang <[email protected]>
--- lib/io.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
lib/io.c +1 -1
@@ -289,7 +289,7 @@ int dev_read(int device_id, void *buf, u64 offset, size_t len)erofs_info ("Reach EOF of device - %s:[%" PRIu64", %zd]." , erofs_devname, offset, len);memset (buf,0 , len); - read_count = len; +return 0 ; }else if (errno !=EINTR ) {erofs_err ("Failed to read data from device - %s:[%" PRIu64", %zd]." , erofs_devname, offset, len);
Signature · 1 line
2.24.4