Skip to contentSkip to conversation

obexd: Fix null pointer dereference.

PATCH Applied Matias Karhumaa 2 participants 2 messages Jun 22, 2017 Bluetooth drivers

lore
Share & tools
lore
#0 lore raw

PATCH v2 1/1 obexd: Fix null pointer dereference.

By sending OPP Put request before CONNECT we were able to cause SIGSEGV in obexd. Crash was caused by null pointer dereference. Crash was found using Synopsys Defensics Obex Server test suite.

This was fixed by calling os->service->connect if CONNECT was not done before.

---
 obexd/src/obex.c | 11 +++++++++++
 1 file changed, 11 insertions(+)
obexd/src/obex.c +11 -0
index 788bffc..be79a77 100644
@@ -864,6 +864,17 @@ static void cmd_put(GObex *obex, GObexPacket *req, gpointer user_data)
 		return;
 	}
 
+	/* OPP session don't require CONNECT, in which case just call connect
+	 * callback to register the transfer.
+	 */
+	if (!os->service_data && os->service->service == OBEX_OPP) {
+		os->service_data = os->service->connect(os, &err);
+		if (err < 0) {
+			os_set_response(os, err);
+			return;
+		}
+	}
+
 	parse_type(os, req);
 
 	if (os->driver == NULL) {
Signature · 1 line
2.7.4
maintainer Applied
#1 lore raw

Hi Matias,

Quoted 33 lines · Matias Karhumaa

By sending OPP Put request before CONNECT we were able to cause SIGSEGV in obexd. Crash was caused by null pointer dereference. Crash was found using Synopsys Defensics Obex Server test suite.

This was fixed by calling os->service->connect if CONNECT was not done before.

---
 obexd/src/obex.c | 11 +++++++++++
 1 file changed, 11 insertions(+)
obexd/src/obex.c +11 -1
index 788bffc..be79a77 100644
@@ -864,6 +864,17 @@ static void cmd_put(GObex *obex, GObexPacket *req, gpointer user_data)
                return;
        }
 
+       /* OPP session don't require CONNECT, in which case just call connect
+        * callback to register the transfer.
+        */
+       if (!os->service_data && os->service->service == OBEX_OPP) {
+               os->service_data = os->service->connect(os, &err);
+               if (err < 0) {
+                       os_set_response(os, err);
+                       return;
+               }
+       }
+
        parse_type(os, req);
 
        if (os->driver == NULL) {
--
Quoted 1 line

2.7.4

Applied, thanks.

Signature · 1 line
Luiz Augusto von Dentz