fs: cbfs: remove wrong header validation
authorChristian Gmeiner <christian.gmeiner@gmail.com>
Sat, 22 Dec 2018 09:55:48 +0000 (01:55 -0800)
committerBin Meng <bmeng.cn@gmail.com>
Mon, 31 Dec 2018 01:42:41 +0000 (09:42 +0800)
cbfs_fileheader.len indicates the content size of the file in the
cbfs, and it has nothing to do with cbfs_fileheader.offset which
is the starting address of the file in the cbfs.

Remove such check in file_cbfs_next_file(). Before this change
'cbfsinit' failed with 'Bad CBFS file'. After this change all cbfs
commands are working as expected.

Signed-off-by: Christian Gmeiner <christian.gmeiner@gmail.com>
[bmeng: keep the necessary header sanity check]
Signed-off-by: Bin Meng <bmeng.cn@gmail.com>
Reviewed-by: Simon Glass <sjg@chromium.org>
fs/cbfs/cbfs.c

index 0dce639b49ce095ac3eede2ee9c3138f1e0af3bb..e9433252972edeb16bb8e2f466d87852c5167768 100644 (file)
@@ -96,8 +96,7 @@ static int file_cbfs_next_file(u8 *start, u32 size, u32 align,
                }
 
                swap_file_header(&header, fileHeader);
-               if (header.offset < sizeof(struct cbfs_fileheader) ||
-                   header.offset > header.len) {
+               if (header.offset < sizeof(struct cbfs_fileheader)) {
                        file_cbfs_result = CBFS_BAD_FILE;
                        return -1;
                }