main/fcgi: security fix for CVE-2012-6687

ref #3971
This commit is contained in:
Natanael Copa 2015-03-11 10:05:18 +00:00
parent a55b66a92f
commit f5ea0fe91c
2 changed files with 96 additions and 5 deletions

View File

@ -2,7 +2,7 @@
# Maintainer: Carlo Landmeter <clandmeter@gmail.com>
pkgname=fcgi
pkgver=2.4.0
pkgrel=7
pkgrel=8
pkgdesc="FAST CGI(fcgi) is a language independent, high performant extension to CGI"
url="http://www.fastcgi.com"
arch="all"
@ -15,7 +15,9 @@ source="http://www.fastcgi.com/dist/${pkgname}-${pkgver}.tar.gz
fcgi-2.4.0-gcc44_fixes.patch
fcgi-2.4.0-Makefile.am-CPPFLAGS.patch
20-fcgi-2.4.0-clientdata-pointer.patch
30-fcgi-2.4.0-html-updates.patch"
30-fcgi-2.4.0-html-updates.patch
CVE-2012-6687.patch
"
prepare() {
cd "$srcdir/$pkgname-$pkgver"
@ -67,16 +69,19 @@ md5sums="d15060a813b91383a9f3c66faf84867e fcgi-2.4.0.tar.gz
2e72c834db21da6af3f77dd2b36727a2 fcgi-2.4.0-gcc44_fixes.patch
8c07165aed574b853326ae25fe9af291 fcgi-2.4.0-Makefile.am-CPPFLAGS.patch
d2654525f06451c99b8cdd4cc00a963b 20-fcgi-2.4.0-clientdata-pointer.patch
f26b536786f70b30a2d91c83d56e944c 30-fcgi-2.4.0-html-updates.patch"
f26b536786f70b30a2d91c83d56e944c 30-fcgi-2.4.0-html-updates.patch
02900e5f2400ed2982db1e02c4a17aa8 CVE-2012-6687.patch"
sha256sums="66fc45c6b36a21bf2fbbb68e90f780cc21a9da1fffbae75e76d2b4402d3f05b9 fcgi-2.4.0.tar.gz
5dfa0465d08b4d87e4e30caefa3702c73e8f7eb634f584305fccd3b63ee65e24 configure.patch
c31eb921a662b53401a88caafbadb16b02ae809d25d0b6d8b1ac96d20803e9d5 fcgi-2.4.0-gcc44_fixes.patch
df132dec038246ce9526f311c5d00ec103427111722c476f78069d7f1386529f fcgi-2.4.0-Makefile.am-CPPFLAGS.patch
27936406b5fcb13096bbdd80ee7eb0cf262e5c2b983e79e41d17a3cd17387683 20-fcgi-2.4.0-clientdata-pointer.patch
df8b2eb4c017fedf6f27a5650e2f4f5636e66ec7d02d20a50282edbc8d636c69 30-fcgi-2.4.0-html-updates.patch"
df8b2eb4c017fedf6f27a5650e2f4f5636e66ec7d02d20a50282edbc8d636c69 30-fcgi-2.4.0-html-updates.patch
7fc1e0af1c71d7b86d1a90595fbadedbb01db0731b9e91b17fb5437680bb4e96 CVE-2012-6687.patch"
sha512sums="38164d11112e834b30c6f809da4e184021e8d22ec8db2c49ad827895a75b99dc1824b94831304aa0ae1174176fe64d02a12882b1a00b780119600bdc39a90927 fcgi-2.4.0.tar.gz
57ae87e526c6fbc39b81b93b0fa2d159315f4d06f9a58053a5636bb3377955c3d92024f2363af483bf4c22b7f3c888d1f1505e265f77e8a1b690740cf5909959 configure.patch
6dafc960c30c1c9f5e09eff0fa71a0202265e063b9ccc56b82d58961f4a2e290734dcea06bd45ea58abc5a394db6edbaed4ccac5dc1fcfa22f0595917fa24243 fcgi-2.4.0-gcc44_fixes.patch
04886b4aa5fab4aca7ef8834b73c1b8d899fcfd8072934a9b337913306335e53e5b24069af6c7e7ac37272bb6bbd9fe0eb82704255a58c344fb964846f925255 fcgi-2.4.0-Makefile.am-CPPFLAGS.patch
c5339ae940994daeec4cf8030933ca2ab5a00651b91eb5d2ff3b871673b5a62646bfb8e81c190ad6d83015fcf59df4076bc745f097ddcada220ca0dc4a05db6a 20-fcgi-2.4.0-clientdata-pointer.patch
79abe9f43150b3163e92030cc9afbee90f69f04bd487254d187abda6fa3484623f605394c96eeb6fd4203d2b06f7e771c9b46f9c21b03cde1aa043da9b3e8d5e 30-fcgi-2.4.0-html-updates.patch"
79abe9f43150b3163e92030cc9afbee90f69f04bd487254d187abda6fa3484623f605394c96eeb6fd4203d2b06f7e771c9b46f9c21b03cde1aa043da9b3e8d5e 30-fcgi-2.4.0-html-updates.patch
119cc765d330d7324c1a8aeb87492d270ee43b23e3d2036445b6f494e2fe8031093fbc0af78b137588c28ecddde2e85ff932a851840896e105efc14403e05a68 CVE-2012-6687.patch"

View File

@ -0,0 +1,86 @@
Author: Anton Kortunov <toshic.toshic@gmail.com>
Bug-Ubuntu: https://bugs.launchpad.net/ubuntu/+source/libfcgi/+bug/933417
Description: use poll in os_unix.c instead of select to avoid problem with > 1024 connections
Forwarded: yes, fastcgi-developers@mailman.fastcgi.com
diff --git a/libfcgi/os_unix.c b/libfcgi/os_unix.c
index 73e6a7f..af35aee 100755
--- a/libfcgi/os_unix.c
+++ b/libfcgi/os_unix.c
@@ -42,6 +42,7 @@ static const char rcsid[] = "$Id: os_unix.c,v 1.37 2002/03/05 19:14:49 robs Exp
#include <sys/time.h>
#include <sys/un.h>
#include <signal.h>
+#include <poll.h>
#ifdef HAVE_NETDB_H
#include <netdb.h>
@@ -103,6 +104,9 @@ static int volatile maxFd = -1;
static int shutdownPending = FALSE;
static int shutdownNow = FALSE;
+static int libfcgiOsClosePollTimeout = 2000;
+static int libfcgiIsAfUnixKeeperPollTimeout = 2000;
+
void OS_ShutdownPending()
{
shutdownPending = TRUE;
@@ -168,6 +172,16 @@ int OS_LibInit(int stdioFds[3])
if(libInitialized)
return 0;
+ char *libfcgiOsClosePollTimeoutStr = getenv( "LIBFCGI_OS_CLOSE_POLL_TIMEOUT" );
+ if(libfcgiOsClosePollTimeoutStr) {
+ libfcgiOsClosePollTimeout = atoi(libfcgiOsClosePollTimeoutStr);
+ }
+
+ char *libfcgiIsAfUnixKeeperPollTimeoutStr = getenv( "LIBFCGI_IS_AF_UNIX_KEEPER_POLL_TIMEOUT" );
+ if(libfcgiIsAfUnixKeeperPollTimeoutStr) {
+ libfcgiIsAfUnixKeeperPollTimeout = atoi(libfcgiIsAfUnixKeeperPollTimeoutStr);
+ }
+
asyncIoTable = (AioInfo *)malloc(asyncIoTableSize * sizeof(AioInfo));
if(asyncIoTable == NULL) {
errno = ENOMEM;
@@ -755,19 +769,16 @@ int OS_Close(int fd)
if (shutdown(fd, 1) == 0)
{
- struct timeval tv;
- fd_set rfds;
+ struct pollfd pfd;
int rv;
char trash[1024];
- FD_ZERO(&rfds);
+ pfd.fd = fd;
+ pfd.events = POLLIN;
do
{
- FD_SET(fd, &rfds);
- tv.tv_sec = 2;
- tv.tv_usec = 0;
- rv = select(fd + 1, &rfds, NULL, NULL, &tv);
+ rv = poll(&pfd, 1, libfcgiOsClosePollTimeout);
}
while (rv > 0 && read(fd, trash, sizeof(trash)) > 0);
}
@@ -1116,13 +1127,11 @@ static int is_reasonable_accept_errno (const int error)
*/
static int is_af_unix_keeper(const int fd)
{
- struct timeval tval = { READABLE_UNIX_FD_DROP_DEAD_TIMEVAL };
- fd_set read_fds;
-
- FD_ZERO(&read_fds);
- FD_SET(fd, &read_fds);
+ struct pollfd pfd;
+ pfd.fd = fd;
+ pfd.events = POLLIN;
- return select(fd + 1, &read_fds, NULL, NULL, &tval) >= 0 && FD_ISSET(fd, &read_fds);
+ return poll(&pfd, 1, libfcgiIsAfUnixKeeperPollTimeout) >= 0 && (pfd.revents & POLLIN);
}
/*