From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1KxLEv-0004lq-Ll for qemu-devel@nongnu.org; Tue, 04 Nov 2008 07:42:33 -0500 Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1KxLEt-0004le-7h for qemu-devel@nongnu.org; Tue, 04 Nov 2008 07:42:32 -0500 Received: from [199.232.76.173] (port=32777 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1KxLEt-0004lb-2O for qemu-devel@nongnu.org; Tue, 04 Nov 2008 07:42:31 -0500 Received: from mx2.redhat.com ([66.187.237.31]:57580) by monty-python.gnu.org with esmtp (Exim 4.60) (envelope-from ) id 1KxLEs-0000cq-Co for qemu-devel@nongnu.org; Tue, 04 Nov 2008 07:42:30 -0500 Received: from int-mx2.corp.redhat.com (int-mx2.corp.redhat.com [172.16.27.26]) by mx2.redhat.com (8.13.8/8.13.8) with ESMTP id mA4CgRQR025507 for ; Tue, 4 Nov 2008 07:42:29 -0500 Received: from ns3.rdu.redhat.com (ns3.rdu.redhat.com [10.11.255.199]) by int-mx2.corp.redhat.com (8.13.1/8.13.1) with ESMTP id mA4CgRYI029797 for ; Tue, 4 Nov 2008 07:42:27 -0500 Received: from zweiblum.travel.kraxel.org (vpn-4-83.str.redhat.com [10.32.4.83]) by ns3.rdu.redhat.com (8.13.8/8.13.8) with ESMTP id mA4CgP7a030240 for ; Tue, 4 Nov 2008 07:42:26 -0500 Message-ID: <49104331.1060203@redhat.com> Date: Tue, 04 Nov 2008 13:42:25 +0100 From: Gerd Hoffmann MIME-Version: 1.0 References: <1225730550-31941-1-git-send-email-kraxel@redhat.com> <1225730550-31941-2-git-send-email-kraxel@redhat.com> In-Reply-To: <1225730550-31941-2-git-send-email-kraxel@redhat.com> Content-Type: multipart/mixed; boundary="------------060604040801030103000801" Subject: [Qemu-devel] Re: [PATCH 1/3] sockets: helper functions for qemu. Reply-To: qemu-devel@nongnu.org List-Id: qemu-devel.nongnu.org List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org This is a multi-part message in MIME format. --------------060604040801030103000801 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit Hi, > + > + for (;;) { > + if (bind(slisten, e->ai_addr, e->ai_addrlen) != 0) { > + if (sockets_debug) > + fprintf(stderr,"%s: bind(%s,%s,%d): OK\n", __FUNCTION__, > + inet_strfamily(e->ai_family), uaddr, inet_getport(e)); > + goto listen; > + } Oops. Fixing up if() coding style with not enough care added a bug here. Unlike in most other cases where we catch errors this way this if() actually tests for bind() *success* to hop out of the "find free port" loop. Incremental fix attached. cheers, Gerd --------------060604040801030103000801 Content-Type: text/plain; name="0042-sockets-fix-bind-return-value-check.patch" Content-Transfer-Encoding: 7bit Content-Disposition: inline; filename="0042-sockets-fix-bind-return-value-check.patch" >>From 63d0d91d213ae3c84f1d3f82dd6879b43ec35bbc Mon Sep 17 00:00:00 2001 From: Gerd Hoffmann Date: Tue, 4 Nov 2008 13:35:07 +0100 Subject: [PATCH] sockets: fix bind return value check. Signed-off-by: Gerd Hoffmann --- qemu-sockets.c | 2 +- 1 files changed, 1 insertions(+), 1 deletions(-) diff --git a/qemu-sockets.c b/qemu-sockets.c index a5499a6..77d9921 100644 --- a/qemu-sockets.c +++ b/qemu-sockets.c @@ -165,7 +165,7 @@ int inet_listen(const char *str, char *ostr, int olen, #endif for (;;) { - if (bind(slisten, e->ai_addr, e->ai_addrlen) != 0) { + if (bind(slisten, e->ai_addr, e->ai_addrlen) == 0) { if (sockets_debug) fprintf(stderr,"%s: bind(%s,%s,%d): OK\n", __FUNCTION__, inet_strfamily(e->ai_family), uaddr, inet_getport(e)); -- 1.5.6.5 --------------060604040801030103000801--