summaryrefslogtreecommitdiffstats
path: root/source/ap/dmidecode/patches/0007-Let-read_file-return-the-actual-data-size.patch
diff options
context:
space:
mode:
author Patrick J Volkerding <volkerdi@slackware.com>2016-06-30 20:26:57 +0000
committer Eric Hameleers <alien@slackware.com>2018-05-31 23:31:18 +0200
commitd31c50870d0bee042ce660e445c9294a59a3a65b (patch)
tree6bfc0de3c95267b401b620c2c67859557dc60f97 /source/ap/dmidecode/patches/0007-Let-read_file-return-the-actual-data-size.patch
parent76fc4757ac91ac7947a01fb7b53dddf9a78a01d1 (diff)
downloadcurrent-d31c50870d0bee042ce660e445c9294a59a3a65b.tar.gz
current-d31c50870d0bee042ce660e445c9294a59a3a65b.tar.xz
Slackware 14.2slackware-14.2
Thu Jun 30 20:26:57 UTC 2016 Slackware 14.2 x86_64 stable is released! The long development cycle (the Linux community has lately been living in "interesting times", as they say) is finally behind us, and we're proud to announce the release of Slackware 14.2. The new release brings many updates and modern tools, has switched from udev to eudev (no systemd), and adds well over a hundred new packages to the system. Thanks to the team, the upstream developers, the dedicated Slackware community, and everyone else who pitched in to help make this release a reality. The ISOs are off to be replicated, a 6 CD-ROM 32-bit set and a dual-sided 32-bit/64-bit x86/x86_64 DVD. Please consider supporting the Slackware project by picking up a copy from store.slackware.com. We're taking pre-orders now, and offer a discount if you sign up for a subscription. Have fun! :-)
Diffstat (limited to 'source/ap/dmidecode/patches/0007-Let-read_file-return-the-actual-data-size.patch')
-rw-r--r--source/ap/dmidecode/patches/0007-Let-read_file-return-the-actual-data-size.patch112
1 files changed, 112 insertions, 0 deletions
diff --git a/source/ap/dmidecode/patches/0007-Let-read_file-return-the-actual-data-size.patch b/source/ap/dmidecode/patches/0007-Let-read_file-return-the-actual-data-size.patch
new file mode 100644
index 000000000..22e2f7241
--- /dev/null
+++ b/source/ap/dmidecode/patches/0007-Let-read_file-return-the-actual-data-size.patch
@@ -0,0 +1,112 @@
+From de9a74e1c60210bee229fcf55b1678a99d1b44dd Mon Sep 17 00:00:00 2001
+From: Jean Delvare <jdelvare@suse.de>
+Date: Mon, 2 Nov 2015 09:45:26 +0100
+Subject: [PATCH 7/9] Let read_file return the actual data size
+
+Let read_file return the actual data size to the caller. This gives
+the caller the possibility to check that the data size is as expected
+and large enough for the purpose, and report to the user if not.
+---
+ CHANGELOG | 5 +++++
+ dmidecode.c | 4 +++-
+ util.c | 11 +++++++----
+ util.h | 2 +-
+ 4 files changed, 16 insertions(+), 6 deletions(-)
+
+diff --git a/CHANGELOG b/CHANGELOG
+index be2092a..1e5437a 100644
+--- a/CHANGELOG
++++ b/CHANGELOG
+@@ -1,3 +1,8 @@
++2015-11-02 Jean Delvare <jdelvare@suse.de>
++
++ * dmidecode.c, util.c, util.h: Let read_file return the actual data
++ size.
++
+ 2015-10-21 Xie XiuQi <xiexiuqi@huawei.com>
+
+ * dmidecode.c: Handle SMBIOS 3.0 entry points on EFI systems.
+diff --git a/dmidecode.c b/dmidecode.c
+index 183ced4..a43cfd1 100644
+--- a/dmidecode.c
++++ b/dmidecode.c
+@@ -4751,6 +4751,7 @@ int main(int argc, char * const argv[])
+ int ret = 0; /* Returned value */
+ int found = 0;
+ off_t fp;
++ size_t size;
+ int efi;
+ u8 *buf;
+
+@@ -4820,8 +4821,9 @@ int main(int argc, char * const argv[])
+ * contain one of several types of entry points, so read enough for
+ * the largest one, then determine what type it contains.
+ */
++ size = 0x20;
+ if (!(opt.flags & FLAG_NO_SYSFS)
+- && (buf = read_file(0x20, SYS_ENTRY_FILE)) != NULL)
++ && (buf = read_file(&size, SYS_ENTRY_FILE)) != NULL)
+ {
+ if (!(opt.flags & FLAG_QUIET))
+ printf("Getting SMBIOS data from sysfs.\n");
+diff --git a/util.c b/util.c
+index f97ac0d..52ed413 100644
+--- a/util.c
++++ b/util.c
+@@ -94,10 +94,11 @@ int checksum(const u8 *buf, size_t len)
+ * needs to be freed by the caller.
+ * This provides a similar usage model to mem_chunk()
+ *
+- * Returns pointer to buffer of max_len bytes, or NULL on error
++ * Returns pointer to buffer of max_len bytes, or NULL on error, and
++ * sets max_len to the length actually read.
+ *
+ */
+-void *read_file(size_t max_len, const char *filename)
++void *read_file(size_t *max_len, const char *filename)
+ {
+ int fd;
+ size_t r2 = 0;
+@@ -115,7 +116,7 @@ void *read_file(size_t max_len, const char *filename)
+ return(NULL);
+ }
+
+- if ((p = malloc(max_len)) == NULL)
++ if ((p = malloc(*max_len)) == NULL)
+ {
+ perror("malloc");
+ return NULL;
+@@ -123,7 +124,7 @@ void *read_file(size_t max_len, const char *filename)
+
+ do
+ {
+- r = read(fd, p + r2, max_len - r2);
++ r = read(fd, p + r2, *max_len - r2);
+ if (r == -1)
+ {
+ if (errno != EINTR)
+@@ -140,6 +141,8 @@ void *read_file(size_t max_len, const char *filename)
+ while (r != 0);
+
+ close(fd);
++ *max_len = r2;
++
+ return p;
+ }
+
+diff --git a/util.h b/util.h
+index 9d409cd..b8748f1 100644
+--- a/util.h
++++ b/util.h
+@@ -25,7 +25,7 @@
+ #define ARRAY_SIZE(x) (sizeof(x)/sizeof((x)[0]))
+
+ int checksum(const u8 *buf, size_t len);
+-void *read_file(size_t len, const char *filename);
++void *read_file(size_t *len, const char *filename);
+ void *mem_chunk(off_t base, size_t len, const char *devmem);
+ int write_dump(size_t base, size_t len, const void *data, const char *dumpfile, int add);
+ u64 u64_range(u64 start, u64 end);
+--
+2.6.4
+