1 |
commit: 038c9f3140b69054f3de9cb4f1a6ccf292510952 |
2 |
Author: Thomas Deutschmann <whissi <AT> gentoo <DOT> org> |
3 |
AuthorDate: Thu Mar 28 00:44:20 2019 +0000 |
4 |
Commit: Thomas Deutschmann <whissi <AT> gentoo <DOT> org> |
5 |
CommitDate: Thu Mar 28 00:44:20 2019 +0000 |
6 |
URL: https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=038c9f31 |
7 |
|
8 |
mail-filter/procmail: re-add security fix with crash fix |
9 |
|
10 |
Bug: https://bugs.gentoo.org/638108 |
11 |
Package-Manager: Portage-2.3.62, Repoman-2.3.12 |
12 |
Signed-off-by: Thomas Deutschmann <whissi <AT> gentoo.org> |
13 |
|
14 |
.../procmail/files/procmail-3.22-crash-fix.patch | 58 ++++++++++ |
15 |
mail-filter/procmail/procmail-3.22-r13.ebuild | 125 +++++++++++++++++++++ |
16 |
2 files changed, 183 insertions(+) |
17 |
|
18 |
diff --git a/mail-filter/procmail/files/procmail-3.22-crash-fix.patch b/mail-filter/procmail/files/procmail-3.22-crash-fix.patch |
19 |
new file mode 100644 |
20 |
index 00000000000..8563ea3d1d4 |
21 |
--- /dev/null |
22 |
+++ b/mail-filter/procmail/files/procmail-3.22-crash-fix.patch |
23 |
@@ -0,0 +1,58 @@ |
24 |
+diff --git a/src/cstdio.c b/src/cstdio.c |
25 |
+index 7b6fe6d..0a0bd5b 100644 |
26 |
+--- a/src/cstdio.c |
27 |
++++ b/src/cstdio.c |
28 |
+@@ -144,7 +144,7 @@ int getbl(p,end)char*p,*end; /* my gets */ |
29 |
+ { case '\n':case EOF:*q='\0'; |
30 |
+ return overflow?-1:p!=q; /* did we read anything at all? */ |
31 |
+ } |
32 |
+- if(q==end) /* check here so that a trailing backslash won't be lost */ |
33 |
++ if(q>=end) /* check here so that a trailing backslash won't be lost */ |
34 |
+ q=p,overflow=1; |
35 |
+ *q++=i; |
36 |
+ } |
37 |
+@@ -199,7 +199,7 @@ int getlline(target,end)char*target,*end; |
38 |
+ if(*(target=strchr(target,'\0')-1)=='\\') |
39 |
+ { if(chp2!=target) /* non-empty line? */ |
40 |
+ target++; /* then preserve the backslash */ |
41 |
+- if(target>end-2) /* space enough for getbl? */ |
42 |
++ if(target>=end-2) /* space enough for getbl? */ |
43 |
+ target=end-linebuf,overflow=1; /* toss what we have */ |
44 |
+ continue; |
45 |
+ } |
46 |
+diff --git a/src/formail.c b/src/formail.c |
47 |
+index 1f5c9dd..49b9967 100644 |
48 |
+--- a/src/formail.c |
49 |
++++ b/src/formail.c |
50 |
+@@ -219,7 +219,8 @@ static char*getsender(namep,fldp,headreply)char*namep;struct field*fldp; |
51 |
+ if(i>=0&&(i!=maxindex(sest)||fldp==rdheader)) /* found anything? */ |
52 |
+ { char*saddr;char*tmp; /* determine the weight */ |
53 |
+ nowm=areply&&headreply?headreply==1?sest[i].wrepl:sest[i].wrrepl:i;chp+=j; |
54 |
+- tmp=malloc(j=fldp->Tot_len-j);tmemmove(tmp,chp,j);(chp=tmp)[j-1]='\0'; |
55 |
++ tmp=malloc((j=fldp->Tot_len-j) + 1);tmemmove(tmp,chp,j);(chp=tmp)[j-1]='\0'; |
56 |
++ chp[j]='\0'; |
57 |
+ if(sest[i].head==From_) |
58 |
+ { char*pastad; |
59 |
+ if(strchr(saddr=chp,'\n')) /* multiple From_ lines */ |
60 |
+@@ -364,7 +365,7 @@ static PROGID; |
61 |
+ |
62 |
+ int main(lastm,argv)int lastm;const char*const argv[]; |
63 |
+ { int i,split=0,force=0,bogus=1,every=0,headreply=0,digest=0,nowait=0,keepb=0, |
64 |
+- minfields=(char*)progid-(char*)progid,conctenate=0,babyl=0,babylstart, |
65 |
++ minfields=(char*)progid-(char*)progid,conctenate=0,babyl=0,babylstart=0, |
66 |
+ berkeley=0,forgetclen; |
67 |
+ long maxlen,ctlength;FILE*idcache=0;pid_t thepid; |
68 |
+ size_t j,lnl,escaplen;char*chp,*namep,*escap=ESCAP; |
69 |
+diff --git a/src/formisc.c b/src/formisc.c |
70 |
+index c48df52..5c2869d 100644 |
71 |
+--- a/src/formisc.c |
72 |
++++ b/src/formisc.c |
73 |
+@@ -66,7 +66,7 @@ inc: start++; |
74 |
+ retz: *target='\0'; |
75 |
+ ret: return start; |
76 |
+ } |
77 |
+- if(*start=='\\') |
78 |
++ if(*start=='\\' && *(start + 1)) |
79 |
+ *target++='\\',start++; |
80 |
+ hitspc=2; |
81 |
+ goto normal; /* normal word */ |
82 |
|
83 |
diff --git a/mail-filter/procmail/procmail-3.22-r13.ebuild b/mail-filter/procmail/procmail-3.22-r13.ebuild |
84 |
new file mode 100644 |
85 |
index 00000000000..9597d1ca647 |
86 |
--- /dev/null |
87 |
+++ b/mail-filter/procmail/procmail-3.22-r13.ebuild |
88 |
@@ -0,0 +1,125 @@ |
89 |
+# Copyright 1999-2019 Gentoo Authors |
90 |
+# Distributed under the terms of the GNU General Public License v2 |
91 |
+ |
92 |
+EAPI=6 |
93 |
+ |
94 |
+inherit flag-o-matic toolchain-funcs prefix |
95 |
+ |
96 |
+DESCRIPTION="Mail delivery agent/filter" |
97 |
+HOMEPAGE="http://www.procmail.org/" |
98 |
+SRC_URI="http://www.procmail.org/${P}.tar.gz" |
99 |
+ |
100 |
+LICENSE="|| ( Artistic GPL-2 )" |
101 |
+SLOT="0" |
102 |
+KEYWORDS="~alpha ~amd64 ~arm ~hppa ~ia64 ~mips ~ppc ~ppc64 ~s390 ~sh ~sparc ~x86 ~amd64-linux ~x86-linux ~ppc-macos ~x86-macos ~sparc-solaris ~sparc64-solaris ~x86-solaris" |
103 |
+IUSE="mbox selinux" |
104 |
+ |
105 |
+DEPEND="virtual/mta" |
106 |
+RDEPEND="selinux? ( sec-policy/selinux-procmail )" |
107 |
+ |
108 |
+src_prepare() { |
109 |
+ # disable flock, using both fcntl and flock style locking |
110 |
+ # doesn't work with NFS with 2.6.17+ kernels, bug #156493 |
111 |
+ |
112 |
+ sed -e "s:/\*#define NO_flock_LOCK:#define NO_flock_LOCK:" \ |
113 |
+ -i config.h || die "sed failed" |
114 |
+ |
115 |
+ if ! use mbox ; then |
116 |
+ echo "# Use maildir-style mailbox in user's home directory" > "${S}"/procmailrc || die |
117 |
+ echo 'DEFAULT=$HOME/.maildir/' >> "${S}"/procmailrc || die |
118 |
+ cd "${S}" || die |
119 |
+ eapply "${FILESDIR}/gentoo-maildir3.diff" |
120 |
+ else |
121 |
+ echo '# Use mbox-style mailbox in /var/spool/mail' > "${S}"/procmailrc || die |
122 |
+ echo 'DEFAULT=${EPREFIX}/var/spool/mail/$LOGNAME' >> "${S}"/procmailrc || die |
123 |
+ fi |
124 |
+ |
125 |
+ # Do not use lazy bindings on lockfile and procmail |
126 |
+ if [[ ${CHOST} != *-darwin* ]]; then |
127 |
+ eapply -p0 "${FILESDIR}/${PN}-lazy-bindings.diff" |
128 |
+ fi |
129 |
+ |
130 |
+ # Fix for bug #102340 |
131 |
+ eapply -p0 "${FILESDIR}/${PN}-comsat-segfault.diff" |
132 |
+ |
133 |
+ # Fix for bug #119890 |
134 |
+ eapply -p0 "${FILESDIR}/${PN}-maxprocs-fix.diff" |
135 |
+ |
136 |
+ # Prefixify config.h |
137 |
+ eapply -p0 "${FILESDIR}"/${PN}-prefix.patch |
138 |
+ eprefixify config.h Makefile src/autoconf src/recommend.c |
139 |
+ |
140 |
+ # Fix for bug #200006 |
141 |
+ eapply "${FILESDIR}/${PN}-pipealloc.diff" |
142 |
+ |
143 |
+ # Fix for bug #270551 |
144 |
+ eapply "${FILESDIR}/${PN}-3.22-glibc-2.10.patch" |
145 |
+ |
146 |
+ # Fix security bugs #522114 and #638108 |
147 |
+ eapply "${FILESDIR}/${PN}-CVE-2014-3618-16844.patch" |
148 |
+ |
149 |
+ eapply "${FILESDIR}/${PN}-3.22-crash-fix.patch" |
150 |
+ |
151 |
+ eapply_user |
152 |
+} |
153 |
+ |
154 |
+src_compile() { |
155 |
+ # -finline-functions (implied by -O3) leaves strstr() in an infinite loop. |
156 |
+ # To work around this, we append -fno-inline-functions to CFLAGS |
157 |
+ # Since GCC 4.7 we also need -fno-ipa-cp-clone (bug #466552) |
158 |
+ # If it's clang, ignore -fno-ipa-cp-clone, as clang doesn't support this |
159 |
+ case "$(tc-getCC)" in |
160 |
+ "clang") append-flags -fno-inline-functions ;; |
161 |
+ "gcc"|*) append-flags -fno-inline-functions -fno-ipa-cp-clone ;; |
162 |
+ esac |
163 |
+ |
164 |
+ sed -e "s:CFLAGS0 = -O:CFLAGS0 = ${CFLAGS}:" \ |
165 |
+ -e "s:LDFLAGS0= -s:LDFLAGS0 = ${LDFLAGS}:" \ |
166 |
+ -e "s:LOCKINGTEST=__defaults__:#LOCKINGTEST=__defaults__:" \ |
167 |
+ -e "s:#LOCKINGTEST=/tmp:LOCKINGTEST=/tmp:" \ |
168 |
+ -i Makefile || die "sed failed" |
169 |
+ |
170 |
+ emake CC="$(tc-getCC)" |
171 |
+} |
172 |
+ |
173 |
+src_install() { |
174 |
+ cd "${S}"/new || die |
175 |
+ insinto /usr/bin |
176 |
+ insopts -m 6755 |
177 |
+ doins procmail |
178 |
+ |
179 |
+ doins lockfile |
180 |
+ fowners root:mail /usr/bin/lockfile |
181 |
+ fperms 2755 /usr/bin/lockfile |
182 |
+ |
183 |
+ dobin formail mailstat |
184 |
+ insopts -m 0644 |
185 |
+ |
186 |
+ doman *.1 *.5 |
187 |
+ |
188 |
+ cd "${S}" || die |
189 |
+ dodoc FAQ FEATURES HISTORY INSTALL KNOWN_BUGS README |
190 |
+ |
191 |
+ insinto /etc |
192 |
+ doins procmailrc |
193 |
+ |
194 |
+ docinto examples |
195 |
+ dodoc examples/* |
196 |
+} |
197 |
+ |
198 |
+pkg_postinst() { |
199 |
+ if ! use mbox ; then |
200 |
+ elog "Starting with mail-filter/procmail-3.22-r9 you'll need to ensure" |
201 |
+ elog "that you configure a mail storage location using DEFAULT in" |
202 |
+ elog "/etc/procmailrc, for example:" |
203 |
+ elog "\tDEFAULT=\$HOME/.maildir/" |
204 |
+ fi |
205 |
+ if has sfperms ${FEATURES}; then |
206 |
+ ewarn "FEATURES=sfperms removes the read-bit for others from" |
207 |
+ ewarn " /usr/bin/procmail" |
208 |
+ ewarn " /usr/bin/lockfile" |
209 |
+ ewarn "If you use procmail from an MTA like Exim, you need to" |
210 |
+ ewarn "re-add the read-bit or avoid the MTA checking the binary" |
211 |
+ ewarn "exists." |
212 |
+ fi |
213 |
+} |