2024-02-27 16:00:57 +00:00
|
|
|
From 803f49aaae16b7f2899e4769afdfc673a21fa9e8 Mon Sep 17 00:00:00 2001
|
|
|
|
From: Guido Draheim <guidod@gmx.de>
|
|
|
|
Date: Mon, 26 Feb 2024 23:17:12 +0100
|
|
|
|
Subject: [PATCH] #69 assert full zzip_file_header
|
2024-01-24 11:13:08 +00:00
|
|
|
|
|
|
|
---
|
2024-02-27 16:00:57 +00:00
|
|
|
zzip/mmapped.c | 3 ++-
|
|
|
|
1 file changed, 2 insertions(+), 1 deletion(-)
|
2024-01-24 11:13:08 +00:00
|
|
|
|
|
|
|
diff --git a/zzip/mmapped.c b/zzip/mmapped.c
|
2024-02-27 16:00:57 +00:00
|
|
|
index 2071882..306ba51 100644
|
2024-01-24 11:13:08 +00:00
|
|
|
--- a/zzip/mmapped.c
|
|
|
|
+++ b/zzip/mmapped.c
|
2024-02-27 16:00:57 +00:00
|
|
|
@@ -276,7 +276,8 @@ struct zzip_file_header *
|
2024-01-24 11:13:08 +00:00
|
|
|
zzip_disk_entry_to_file_header(ZZIP_DISK * disk, struct zzip_disk_entry *entry)
|
|
|
|
{
|
2024-02-27 16:00:57 +00:00
|
|
|
zzip_byte_t *const ptr = disk->buffer + zzip_disk_entry_fileoffset(entry);
|
2024-01-24 11:13:08 +00:00
|
|
|
- if (disk->buffer > ptr || ptr >= disk->endbuf)
|
2024-02-27 16:00:57 +00:00
|
|
|
+ zzip_byte_t *const end = ptr + sizeof(struct zzip_file_header);
|
|
|
|
+ if (disk->buffer > ptr || end >= disk->endbuf || end <= NULL)
|
2024-01-24 11:13:08 +00:00
|
|
|
{
|
|
|
|
errno = EBADMSG;
|
|
|
|
return 0;
|