Please try this within your cboot, reflash the cboot and it shall work with extlinux.conf.
diff --git a/lib/fs/ext4/ext4.c b/lib/fs/ext4/ext4.c
index c994c0f..6e8e2e7 100644
--- a/lib/fs/ext4/ext4.c
+++ b/lib/fs/ext4/ext4.c
@@ -244,6 +244,9 @@
uint8_t *buf_ptr = NULL;
off_t total_bytes_read = 0;
int err = 0;
+ uint32_t file_len_in_blocks = 0;
+ uint32_t total_blocks_read;
+ uint32_t block_size;
LTRACE_ENTRY;
@@ -254,6 +257,15 @@
}
buf_ptr = (uint8_t *)buf;
+ block_size = E2FS_BLOCK_SIZE(ext2->super_blk);
+
+ if (len != 0UL) {
+ file_len_in_blocks = len/block_size;
+ if ((len % block_size) != 0U) {
+ file_len_in_blocks++;
+ }
+ LTRACEF("file_len_in_blocks: %u\n", file_len_in_blocks);
+ }
/* Extract extents info */
extent_header = (struct ext4_extent_header *)inode->e2di_blocks;
@@ -284,21 +296,37 @@
err = ext4_read_extent(ext2, (struct ext4_extent_header *)buf2, buf_ptr, &bytes_read);
total_bytes_read += bytes_read;
buf_ptr += bytes_read;
- if ((len != 0) && (total_bytes_read > len)) {
- TRACEF("Total file read should not be larger than file stat size\n");
- err = ERR_NOT_VALID;
- goto fail;
- }
+
+ total_blocks_read = total_bytes_read/block_size;
+ if ((total_bytes_read % block_size) != 0U) {
+ total_blocks_read++;
+ }
+
+ /* Check if extra block isn't read */
+ if ((len != 0) && (total_blocks_read > file_len_in_blocks)) {
+ TRACEF("More blocks are read (%u) than file block count (%u)\n",
+ total_blocks_read, file_len_in_blocks);
+ err = ERR_NOT_VALID;
+ goto fail;
+ }
}
} else {
/* Read leaf node */
err = ext4_read_extent(ext2, extent_header, buf_ptr, &bytes_read);
total_bytes_read += bytes_read;
- if ((len != 0) && (total_bytes_read > len)) {
- TRACEF("Total file read should not be larger than file stat size\n");
- err = ERR_NOT_VALID;
- goto fail;
- }
+
+ total_blocks_read = total_bytes_read/block_size;
+ if ((total_bytes_read % block_size) != 0U) {
+ total_blocks_read++;
+ }
+
+ /* Check if extra block isn't read */
+ if ((len != 0) && (total_blocks_read > file_len_in_blocks)) {
+ TRACEF("More blocks are read (%u) than file block count (%u)\n",
+ total_blocks_read, file_len_in_blocks);
+ err = ERR_NOT_VALID;
+ goto fail;
+ }
}
LTRACEF("err %d, bytes_read %lu\n", err, total_bytes_read);