bsdiff-portable

A more portable version of Colin Percival's bsdiff
git clone git://git.sgregoratto.me/bsdiff-portable
Log | Files | Refs | README | LICENSE

commit f84511ead31c2c690698fd4af8b12fb0f1c339f6
parent 394a89f23ca1ede2bd098e2f76279c42a9cd2f8a
Author: Stephen Gregoratto <dev@sgregoratto.me>
Date:   Thu, 24 Sep 2020 16:01:16 +1000

fix memory allocation sizes

Files were being allocated as buffers of off_t, which is 8x the original
size! Same for the diff/extra blocks.

Diffstat:
Mbsdiff.c | 2+-
Mutil.c | 2+-
2 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/bsdiff.c b/bsdiff.c @@ -125,7 +125,7 @@ main(int argc, char **argv) err(1, "pledge"); #endif - if ((dbuf = reallocarray(NULL, newsize + 1, sizeof(off_t))) == NULL) + if ((dbuf = reallocarray(NULL, newsize + 1, 1)) == NULL) err(1, "reallocarray"); filelen = 0; diff --git a/util.c b/util.c @@ -272,7 +272,7 @@ readfile(char *path, off_t *size, struct stat *st) * try to malloc(0) and get a NULL pointer. */ *size = st->st_size; - if ((buf = reallocarray(NULL, *size + 1, sizeof(off_t))) == NULL) + if ((buf = reallocarray(NULL, *size + 1, 1)) == NULL) err(1, "%s: reallocarray", path); if (read(fd, buf, *size) == -1)