]> git.dujemihanovic.xyz Git - u-boot.git/commitdiff
cbfs: Check offset range when reading a file
authorSimon Glass <sjg@chromium.org>
Fri, 14 May 2021 01:39:27 +0000 (19:39 -0600)
committerTom Rini <trini@konsulko.com>
Thu, 15 Jul 2021 22:42:05 +0000 (18:42 -0400)
Add a check that the offset is within the allowed range.

Signed-off-by: Simon Glass <sjg@chromium.org>
Reported-by: Coverity (CID: 331155)
fs/cbfs/cbfs.c

index 415ea28b871d36f95cecf7ee1b3ba46cbb36a39e..3e905c74e58a6404fd9bfb5c518c838604e60764 100644 (file)
@@ -167,6 +167,8 @@ static int file_cbfs_next_file(struct cbfs_priv *priv, void *start, int size,
                }
 
                swap_file_header(&header, file_header);
+               if (header.offset >= size)
+                       return log_msg_ret("range", -E2BIG);
                ret = fill_node(node, start, &header);
                if (ret) {
                        priv->result = CBFS_BAD_FILE;