Skip to content

Commit bb5f5f7

Browse files
committed
unyar: account for end-of-file padding
Allows decompressing yaz archives that contain padding or other stale data at the end, by attempting to decompress only as many files as described by the header.
1 parent b140615 commit bb5f5f7

File tree

2 files changed

+4
-2
lines changed

2 files changed

+4
-2
lines changed

src/yar.c

+3-1
Original file line numberDiff line numberDiff line change
@@ -104,6 +104,7 @@ yar_reencode(
104104
struct yarFile *list = 0;
105105
struct yarFile *item;
106106
int list_num;
107+
int cur_index = 1; /* accounts for padding the end of the file */
107108

108109
assert(src);
109110
assert(sz);
@@ -234,8 +235,9 @@ yar_reencode(
234235

235236
ss += 4;
236237
item += 1;
238+
cur_index += 1;
237239

238-
} while ((unsigned)(ss - src) < end);
240+
} while ((unsigned)(ss - src) < end && cur_index < list_num - 1);
239241

240242
/* update progress display */
241243
if (name)

src/z64yartool.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -305,7 +305,7 @@ int main(int argc, const char *argv[])
305305
const char *command = argv[1];
306306
const char *input = argv[2];
307307

308-
fprintf(stderr, "welcome to z64yartool v1.0.0 <z64.me> special thanks Javarooster\n");
308+
fprintf(stderr, "welcome to z64yartool v1.0.1 <z64.me> special thanks Javarooster\n");
309309
fprintf(stderr, "build date: %s at %s\n", __DATE__, __TIME__);
310310

311311
if ((!command || strcmp(command, "unyar")) && argc != 3)

0 commit comments

Comments
 (0)