check signness at RLE

Signed-off-by: Slice <sergey.slice@gmail.com>
This commit is contained in:
Slice 2024-06-09 12:44:46 +03:00
parent 73f4840a3a
commit 97fe5c2fc8
5 changed files with 22 additions and 12 deletions

View File

@ -96,6 +96,8 @@ EFI_PART_TYPE_LEGACY_MBR_GUID {0x024DEE41, 0x33E7, 0x11D3, {0x9D, 0x69, 0x00, 0x
// B295BD1C-63E3-48E3-B265-F7DFA2070123 - success // B295BD1C-63E3-48E3-B265-F7DFA2070123 - success
// 82ED9A9E-CCBB-4CD2-8A94-F4E3559AF911 - Gibraltar // 82ED9A9E-CCBB-4CD2-8A94-F4E3559AF911 - Gibraltar
// ->LocateProtocol(3496A19A-2E99-41BA-833E-0FDE2EBF2A55, 0, 0/0) = Not Found
// ->LocateProtocol(8555FD40-140B-4F3C-905E-3BF378A099FA, 0, 0/0) = Not Found
/** /**
Apple Debug Log protocol GUID. Apple Debug Log protocol GUID.

View File

@ -318,7 +318,7 @@ EFI_PART_TYPE_LEGACY_MBR_GUID {0x024DEE41, 0x33E7, 0x11D3, {0x9D, 0x69, 0x00, 0x
// 00 00 08 00 00 00 00 00 | ........ // 00 00 08 00 00 00 00 00 | ........
// gAppleFpfConfigurationHobGuid = { 0xE3CC8EC6, 0x81C1, 0x4271, { 0xAC, 0xBC, 0xDB, 0x65, 0x08, 0x6E, 0x8D, 0xC8 }} // gAppleFpfConfigurationHobGuid = { 0xE3CC8EC6, 0x81C1, 0x4271, { 0xAC, 0xBC, 0xDB, 0x65, 0x08, 0x6E, 0x8D, 0xC8 }}
// 59D76AE4-37E3-55A7-B460-EF13D46E6020 AppleEncryptedPartitionProtocolGuid // 59D76AE4-37E3-55A7-B460-EF13D46E6020 AppleEncryptedPartitionProtocolGuid
// ->LocateProtocol(3496A19A-2E99-41BA-833E-0FDE2EBF2A55, 0, 0/0) = Not Found
/* /*
#define APPLE_SECURE_BOOT_VARIABLE_GUID \ #define APPLE_SECURE_BOOT_VARIABLE_GUID \
{ 0x94B73556, 0x2197, 0x4702, \ { 0x94B73556, 0x2197, 0x4702, \

View File

@ -22,8 +22,8 @@
//#include "picopng.h" //#include "picopng.h"
#include "lodepng.h" #include "lodepng.h"
//#define DBG(...) DebugLog(1, __VA_ARGS__) #define DBG(...) DebugLog(1, __VA_ARGS__)
#define DBG(...) //#define DBG(...)
struct EFI_RES_ENTRY { struct EFI_RES_ENTRY {
CHAR8 Name[64]; CHAR8 Name[64];
@ -133,7 +133,7 @@ GetImageDims (//IN APPLE_IMAGE_CODEC_PROTOCOL* This,
*ImageHeight = (UINT32)Image.GetHeight(); *ImageHeight = (UINT32)Image.GetHeight();
DBG("EFI_SUCCESS, Width=%d, Height=%d\n", *ImageWidth, *ImageHeight); DBG("EFI_SUCCESS, Width=%d, Height=%d\n", *ImageWidth, *ImageHeight);
DBG("ImageSize=%lld\n", ImageSize); // DBG("ImageSize=%lld\n", ImageSize);
return EFI_SUCCESS; return EFI_SUCCESS;
} }

View File

@ -99,7 +99,7 @@ void egDecompressIcnsRLE(IN OUT UINT8 **CompData, IN OUT UINTN *CompLen, IN UINT
UINT8 *cp; UINT8 *cp;
UINT8 *cp_end; UINT8 *cp_end;
UINT8 *pp; UINT8 *pp;
UINTN pp_left; INTN pp_left;
UINTN len; UINTN len;
UINT8 value; UINT8 value;
@ -114,7 +114,7 @@ void egDecompressIcnsRLE(IN OUT UINT8 **CompData, IN OUT UINTN *CompLen, IN UINT
len = *cp++; len = *cp++;
if (len & 0x80) { // compressed data: repeat next byte if (len & 0x80) { // compressed data: repeat next byte
len -= 125; len -= 125;
if (len > pp_left) if (len > (UINTN)pp_left)
break; break;
value = *cp++; value = *cp++;
for (UINTN i = 0; i < len; i++) { for (UINTN i = 0; i < len; i++) {
@ -123,14 +123,14 @@ void egDecompressIcnsRLE(IN OUT UINT8 **CompData, IN OUT UINTN *CompLen, IN UINT
} }
} else { // uncompressed data: copy bytes } else { // uncompressed data: copy bytes
len++; len++;
if (len > pp_left || cp + len > cp_end) if (len > (UINTN)pp_left || cp + len > cp_end)
break; break;
for (UINTN i = 0; i < len; i++) { for (UINTN i = 0; i < len; i++) {
*pp = *cp++; *pp = *cp++;
pp += 4; pp += 4;
} }
} }
pp_left -= len; pp_left -= (INTN)len;
} }
if (pp_left > 0) { if (pp_left > 0) {

View File

@ -51,12 +51,20 @@ extern "C" {
#define NANOSVG_ALL_COLOR_KEYWORDS 1 #define NANOSVG_ALL_COLOR_KEYWORDS 1
#define NSVG_RGBA(r, g, b, a) (((unsigned int)b) | ((unsigned int)g << 8) | ((unsigned int)r << 16) | ((unsigned int)a << 24)) #define NSVG_RGBA(r, g, b, a) (((unsigned int)b) | ((unsigned int)g << 8) | ((unsigned int)r << 16) | ((unsigned int)a << 24))
#define kMaxIDLength 64 //#define kMaxIDLength 64
#define kMaxTextLength 256 //#define kMaxTextLength 256
//
//
//#define NSVG_MAX_ATTR 2048
//#define NSVG_MAX_CLIP_PATHS 1024 // also note NSVGclipPathIndex
const int kMaxIDLength = 64;
const int kMaxTextLength = 256;
#define NSVG_MAX_ATTR 2048 const int NSVG_MAX_ATTR = 2048;
#define NSVG_MAX_CLIP_PATHS 1024 // also note NSVGclipPathIndex const int NSVG_MAX_CLIP_PATHS = 1024; // also note NSVGclipPathIndex
#ifdef JIEF_DEBUG #ifdef JIEF_DEBUG
#define NANOSVG_MEMORY_ALLOCATION_TRACE #define NANOSVG_MEMORY_ALLOCATION_TRACE