[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[GNUnet-SVN] r33718 - gnunet/src/transport
From: |
gnunet |
Subject: |
[GNUnet-SVN] r33718 - gnunet/src/transport |
Date: |
Tue, 17 Jun 2014 22:20:21 +0200 |
Author: grothoff
Date: 2014-06-17 22:20:21 +0200 (Tue, 17 Jun 2014)
New Revision: 33718
Modified:
gnunet/src/transport/gnunet-helper-transport-bluetooth.c
Log:
-fix socket leak in error handling branches
Modified: gnunet/src/transport/gnunet-helper-transport-bluetooth.c
===================================================================
--- gnunet/src/transport/gnunet-helper-transport-bluetooth.c 2014-06-17
20:16:43 UTC (rev 33717)
+++ gnunet/src/transport/gnunet-helper-transport-bluetooth.c 2014-06-17
20:20:21 UTC (rev 33718)
@@ -1080,7 +1080,7 @@
* Open the bluetooth interface for reading/writing
*
* @param dev pointer to the device struct
- * @return 0 on success
+ * @return 0 on success, non-zero on error
*/
static int
open_device (struct HardwareInfos *dev)
@@ -1140,7 +1140,9 @@
if (fd_hci < 0)
{
- fprintf (stderr, "Failed to create HCI socket: %s\n", strerror (errno));
+ fprintf (stderr,
+ "Failed to create HCI socket: %s\n",
+ strerror (errno));
return -1;
}
@@ -1149,8 +1151,12 @@
if (ioctl (fd_hci, HCIGETDEVLIST, (void *) &request) < 0)
{
- fprintf (stderr, "ioctl(HCIGETDEVLIST) on interface `%.*s' failed: %s\n",
- IFNAMSIZ, dev->iface, strerror (errno));
+ fprintf (stderr,
+ "ioctl(HCIGETDEVLIST) on interface `%.*s' failed: %s\n",
+ IFNAMSIZ,
+ dev->iface,
+ strerror (errno));
+ (void) close (fd_hci);
return 1;
}
@@ -1165,8 +1171,12 @@
if (ioctl (fd_hci, HCIGETDEVINFO, (void *) &dev_info))
{
- fprintf (stderr, "ioctl(HCIGETDEVINFO) on interface `%.*s' failed:
%s\n",
- IFNAMSIZ, dev->iface, strerror (errno));
+ fprintf (stderr,
+ "ioctl(HCIGETDEVINFO) on interface `%.*s' failed: %s\n",
+ IFNAMSIZ,
+ dev->iface,
+ strerror (errno));
+ (void) close (fd_hci);
return 1;
}
@@ -1185,8 +1195,12 @@
/* Bring the interface up */
if (ioctl (fd_hci, HCIDEVUP, dev_info.dev_id))
{
- fprintf (stderr, "ioctl(HCIDEVUP) on interface `%.*s' failed:
%s\n",
- IFNAMSIZ, dev->iface, strerror (errno));
+ fprintf (stderr,
+ "ioctl(HCIDEVUP) on interface `%.*s' failed: %s\n",
+ IFNAMSIZ,
+ dev->iface,
+ strerror (errno));
+ (void) close (fd_hci);
return 1;
}
}
@@ -1204,8 +1218,12 @@
if (ioctl (fd_hci, HCISETSCAN, (unsigned long) &dev_req))
{
- fprintf (stderr, "ioctl(HCISETSCAN) on interface `%.*s' failed:
%s\n",
- IFNAMSIZ, dev->iface, strerror (errno));
+ fprintf (stderr,
+ "ioctl(HCISETSCAN) on interface `%.*s' failed: %s\n",
+ IFNAMSIZ,
+ dev->iface,
+ strerror (errno));
+ (void) close (fd_hci);
return 1;
}
@@ -1216,9 +1234,12 @@
}
/* Check if the interface was not found */
- if (dev_id == -1)
+ if (-1 == dev_id)
{
- fprintf (stderr, "The interface %s was not found\n", dev->iface);
+ fprintf (stderr,
+ "The interface %s was not found\n",
+ dev->iface);
+ (void) close (fd_hci);
return 1;
}
@@ -1234,15 +1255,20 @@
if (bind_socket (dev->fd_rfcomm, &rc_addr) != 0)
{
- fprintf (stderr, "Failed to bind interface `%.*s': %s\n", IFNAMSIZ,
- dev->iface, strerror (errno));
+ fprintf (stderr,
+ "Failed to bind interface `%.*s': %s\n",
+ IFNAMSIZ,
+ dev->iface,
+ strerror (errno));
return 1;
}
/* Register a SDP service */
if (register_service (dev, rc_addr.rc_channel) != 0)
{
- fprintf (stderr, "Failed to register a service on interface `%.*s':
%s\n", IFNAMSIZ,
+ fprintf (stderr,
+ "Failed to register a service on interface `%.*s': %s\n",
+ IFNAMSIZ,
dev->iface, strerror (errno));
return 1;
}
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [GNUnet-SVN] r33718 - gnunet/src/transport,
gnunet <=