summaryrefslogtreecommitdiff
path: root/obexd/plugins
diff options
context:
space:
mode:
authorLuiz Augusto von Dentz <luiz.von.dentz@intel.com>2013-06-06 15:05:46 +0700
committerLuiz Augusto von Dentz <luiz.von.dentz@intel.com>2013-06-12 00:12:33 +0300
commit9ee1038cff9e9e3eaa637df94704801cf09cbe66 (patch)
treed15864c20f3795fa57a7e1bd41f28486ae88b921 /obexd/plugins
parent00622544dd96a8037fbf557ac2438bc307142b71 (diff)
downloadbluez-9ee1038cff9e9e3eaa637df94704801cf09cbe66.tar.gz
obexd: Fix not checking for valid fd on NewConnection
The fd needs to be checked as it may not be valid which cause the following warnings: ==8162== Warning: invalid file descriptor 1031 in syscall fcntl(DUPFD_CLOEXEC)() (obexd:8162): GLib-WARNING **: giounix.c:412Error while getting flags for FD: Bad file descriptor (9)
Diffstat (limited to 'obexd/plugins')
-rw-r--r--obexd/plugins/bluetooth.c13
1 files changed, 13 insertions, 0 deletions
diff --git a/obexd/plugins/bluetooth.c b/obexd/plugins/bluetooth.c
index 07baf9058..e4d518ef5 100644
--- a/obexd/plugins/bluetooth.c
+++ b/obexd/plugins/bluetooth.c
@@ -30,6 +30,7 @@
#include <string.h>
#include <unistd.h>
#include <inttypes.h>
+#include <fcntl.h>
#include <sys/socket.h>
#include <glib.h>
@@ -132,6 +133,18 @@ static DBusMessage *profile_new_connection(DBusConnection *conn,
dbus_message_iter_get_basic(&args, &fd);
+ if (fd < 0) {
+ error("bluetooth: NewConnection invalid fd");
+ return invalid_args(msg);
+ }
+
+ /* Read fd flags to make sure it can be used */
+ if (fcntl(fd, F_GETFD) < 0) {
+ error("bluetooth: fcntl(%d, F_GETFD): %s (%d)", fd,
+ strerror(errno), errno);
+ return invalid_args(msg);
+ }
+
io = g_io_channel_unix_new(fd);
if (io == NULL)
return invalid_args(msg);