From 166632fc15759d5390bfcafb4b97db5f4c835013 Mon Sep 17 00:00:00 2001 From: Stephen Seo Date: Fri, 4 Oct 2024 14:02:54 +0900 Subject: [PATCH] Update file_format for v1 Size of bytes for files per chunk was changed from 2 bytes to 4 bytes. --- file_format.md | 2 +- file_format_1_example_0 | Bin 203 -> 207 bytes file_format_1_example_1 | Bin 405 -> 407 bytes src/archiver.c | 10 +++++----- 4 files changed, 6 insertions(+), 6 deletions(-) diff --git a/file_format.md b/file_format.md index 67c5866..4e39544 100644 --- a/file_format.md +++ b/file_format.md @@ -149,7 +149,7 @@ archive. Following the chunk-count bytes, the following bytes are added for each chunk: -1. 2 bytes that are a 16-bit unsigned integer "file count" in big-endian. +1. 4 bytes that are a 32-bit unsigned integer "file count" in big-endian. The following bytes are added for each file within the current chunk: diff --git a/file_format_1_example_0 b/file_format_1_example_0 index f28c89ed130d3445f8c84ba0f3f3521d17cc134e..a39ecf63812a798e5e1ca4829331e322f43c68ec 100644 GIT binary patch delta 16 WcmX@jc%E^BA|t~@1wSB>8wUU?j|8g# delta 12 TcmX@lc$#s7;zVWNiAAvhA7%uv diff --git a/file_format_1_example_1 b/file_format_1_example_1 index b56b56c6a7fcd8bee2c0dc7cee54354451196ddc..696a49f01f3583aeee48051f72487a10d1e15a7b 100644 GIT binary patch delta 12 TcmbQrJe_$$86(5SQUyi;8BPO% delta 10 RcmbQvJe7Gu*~SWaMgSDy1A+hm diff --git a/src/archiver.c b/src/archiver.c index 0644051..a0c37fb 100644 --- a/src/archiver.c +++ b/src/archiver.c @@ -2974,13 +2974,13 @@ int simple_archiver_parse_archive_version_1(FILE *in_f, int_fast8_t do_extract, for (uint32_t chunk_idx = 0; chunk_idx < chunk_count; ++chunk_idx) { fprintf(stderr, "CHUNK %3u of %3u\n", chunk_idx + 1, chunk_count); - if (fread(buf, 1, 2, in_f) != 2) { + if (fread(buf, 1, 4, in_f) != 4) { return SDAS_INVALID_FILE; } - memcpy(&u16, buf, 2); - simple_archiver_helper_16_bit_be(&u16); + memcpy(&u32, buf, 4); + simple_archiver_helper_32_bit_be(&u32); - const uint16_t file_count = u16; + const uint32_t file_count = u32; __attribute__((cleanup(simple_archiver_list_free))) SDArchiverLinkedList *file_info_list = simple_archiver_list_init(); @@ -2988,7 +2988,7 @@ int simple_archiver_parse_archive_version_1(FILE *in_f, int_fast8_t do_extract, __attribute__((cleanup(cleanup_internal_file_info))) SDArchiverInternalFileInfo *file_info = NULL; - for (uint16_t file_idx = 0; file_idx < file_count; ++file_idx) { + for (uint32_t file_idx = 0; file_idx < file_count; ++file_idx) { file_info = malloc(sizeof(SDArchiverInternalFileInfo)); memset(file_info, 0, sizeof(SDArchiverInternalFileInfo));