summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndrew Savchenko <bircoph@gentoo.org>2017-02-12 03:05:33 +0300
committerAndrew Savchenko <bircoph@gentoo.org>2017-02-12 03:05:33 +0300
commit01bb8c32471a29081be7d77f52e0f95da371b1cf (patch)
tree1bb86e89ad4230f33778acf2931b2775c900f46c /sys-fs/e4rat/files
parentkde-apps/cantor: Fix build w/ USE=julia and KF-5.31 (diff)
downloadgentoo-01bb8c32471a29081be7d77f52e0f95da371b1cf.tar.gz
gentoo-01bb8c32471a29081be7d77f52e0f95da371b1cf.tar.bz2
gentoo-01bb8c32471a29081be7d77f52e0f95da371b1cf.zip
sys-fs/e4rat: fix memory corruption
It is unsafe to use Config::get<T>(arg)c_str() pointer directly, since it may be overwritten by later get calls. Package-Manager: Portage-2.3.3, Repoman-2.3.1 Signed-off-by: Andrew Savchenko <bircoph@gentoo.org>
Diffstat (limited to 'sys-fs/e4rat/files')
-rw-r--r--sys-fs/e4rat/files/e4rat-0.2.4-strdup.patch41
1 files changed, 41 insertions, 0 deletions
diff --git a/sys-fs/e4rat/files/e4rat-0.2.4-strdup.patch b/sys-fs/e4rat/files/e4rat-0.2.4-strdup.patch
new file mode 100644
index 000000000000..c3a9cd0e8ca0
--- /dev/null
+++ b/sys-fs/e4rat/files/e4rat-0.2.4-strdup.patch
@@ -0,0 +1,41 @@
+--- e4rat-0.2.4_pre20141201/src/e4rat-collect.cc.orig 2014-11-24 12:12:12.000000000 +0300
++++ e4rat-0.2.4_pre20141201/src/e4rat-collect.cc 2017-02-12 02:16:25.151757182 +0300
+@@ -32,6 +32,7 @@
+ #include <fcntl.h>
+ #include <fstream>
+ #include <signal.h>
++#include <cstring>
+
+ /* EXT2_SUPER_MAGIC */
+ #include <ext2fs/ext2_fs.h>
+@@ -361,7 +362,9 @@
+ {
+ create_pid_late = true;
+
+- outPath = Config::get<std::string>("startup_log_file").c_str();
++ // It is unsafe to use Config::get<T>(arg)c_str() pointer
++ // directly, since it may be overwritten by later get calls.
++ outPath = strdup(Config::get<std::string>("startup_log_file").c_str());
+ verbose = 0;
+ }
+ else
+--- e4rat-0.2.4_pre20141201/src/e4rat-preload.cc.orig 2014-11-24 12:12:12.000000000 +0300
++++ e4rat-0.2.4_pre20141201/src/e4rat-preload.cc 2017-02-12 02:16:38.425552630 +0300
+@@ -25,6 +25,7 @@
+
+ #include <iostream>
+ #include <fstream>
++#include <cstring>
+
+ #include <sys/types.h>
+ #include <sys/stat.h>
+@@ -227,7 +228,8 @@
+ try {
+ if(getpid() == 1)
+ {
+- const char* logfile = Config::get<std::string>("startup_log_file").c_str();
++ // pointer may change, string must be copied
++ const char* logfile = strdup(Config::get<std::string>("startup_log_file").c_str());
+ notice("Open %s ... ", logfile);
+ FILE* infile = fopen(logfile, "r");
+ if(!infile)