socket-util: Report fd of -1 on error in inet_open_active().
authorBen Pfaff <blp@nicira.com>
Wed, 7 Nov 2012 20:55:53 +0000 (12:55 -0800)
committerBen Pfaff <blp@nicira.com>
Wed, 7 Nov 2012 20:55:53 +0000 (12:55 -0800)
commitce78d135fc990505372e404de977a85841c49c24
tree0ff0d2140d1d99a70a64bfc16b4632034d96a3d4
parentb099cd5f555a22646fe0be565ccef3c0cf9dcd87
socket-util: Report fd of -1 on error in inet_open_active().

inet_open_active() is documented to report a fd of -1 when an error occurs.
All three of its callers rely on this, by checking only the fd to determine
whether there was an error.  This means that if the call to
set_nonblocking() or set_dscp() or connect() failed, then the callers would
try to use a fd that had already been closed, wreaking havoc.

This fixes a bug introduced in commit a4efa3fc5d (socket-util: Close socket
on failed dscp modification.)

Bug #13750.
Reported-by: Scott Hendricks <shendricks@vmware.com>
Signed-off-by: Ben Pfaff <blp@nicira.com>
Acked-by: Ethan Jackson <ethan@nicira.com>
lib/socket-util.c