summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJörg Frings-Fürst <debian@jff-webhosting.net>2015-10-01 07:43:34 +0200
committerJörg Frings-Fürst <debian@jff-webhosting.net>2015-10-01 07:43:34 +0200
commite1693fee448e9bb110474f05363110c6d82dd5d1 (patch)
treef8ba9d27ce54938ec568ff4e4af4225d97b16d52
parent5a084476431d592344b3063468b6c3993fd76495 (diff)
new patch 05-dmidecode-avoid-sigbus.patch
-rw-r--r--debian/changelog9
-rw-r--r--debian/patches/05-dmidecode-avoid-sigbus.patch50
-rw-r--r--debian/patches/series1
3 files changed, 59 insertions, 1 deletions
diff --git a/debian/changelog b/debian/changelog
index f24510c..bb7df08 100644
--- a/debian/changelog
+++ b/debian/changelog
@@ -1,3 +1,10 @@
+dmidecode (3.0-2) unstable; urgency=medium
+
+ * New debian/patches/05-dmidecode-avoid-sigbus.patch (Closes: #796963):
+ - Avoid SIGBUS on mmap failure
+
+ -- Jörg Frings-Fürst <debian@jff-webhosting.net> Thu, 01 Oct 2015 07:42:13 +0200
+
dmidecode (3.0-1) unstable; urgency=medium
* Correct typo at debian/changelog.
@@ -17,7 +24,7 @@ dmidecode (3.0-1) unstable; urgency=medium
* New debian/upstream/metadata:
- Add some DEP-12 upstream metadata.
- -- Jörg Frings-Fürst <debian@jff-webhosting.net> Mon, 28 Sep 2015 14:38:46 +0200
+ -- Jörg Frings-Fürst <debian@jff-webhosting.net> Tue, 29 Sep 2015 05:42:43 +0200
dmidecode (2.12-4) unstable; urgency=low
diff --git a/debian/patches/05-dmidecode-avoid-sigbus.patch b/debian/patches/05-dmidecode-avoid-sigbus.patch
new file mode 100644
index 0000000..518d972
--- /dev/null
+++ b/debian/patches/05-dmidecode-avoid-sigbus.patch
@@ -0,0 +1,50 @@
+Description: Avoid SIGBUS on mmap failure
+ mmap will fail with SIGBUS if trying to map a non-existent portion of
+ a file. While this should never happen with /dev/mem, it can happen if
+ passing a regular file with option -d. While people should no longer
+ do that, failure gracefully seems better than crashing. So check for
+ the file size before calling mmap.
+Author: Jean Delvare <jdelvare@suse.de>
+Origin: https://savannah.nongnu.org/bugs/download.php?file_id=35008
+Bug: https://savannah.nongnu.org/bugs/index.php?46066
+Bug-Debian: https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=796963
+Last-Update: 2015-10-01
+----
+This patch header follows DEP-3: http://dep.debian.net/deps/dep3/
+--- dmidecode.orig/util.c 2015-09-29 11:27:02.136566009 +0200
++++ dmidecode/util.c 2015-09-29 11:37:24.746191083 +0200
+@@ -152,6 +152,7 @@ void *mem_chunk(off_t base, size_t len,
+ void *p;
+ int fd;
+ #ifdef USE_MMAP
++ struct stat statbuf;
+ off_t mmoffset;
+ void *mmp;
+ #endif
+@@ -169,6 +170,26 @@ void *mem_chunk(off_t base, size_t len,
+ }
+
+ #ifdef USE_MMAP
++ if (fstat(fd, &statbuf) == -1)
++ {
++ fprintf(stderr, "%s: ", devmem);
++ perror("stat");
++ free(p);
++ return NULL;
++ }
++
++ /*
++ * mmap() will fail with SIGBUS if trying to map beyond the end of
++ * the file.
++ */
++ if (S_ISREG(statbuf.st_mode) && base + (off_t)len > statbuf.st_size)
++ {
++ fprintf(stderr, "mmap: Can't map beyond end of file %s\n",
++ devmem);
++ free(p);
++ return NULL;
++ }
++
+ #ifdef _SC_PAGESIZE
+ mmoffset = base % sysconf(_SC_PAGESIZE);
+ #else
diff --git a/debian/patches/series b/debian/patches/series
index e95b363..41f2000 100644
--- a/debian/patches/series
+++ b/debian/patches/series
@@ -1,3 +1,4 @@
01-ansi-c.patch
02-hurd.patch
03-build.patch
+05-dmidecode-avoid-sigbus.patch