From 6f98d2f2148f1b4dccc1a7db7fc984af6dbbf59f Mon Sep 17 00:00:00 2001 From: Connor Olding Date: Wed, 21 Mar 2018 08:30:17 +0100 Subject: [PATCH] pad compressed files to multiple of 16 bytes --- z64yaz0.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/z64yaz0.c b/z64yaz0.c index 03a3c17..9ab76be 100644 --- a/z64yaz0.c +++ b/z64yaz0.c @@ -260,7 +260,13 @@ int main(int argc, char *argv[]) long csize = encodeYaz0(bufi, bufo + 16, size) + 16; - fwrite(bufo, csize, 1, stdout); + // pad compressed file to be a multiple of 16 bytes. + long ceilsize = (csize + 15) & ~0xF; + for (long i = csize; i < ceilsize; i++) { + bufo[i] = 0; + } + + fwrite(bufo, ceilsize, 1, stdout); free(bufo); } free(bufi);