Gentoo Archives: gentoo-commits

From: Andrew Savchenko <bircoph@g.o>
To: gentoo-commits@l.g.o
Subject: [gentoo-commits] repo/gentoo:master commit in: sys-fs/e4rat/, sys-fs/e4rat/files/
Date: Sun, 12 Feb 2017 00:06:03
Message-Id: 1486857933.01bb8c32471a29081be7d77f52e0f95da371b1cf.bircoph@gentoo
1 commit: 01bb8c32471a29081be7d77f52e0f95da371b1cf
2 Author: Andrew Savchenko <bircoph <AT> gentoo <DOT> org>
3 AuthorDate: Sun Feb 12 00:05:33 2017 +0000
4 Commit: Andrew Savchenko <bircoph <AT> gentoo <DOT> org>
5 CommitDate: Sun Feb 12 00:05:33 2017 +0000
6 URL: https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=01bb8c32
7
8 sys-fs/e4rat: fix memory corruption
9
10 It is unsafe to use Config::get<T>(arg)c_str() pointer
11 directly, since it may be overwritten by later get calls.
12
13 Package-Manager: Portage-2.3.3, Repoman-2.3.1
14 Signed-off-by: Andrew Savchenko <bircoph <AT> gentoo.org>
15
16 sys-fs/e4rat/e4rat-0.2.4_pre20141201-r1.ebuild | 64 ++++++++++++++++++++++++++
17 sys-fs/e4rat/files/e4rat-0.2.4-strdup.patch | 41 +++++++++++++++++
18 2 files changed, 105 insertions(+)
19
20 diff --git a/sys-fs/e4rat/e4rat-0.2.4_pre20141201-r1.ebuild b/sys-fs/e4rat/e4rat-0.2.4_pre20141201-r1.ebuild
21 new file mode 100644
22 index 0000000000..6792b38e4e
23 --- /dev/null
24 +++ b/sys-fs/e4rat/e4rat-0.2.4_pre20141201-r1.ebuild
25 @@ -0,0 +1,64 @@
26 +# Copyright 1999-2017 Gentoo Foundation
27 +# Distributed under the terms of the GNU General Public License v2
28 +# $Id$
29 +
30 +EAPI=6
31 +inherit cmake-utils linux-info readme.gentoo-r1
32 +
33 +DESCRIPTION="Toolset to accelerate the boot process and application startup"
34 +HOMEPAGE="http://e4rat.sourceforge.net/"
35 +#SRC_URI="mirror://sourceforge/${PN}/${P/-/_}_src.tar.gz"
36 +SRC_URI="https://dev.gentoo.org/~pacho/${PN}/${PN}-0.2.4_pre20141201.tar.xz"
37 +
38 +LICENSE="GPL-3"
39 +SLOT="0"
40 +KEYWORDS="~amd64 ~x86"
41 +IUSE=""
42 +
43 +RDEPEND="
44 + dev-lang/perl:=
45 + >=dev-libs/boost-1.42:=
46 + sys-fs/e2fsprogs
47 + sys-process/audit[static-libs(+)]
48 + sys-process/lsof
49 +"
50 +DEPEND="${DEPEND}"
51 +
52 +CONFIG_CHECK="~AUDITSYSCALL"
53 +
54 +PATCHES=(
55 + "${FILESDIR}"/${PN}-0.2.2-shared-build.patch
56 + "${FILESDIR}"/${PN}-0.2.2-libdir.patch
57 + "${FILESDIR}"/${PN}-0.2.4-sysmacros.patch #580534
58 + "${FILESDIR}"/${PN}-0.2.4-gcc6.patch #594046
59 + "${FILESDIR}"/${PN}-0.2.4-strdup.patch
60 +)
61 +
62 +pkg_setup() {
63 + check_extra_config
64 + DOC_CONTENTS="
65 + To launch systemd from e4rat you simply need to edit /etc/e4rat.conf
66 + and set:\n
67 + ; path to init process binary (DEFAULT: /sbin/init)\n
68 + init /usr/lib/systemd/systemd"
69 +}
70 +
71 +src_install() {
72 + cmake-utils_src_install
73 + # relocate binaries to /sbin. If someone knows of a better way to do it
74 + # please do tell me
75 + dodir sbin
76 + find "${D}"/usr/sbin -type f -exec mv {} "${D}"/sbin/. \; \
77 + || die
78 +
79 + readme.gentoo_create_doc
80 +}
81 +
82 +pkg_postinst() {
83 + readme.gentoo_print_elog
84 + if has_version sys-apps/preload; then
85 + elog "It appears you have sys-apps/preload installed. This may"
86 + elog "has negative effects on ${PN}. You may want to disable preload"
87 + elog "when using ${PN}."
88 + fi
89 +}
90
91 diff --git a/sys-fs/e4rat/files/e4rat-0.2.4-strdup.patch b/sys-fs/e4rat/files/e4rat-0.2.4-strdup.patch
92 new file mode 100644
93 index 0000000000..c3a9cd0e8c
94 --- /dev/null
95 +++ b/sys-fs/e4rat/files/e4rat-0.2.4-strdup.patch
96 @@ -0,0 +1,41 @@
97 +--- e4rat-0.2.4_pre20141201/src/e4rat-collect.cc.orig 2014-11-24 12:12:12.000000000 +0300
98 ++++ e4rat-0.2.4_pre20141201/src/e4rat-collect.cc 2017-02-12 02:16:25.151757182 +0300
99 +@@ -32,6 +32,7 @@
100 + #include <fcntl.h>
101 + #include <fstream>
102 + #include <signal.h>
103 ++#include <cstring>
104 +
105 + /* EXT2_SUPER_MAGIC */
106 + #include <ext2fs/ext2_fs.h>
107 +@@ -361,7 +362,9 @@
108 + {
109 + create_pid_late = true;
110 +
111 +- outPath = Config::get<std::string>("startup_log_file").c_str();
112 ++ // It is unsafe to use Config::get<T>(arg)c_str() pointer
113 ++ // directly, since it may be overwritten by later get calls.
114 ++ outPath = strdup(Config::get<std::string>("startup_log_file").c_str());
115 + verbose = 0;
116 + }
117 + else
118 +--- e4rat-0.2.4_pre20141201/src/e4rat-preload.cc.orig 2014-11-24 12:12:12.000000000 +0300
119 ++++ e4rat-0.2.4_pre20141201/src/e4rat-preload.cc 2017-02-12 02:16:38.425552630 +0300
120 +@@ -25,6 +25,7 @@
121 +
122 + #include <iostream>
123 + #include <fstream>
124 ++#include <cstring>
125 +
126 + #include <sys/types.h>
127 + #include <sys/stat.h>
128 +@@ -227,7 +228,8 @@
129 + try {
130 + if(getpid() == 1)
131 + {
132 +- const char* logfile = Config::get<std::string>("startup_log_file").c_str();
133 ++ // pointer may change, string must be copied
134 ++ const char* logfile = strdup(Config::get<std::string>("startup_log_file").c_str());
135 + notice("Open %s ... ", logfile);
136 + FILE* infile = fopen(logfile, "r");
137 + if(!infile)