tizen 2.3.1 release
[framework/connectivity/bluez.git] / src / sdpd-server.c
index 1d9509e..e6b611a 100644 (file)
 #include <config.h>
 #endif
 
-#include <stdio.h>
 #include <errno.h>
 #include <unistd.h>
 #include <stdlib.h>
+#include <stdbool.h>
 #include <sys/stat.h>
-#include <sys/socket.h>
-
-#include <bluetooth/bluetooth.h>
-#include <bluetooth/l2cap.h>
-#include <bluetooth/sdp.h>
-#include <bluetooth/sdp_lib.h>
-
 #include <sys/un.h>
-#include <netinet/in.h>
 
 #include <glib.h>
 
-#include "hcid.h"
+#include "lib/bluetooth.h"
+#include "lib/l2cap.h"
+#include "lib/sdp.h"
+#include "lib/sdp_lib.h"
+
 #include "log.h"
 #include "sdpd.h"
 
@@ -147,7 +143,7 @@ static int init_server(uint16_t mtu, int master, int compat)
                return -1;
        }
 
-       chmod(SDP_UNIX_PATH, S_IRUSR | S_IWUSR | S_IRGRP | S_IWGRP | S_IROTH | S_IWOTH);
+       chmod(SDP_UNIX_PATH, S_IRUSR | S_IWUSR | S_IRGRP | S_IWGRP);
 
        return 0;
 }
@@ -169,7 +165,7 @@ static gboolean io_session_event(GIOChannel *chan, GIOCondition cond, gpointer d
        }
 
        len = recv(sk, &hdr, sizeof(sdp_pdu_hdr_t), MSG_PEEK);
-       if (len <= 0) {
+       if (len != sizeof(sdp_pdu_hdr_t)) {
                sdp_svcdb_collect_all(sk);
                return FALSE;
        }
@@ -180,6 +176,10 @@ static gboolean io_session_event(GIOChannel *chan, GIOCondition cond, gpointer d
                return TRUE;
 
        len = recv(sk, buf, size, 0);
+       /* Check here only that the received message is not empty.
+        * Incorrect length of message should be processed later
+        * inside handle_request() in order to produce ErrorResponse.
+        */
        if (len <= 0) {
                sdp_svcdb_collect_all(sk);
                free(buf);
@@ -241,9 +241,6 @@ int start_sdp_server(uint16_t mtu, uint32_t flags)
                return -1;
        }
 
-       if (main_opts.did_source > 0)
-               register_device_id();
-
        io = g_io_channel_unix_new(l2cap_sock);
        g_io_channel_set_close_on_unref(io, TRUE);