From e8cb65a2e252443c92330871384b15e340db9418 Mon Sep 17 00:00:00 2001
From: Troy Kisky <troy.kisky@boundarydevices.com>
Date: Fri, 22 Apr 2016 13:18:57 -0700
Subject: [PATCH] splash_source: fix gzip and raw storage checks

Signed-off-by: Troy Kisky <troy.kisky@boundarydevices.com>
---
 common/splash_source.c | 21 ++++++++++++++++++++-
 1 file changed, 20 insertions(+), 1 deletion(-)

diff --git a/common/splash_source.c b/common/splash_source.c
index 62763b9ebd5..1b454d3046b 100644
--- a/common/splash_source.c
+++ b/common/splash_source.c
@@ -95,7 +95,26 @@ static int splash_load_raw(struct splash_location *location, u32 bmp_load_addr)
 		return res;
 
 	bmp_hdr = (struct bmp_header *)bmp_load_addr;
-	bmp_size = le32_to_cpu(bmp_hdr->file_size);
+
+	if ((bmp_hdr->signature[0] == 'B') &&
+	      (bmp_hdr->signature[1] == 'M')) {
+		bmp_size = le32_to_cpu(bmp_hdr->file_size);
+	} else if ((bmp_hdr->signature[0] == 0x1f) &&
+			      (bmp_hdr->signature[1] == 0x8b)) {
+		char *sz = getenv("splashsize");
+
+		bmp_size = 0;
+		if (sz)
+			bmp_size = simple_strtoul(sz, 0, 16);
+		if (!bmp_size) {
+			printf("Error: specify env splashsize\n");
+			return -EINVAL;
+		}
+	} else {
+		printf("Error: unrecognized splash file type %02x %02x\n",
+			bmp_hdr->signature[0], bmp_hdr->signature[1]);
+		return -EINVAL;
+	}
 
 	if (bmp_load_addr + bmp_size >= gd->start_addr_sp)
 		goto splash_address_too_high;
-- 
GitLab