lib/uri: Remove support for gzip compressed files
diff --git a/common/compress/gzip.c b/common/compress/gzip.c
deleted file mode 100644
index 6e4b4544..00000000
--- a/common/compress/gzip.c
+++ /dev/null
@@ -1,128 +0,0 @@
-/*
- * originally from tinfgzip - tiny gzip decompressor
- *
- * Copyright (c) 2003-2019 Joergen Ibsen
- * Copyright (c) 2023-2024 mintsuki and contributors to the Limine project
- *
- * This software is provided 'as-is', without any express or implied
- * warranty. In no event will the authors be held liable for any damages
- * arising from the use of this software.
- *
- * Permission is granted to anyone to use this software for any purpose,
- * including commercial applications, and to alter it and redistribute it
- * freely, subject to the following restrictions:
- *
- * 1. The origin of this software must not be misrepresented; you must
- * not claim that you wrote the original software. If you use this
- * software in a product, an acknowledgment in the product
- * documentation would be appreciated but is not required.
- *
- * 2. Altered source versions must be plainly marked as such, and must
- * not be misrepresented as being the original software.
- *
- * 3. This notice may not be removed or altered from any source
- * distribution.
- */
-
-#include <stdint.h>
-#include <lib/stb_image.h>
-
-typedef enum {
- FTEXT = 1,
- FHCRC = 2,
- FEXTRA = 4,
- FNAME = 8,
- FCOMMENT = 16
-} gzip_flag;
-
-void *gzip_uncompress(const void *source, uint64_t sourceLen, uint64_t *outsize) {
- const uint8_t *src = (const uint8_t *) source;
- const uint8_t *start;
- int res;
- uint8_t flg;
-
- /* -- Check header -- */
-
- /* Check room for at least 10 byte header and 8 byte trailer */
- if (sourceLen < 18) {
- return NULL;
- }
-
- /* Check id bytes */
- if (src[0] != 0x1F || src[1] != 0x8B) {
- return NULL;
- }
-
- /* Check method is deflate */
- if (src[2] != 8) {
- return NULL;
- }
-
- /* Get flag byte */
- flg = src[3];
-
- /* Check that reserved bits are zero */
- if (flg & 0xE0) {
- return NULL;
- }
-
- /* -- Find start of compressed data -- */
-
- /* Skip base header of 10 bytes */
- start = src + 10;
-
- /* Skip extra data if present */
- if (flg & FEXTRA) {
- uint64_t xlen = *((uint16_t *)start);
-
- if (xlen > sourceLen - 12) {
- return NULL;
- }
-
- start += xlen + 2;
- }
-
- /* Skip file name if present */
- if (flg & FNAME) {
- do {
- if (((uint64_t)(start - src)) >= sourceLen) {
- return NULL;
- }
- } while (*start++);
- }
-
- /* Skip file comment if present */
- if (flg & FCOMMENT) {
- do {
- if (((uint64_t)(start - src)) >= sourceLen) {
- return NULL;
- }
- } while (*start++);
- }
-
- if (flg & FHCRC) {
- start += 2;
- }
-
- /* -- Get decompressed length -- */
-
- uint32_t dlen = *((uint32_t *)&src[sourceLen - 4]);
-
- /* -- Decompress data -- */
-
- if ((src + sourceLen) - start < 8) {
- return NULL;
- }
-
- void *buf = ext_mem_alloc(dlen);
-
- res = stbi_zlib_decode_noheader_buffer(buf, dlen, (const char *)start, (src + sourceLen) - start - 8);
-
- if (res == -1) {
- pmm_free(buf, dlen);
- return NULL;
- }
-
- *outsize = (uint64_t)dlen;
- return buf;
-}
diff --git a/common/compress/gzip.h b/common/compress/gzip.h
deleted file mode 100644
index f6e232ac..00000000
--- a/common/compress/gzip.h
+++ /dev/null
@@ -1,8 +0,0 @@
-#ifndef COMPRESS__GZIP_H__
-#define COMPRESS__GZIP_H__
-
-#include <stdint.h>
-
-void *gzip_uncompress(const void *source, uint64_t sourceLen, uint64_t *outsize);
-
-#endif
diff --git a/common/lib/uri.c b/common/lib/uri.c
index 9ed8e439..0b8cd1d5 100644
--- a/common/lib/uri.c
+++ b/common/lib/uri.c
@@ -8,7 +8,6 @@
#include <mm/pmm.h>
#include <lib/print.h>
#include <pxe/tftp.h>
-#include <compress/gzip.h>
#include <menu.h>
#include <lib/getchar.h>
#include <crypt/blake2b.h>
@@ -218,12 +217,6 @@ struct file_handle *uri_open(char *uri) {
panic(true, "No resource specified for URI `%#`.", uri);
}
- bool compressed = false;
- if (*resource == '$') {
- compressed = true;
- resource++;
- }
-
if (!strcmp(resource, "bios")) {
panic(true, "bios:// resource is no longer supported. Check CONFIG.md for hdd:// and odd://");
} else if (!strcmp(resource, "hdd")) {
@@ -270,22 +263,5 @@ struct file_handle *uri_open(char *uri) {
}
}
- if (compressed && ret != NULL) {
- struct file_handle *compressed_fd = ext_mem_alloc(sizeof(struct file_handle));
- void *src = freadall(ret, MEMMAP_BOOTLOADER_RECLAIMABLE);
- if ((compressed_fd->fd = gzip_uncompress(src, ret->size, &compressed_fd->size)) == NULL) {
- panic(true, "GZip error");
- }
- compressed_fd->vol = ret->vol;
- compressed_fd->path = ext_mem_alloc(ret->path_len);
- memcpy(compressed_fd->path, ret->path, ret->path_len);
- compressed_fd->path_len = ret->path_len;
- compressed_fd->is_memfile = true;
- uint64_t src_size = ret->size;
- fclose(ret);
- pmm_free(src, src_size);
- ret = compressed_fd;
- }
-
return ret;
}
diff --git a/common/stb_image.patch b/common/stb_image.patch
index 13128b47..0f3718d7 100644
--- a/common/stb_image.patch
+++ b/common/stb_image.patch
@@ -46,8 +46,8 @@
+#define STBI_NO_SIMD
+#define STBI_NO_LINEAR
+
-+#define STBI_ONLY_ZLIB
-+#define STBI_SUPPORT_ZLIB
++
++
+#define STBI_ONLY_JPEG
+#define STBI_ONLY_PNG
+#define STBI_ONLY_BMP
