void-packages/srcpkgs/vboot-utils/patches/format-glibc.patch

59 lines
1.9 KiB
Diff

commit 8f2787e5eb72406231b83a4bc6ee20daa640ab41
Author: Érico Rolim <erico.erc@gmail.com>
Date: Sun Feb 21 00:45:12 2021 -0300
Fix wrong memory access on 32-bit glibc.
off_t on 32-bit glibc is a 32-bit value by default, and building with
large file is optional.
We also fix the makefile to actually enable large file support.
This isn't an issue on musl since it builds with large file support by
default.
diff --git Makefile Makefile
index 3a72d3d..0f9caa4 100644
--- a/Makefile
+++ b/Makefile
@@ -252,7 +252,7 @@ CFLAGS += -D_GNU_SOURCE
# but if the environment doesn't support it, at least compile support
# for what is possible.
# Pass through cflags_use_64bits to evaluate it only once, here.
-cflags_use_64bits := $(call test_ccflag,-D_FILE_OFFSET_BITS=64,\#include <fts.h>)
+cflags_use_64bits := $(call test_ccflag,-D_FILE_OFFSET_BITS=64,#include <fts.h>)
CFLAGS += $(cflags_use_64bits)
# Code coverage
diff --git futility/cmd_gbb_utility.c futility/cmd_gbb_utility.c
index 2a76ecb..ab0d568 100644
--- a/futility/cmd_gbb_utility.c
+++ b/futility/cmd_gbb_utility.c
@@ -225,7 +225,7 @@ static uint8_t *read_entire_file(const char *filename, off_t *sizeptr)
buf = (uint8_t *) malloc(sb.st_size);
if (!buf) {
fprintf(stderr, "ERROR: can't malloc %" PRIi64 " bytes: %s\n",
- sb.st_size, strerror(errno));
+ (int64_t)sb.st_size, strerror(errno));
goto fail;
}
@@ -333,7 +333,7 @@ static int read_from_file(const char *msg, const char *filename,
if (ferror(fp)) {
fprintf(stderr,
"ERROR: Read %zu/%" PRIi64 " bytes from %s: %s\n",
- count, sb.st_size, filename, strerror(errno));
+ count, (int64_t)sb.st_size, filename, strerror(errno));
errorcnt++;
r = errno;
}
@@ -557,7 +557,7 @@ static int do_gbb(int argc, char *argv[])
errorcnt++;
fprintf(stderr,
"ERROR: can't malloc %" PRIi64 " bytes: %s\n",
- filesize, strerror(errno));
+ (int64_t)filesize, strerror(errno));
break;
}