1 diff --git a/dmidecode.c b/dmidecode.c
2 index 183ced4..a43cfd1 100644
5 @@ -4751,6 +4751,7 @@ int main(int argc, char * const argv[])
6 int ret = 0; /* Returned value */
13 @@ -4820,8 +4821,9 @@ int main(int argc, char * const argv[])
14 * contain one of several types of entry points, so read enough for
15 * the largest one, then determine what type it contains.
18 if (!(opt.flags & FLAG_NO_SYSFS)
19 - && (buf = read_file(0x20, SYS_ENTRY_FILE)) != NULL)
20 + && (buf = read_file(&size, SYS_ENTRY_FILE)) != NULL)
22 if (!(opt.flags & FLAG_QUIET))
23 printf("Getting SMBIOS data from sysfs.\n");
24 diff --git a/util.c b/util.c
25 index f97ac0d..52ed413 100644
28 @@ -94,10 +94,11 @@ int checksum(const u8 *buf, size_t len)
29 * needs to be freed by the caller.
30 * This provides a similar usage model to mem_chunk()
32 - * Returns pointer to buffer of max_len bytes, or NULL on error
33 + * Returns pointer to buffer of max_len bytes, or NULL on error, and
34 + * sets max_len to the length actually read.
37 -void *read_file(size_t max_len, const char *filename)
38 +void *read_file(size_t *max_len, const char *filename)
42 @@ -115,7 +116,7 @@ void *read_file(size_t max_len, const char *filename)
46 - if ((p = malloc(max_len)) == NULL)
47 + if ((p = malloc(*max_len)) == NULL)
51 @@ -123,7 +124,7 @@ void *read_file(size_t max_len, const char *filename)
55 - r = read(fd, p + r2, max_len - r2);
56 + r = read(fd, p + r2, *max_len - r2);
60 @@ -140,6 +141,8 @@ void *read_file(size_t max_len, const char *filename)
69 diff --git a/util.h b/util.h
70 index 9d409cd..b8748f1 100644
74 #define ARRAY_SIZE(x) (sizeof(x)/sizeof((x)[0]))
76 int checksum(const u8 *buf, size_t len);
77 -void *read_file(size_t len, const char *filename);
78 +void *read_file(size_t *len, const char *filename);
79 void *mem_chunk(off_t base, size_t len, const char *devmem);
80 int write_dump(size_t base, size_t len, const void *data, const char *dumpfile, int add);
81 u64 u64_range(u64 start, u64 end);