]> git.sur5r.net Git - u-boot/blobdiff - fs/cbfs/cbfs.c
SPDX: Convert all of our single license tags to Linux Kernel style
[u-boot] / fs / cbfs / cbfs.c
index 1b25a15e48848081c34c396eb7e060d150327a61..0dce639b49ce095ac3eede2ee9c3138f1e0af3bb 100644 (file)
@@ -1,22 +1,9 @@
+// SPDX-License-Identifier: GPL-2.0+
 /*
  * Copyright (c) 2011 The Chromium OS Authors. All rights reserved.
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License as
- * published by the Free Software Foundation; either version 2 of
- * the License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
- * MA 02111-1307 USA
  */
 
+#include <common.h>
 #include <cbfs.h>
 #include <malloc.h>
 #include <asm/byteorder.h>
@@ -109,8 +96,8 @@ static int file_cbfs_next_file(u8 *start, u32 size, u32 align,
                }
 
                swap_file_header(&header, fileHeader);
-               if (header.offset < sizeof(const struct cbfs_cachenode *) ||
-                               header.offset > header.len) {
+               if (header.offset < sizeof(struct cbfs_fileheader) ||
+                   header.offset > header.len) {
                        file_cbfs_result = CBFS_BAD_FILE;
                        return -1;
                }
@@ -118,9 +105,9 @@ static int file_cbfs_next_file(u8 *start, u32 size, u32 align,
                newNode->type = header.type;
                newNode->data = start + header.offset;
                newNode->data_length = header.len;
-               name_len = header.offset - sizeof(struct cbfs_cachenode *);
+               name_len = header.offset - sizeof(struct cbfs_fileheader);
                newNode->name = (char *)fileHeader +
-                               sizeof(struct cbfs_cachenode *);
+                               sizeof(struct cbfs_fileheader);
                newNode->name_length = name_len;
                newNode->checksum = header.checksum;
 
@@ -180,9 +167,9 @@ static int file_cbfs_load_header(uintptr_t end_of_rom,
                                 struct cbfs_header *header)
 {
        struct cbfs_header *header_in_rom;
+       int32_t offset = *(u32 *)(end_of_rom - 3);
 
-       header_in_rom = (struct cbfs_header *)(uintptr_t)
-                       *(u32 *)(end_of_rom - 3);
+       header_in_rom = (struct cbfs_header *)(end_of_rom + offset + 1);
        swap_header(header, header_in_rom);
 
        if (header->magic != good_magic || header->offset >