summaryrefslogtreecommitdiffstats
path: root/source/ap/dmidecode/patches/0003-Fix-error-paths-in-mem_chunk.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/0003-Fix-error-paths-in-mem_chunk.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/0003-Fix-error-paths-in-mem_chunk.patch')
-rw-r--r--source/ap/dmidecode/patches/0003-Fix-error-paths-in-mem_chunk.patch88
1 files changed, 88 insertions, 0 deletions
diff --git a/source/ap/dmidecode/patches/0003-Fix-error-paths-in-mem_chunk.patch b/source/ap/dmidecode/patches/0003-Fix-error-paths-in-mem_chunk.patch
new file mode 100644
index 000000000..7b4e418e6
--- /dev/null
+++ b/source/ap/dmidecode/patches/0003-Fix-error-paths-in-mem_chunk.patch
@@ -0,0 +1,88 @@
+From 458f73d58c24a7addce82bf1e8bfb8c2554ca458 Mon Sep 17 00:00:00 2001
+From: Jean Delvare <jdelvare@suse.de>
+Date: Wed, 14 Oct 2015 14:37:09 +0200
+Subject: [PATCH 3/9] Fix error paths in mem_chunk
+
+Use a common error path in function mem_chunk, to make sure it does
+not leak memory and does not leave an opened file descriptor behind,
+without duplicating the cleaning code.
+---
+ CHANGELOG | 1 +
+ util.c | 24 ++++++++++--------------
+ 2 files changed, 11 insertions(+), 14 deletions(-)
+
+diff --git a/CHANGELOG b/CHANGELOG
+index aa1c28f..c940c9f 100644
+--- a/CHANGELOG
++++ b/CHANGELOG
+@@ -3,6 +3,7 @@
+ * util.c: Avoid SIGBUS on mmap failure.
+ This fixes Savannah bug #46066:
+ https://savannah.nongnu.org/bugs/?46066
++ * util.c: Fix error paths in mem_chunk.
+
+ 2015-10-01 Roy Franz <roy.franz@linaro.org>
+
+diff --git a/util.c b/util.c
+index 5795d02..f97ac0d 100644
+--- a/util.c
++++ b/util.c
+@@ -166,7 +166,7 @@ void *mem_chunk(off_t base, size_t len, const char *devmem)
+ if ((p = malloc(len)) == NULL)
+ {
+ perror("malloc");
+- return NULL;
++ goto out;
+ }
+
+ #ifdef USE_MMAP
+@@ -174,8 +174,7 @@ void *mem_chunk(off_t base, size_t len, const char *devmem)
+ {
+ fprintf(stderr, "%s: ", devmem);
+ perror("stat");
+- free(p);
+- return NULL;
++ goto err_free;
+ }
+
+ /*
+@@ -186,8 +185,7 @@ void *mem_chunk(off_t base, size_t len, const char *devmem)
+ {
+ fprintf(stderr, "mmap: Can't map beyond end of file %s\n",
+ devmem);
+- free(p);
+- return NULL;
++ goto err_free;
+ }
+
+ #ifdef _SC_PAGESIZE
+@@ -220,19 +218,17 @@ try_read:
+ {
+ fprintf(stderr, "%s: ", devmem);
+ perror("lseek");
+- free(p);
+- return NULL;
++ goto err_free;
+ }
+
+- if (myread(fd, p, len, devmem) == -1)
+- {
+- free(p);
+- return NULL;
+- }
++ if (myread(fd, p, len, devmem) == 0)
++ goto out;
++
++err_free:
++ free(p);
++ p = NULL;
+
+-#ifdef USE_MMAP
+ out:
+-#endif
+ if (close(fd) == -1)
+ perror(devmem);
+
+--
+2.6.4
+