From: Michael Brown Date: Mon, 6 Jul 2009 15:16:59 +0000 (+0100) Subject: [xfer] Always nullify interface while sending close() message X-Git-Tag: v0.9.8~95 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=b7e93a6a55cadbf14fc0fc8f797d2f576c0c5dda;p=thirdparty%2Fipxe.git [xfer] Always nullify interface while sending close() message Objects typically call xfer_close() as part of their response to a close() message. If the initiating object has already nullified the xfer interface then this isn't a problem, but it can lead to unexpected behaviour when the initiating object is aiming to reuse the connection and so does not nullify the interface. Fix by always temporarily nullifying the interface during xfer_close() (as was already being done by xfer_vreopen() in order to work around this specific problem). Reported-by: infernix Tested-by: infernix --- diff --git a/src/core/open.c b/src/core/open.c index d5eb30cfa..70b427ba2 100644 --- a/src/core/open.c +++ b/src/core/open.c @@ -188,15 +188,10 @@ int xfer_open ( struct xfer_interface *xfer, int type, ... ) { * method handler. */ int xfer_vreopen ( struct xfer_interface *xfer, int type, va_list args ) { - struct xfer_interface_operations *op = xfer->op; /* Close existing connection */ - xfer_nullify ( xfer ); xfer_close ( xfer, 0 ); - /* Restore to operational status */ - xfer->op = op; - /* Open new location */ return xfer_vopen ( xfer, type, args ); } diff --git a/src/core/xfer.c b/src/core/xfer.c index a9bcb4d7b..1ec6f9d3f 100644 --- a/src/core/xfer.c +++ b/src/core/xfer.c @@ -45,11 +45,14 @@ static struct xfer_metadata dummy_metadata; */ void xfer_close ( struct xfer_interface *xfer, int rc ) { struct xfer_interface *dest = xfer_get_dest ( xfer ); + struct xfer_interface_operations *op = xfer->op; DBGC ( xfer, "XFER %p->%p close\n", xfer, dest ); xfer_unplug ( xfer ); + xfer_nullify ( xfer ); dest->op->close ( dest, rc ); + xfer->op = op; xfer_put ( dest ); }