From 14a823cef884edcda74293345ca5525a8ceb859e Mon Sep 17 00:00:00 2001 From: ajacoutot Date: Tue, 20 Apr 2010 17:48:18 +0000 Subject: [PATCH] Prevent an infinite EINVAL loop, from FreeBSD. --- x11/dbus/Makefile | 4 +- x11/dbus/patches/patch-dbus_dbus-connection_c | 75 +++++++++++++++++++ 2 files changed, 78 insertions(+), 1 deletion(-) create mode 100644 x11/dbus/patches/patch-dbus_dbus-connection_c diff --git a/x11/dbus/Makefile b/x11/dbus/Makefile index 55f3ad5ca9a..7ec2371d2ec 100644 --- a/x11/dbus/Makefile +++ b/x11/dbus/Makefile @@ -1,4 +1,4 @@ -# $OpenBSD: Makefile,v 1.33 2010/04/20 14:54:21 ajacoutot Exp $ +# $OpenBSD: Makefile,v 1.34 2010/04/20 17:48:18 ajacoutot Exp $ # XXX patches/patch-configure_in disables PIE on arm/hppa. This is just a # temporary workaround until PIE works. @@ -6,6 +6,8 @@ COMMENT= message bus system DISTNAME= dbus-1.2.24 +PKGNAME= ${DISTNAME}p0 + SHARED_LIBS += dbus-1 7.1 # .7.0 CATEGORIES= x11 diff --git a/x11/dbus/patches/patch-dbus_dbus-connection_c b/x11/dbus/patches/patch-dbus_dbus-connection_c new file mode 100644 index 00000000000..7047dad5142 --- /dev/null +++ b/x11/dbus/patches/patch-dbus_dbus-connection_c @@ -0,0 +1,75 @@ +$OpenBSD: patch-dbus_dbus-connection_c,v 1.1 2010/04/20 17:48:18 ajacoutot Exp $ + +From FreeBSD: +Linux is more relaxed when it comes to the timeout argument to poll(2). +Linux will accept aby negative number to mean an infinite timeout. FreeBSD +will only accept -1. Make sure we do not pass an aribtrary negative number +to poll(2) to avoid an infinite EINVAL loop. + +--- dbus/dbus-connection.c.orig Tue Mar 23 20:01:32 2010 ++++ dbus/dbus-connection.c Tue Apr 20 19:43:43 2010 +@@ -2287,7 +2287,7 @@ _dbus_connection_block_pending_call (DBusPendingCall * + DBusConnection *connection; + dbus_uint32_t client_serial; + DBusTimeout *timeout; +- int timeout_milliseconds, elapsed_milliseconds; ++ int timeout_milliseconds, elapsed_milliseconds, remain_milliseconds; + + _dbus_assert (pending != NULL); + +@@ -2367,6 +2367,10 @@ _dbus_connection_block_pending_call (DBusPendingCall * + _dbus_get_current_time (&tv_sec, &tv_usec); + elapsed_milliseconds = (tv_sec - start_tv_sec) * 1000 + + (tv_usec - start_tv_usec) / 1000; ++ if (timeout_milliseconds != -1) ++ remain_milliseconds = timeout_milliseconds - elapsed_milliseconds; ++ else ++ remain_milliseconds = -1; + + if (!_dbus_connection_get_is_connected_unlocked (connection)) + { +@@ -2393,7 +2397,7 @@ _dbus_connection_block_pending_call (DBusPendingCall * + */ + _dbus_verbose ("dbus_connection_send_with_reply_and_block() waiting for more memory\n"); + +- _dbus_memory_pause_based_on_timeout (timeout_milliseconds - elapsed_milliseconds); ++ _dbus_memory_pause_based_on_timeout (remain_milliseconds); + } + else + { +@@ -2401,7 +2405,7 @@ _dbus_connection_block_pending_call (DBusPendingCall * + _dbus_connection_do_iteration_unlocked (connection, + DBUS_ITERATION_DO_READING | + DBUS_ITERATION_BLOCK, +- timeout_milliseconds - elapsed_milliseconds); ++ remain_milliseconds); + } + + goto recheck_status; +@@ -2410,7 +2414,7 @@ _dbus_connection_block_pending_call (DBusPendingCall * + _dbus_verbose ("dbus_connection_send_with_reply_and_block(): clock set backward\n"); + else if (elapsed_milliseconds < timeout_milliseconds) + { +- _dbus_verbose ("dbus_connection_send_with_reply_and_block(): %d milliseconds remain\n", timeout_milliseconds - elapsed_milliseconds); ++ _dbus_verbose ("dbus_connection_send_with_reply_and_block(): %d milliseconds remain\n", remain_milliseconds); + + if (status == DBUS_DISPATCH_NEED_MEMORY) + { +@@ -2420,7 +2424,7 @@ _dbus_connection_block_pending_call (DBusPendingCall * + */ + _dbus_verbose ("dbus_connection_send_with_reply_and_block() waiting for more memory\n"); + +- _dbus_memory_pause_based_on_timeout (timeout_milliseconds - elapsed_milliseconds); ++ _dbus_memory_pause_based_on_timeout (remain_milliseconds); + } + else + { +@@ -2428,7 +2432,7 @@ _dbus_connection_block_pending_call (DBusPendingCall * + _dbus_connection_do_iteration_unlocked (connection, + DBUS_ITERATION_DO_READING | + DBUS_ITERATION_BLOCK, +- timeout_milliseconds - elapsed_milliseconds); ++ remain_milliseconds); + } + + goto recheck_status;