Diff between e85450cc32c7bf188baeb399a7a49f09dc6c3ff8 and 38c2f10f771d0d9286e9284215d8e0aa58a8edb1

Changed Files

File Additions Deletions Status
obexd/plugins/ftp.c +3 -0 modified
obexd/plugins/opp.c +4 -0 modified
obexd/src/obex.c +4 -6 modified

Full Patch

diff --git a/obexd/plugins/ftp.c b/obexd/plugins/ftp.c
index bcd6951..ffb00ff 100644
--- a/obexd/plugins/ftp.c
+++ b/obexd/plugins/ftp.c
@@ -237,6 +237,9 @@ static gint ftp_chkput(struct obex_session *os, gpointer user_data)
 	gchar *path;
 	int ret;
 
+	if (name == NULL)
+		return -EBADR;
+
 	if (obex_get_size(os) == OBJECT_SIZE_DELETE)
 		return 0;
 
diff --git a/obexd/plugins/opp.c b/obexd/plugins/opp.c
index 7637516..729c2ef 100644
--- a/obexd/plugins/opp.c
+++ b/obexd/plugins/opp.c
@@ -27,6 +27,7 @@
 #endif
 
 #include <errno.h>
+#include <string.h>
 
 #include <openobex/obex.h>
 #include <openobex/obex_const.h>
@@ -136,6 +137,9 @@ static gint opp_chkput(struct obex_session *os, gpointer user_data)
 		name = g_strdup(obex_get_name(os));
 
 skip_auth:
+	if (name == NULL || strlen(name) == 0)
+		return -EBADR;
+
 	path = g_build_filename(folder, name, NULL);
 
 	manager_emit_transfer_started(os);
diff --git a/obexd/src/obex.c b/obexd/src/obex.c
index 71fef28..e4872c1 100644
--- a/obexd/src/obex.c
+++ b/obexd/src/obex.c
@@ -799,12 +799,6 @@ static gboolean check_put(obex_t *obex, obex_object_t *obj)
 	if (!os->service->chkput)
 		goto done;
 
-	if (!os->name) {
-		OBEX_ObjectSetRsp(obj, OBEX_RSP_BAD_REQUEST,
-				OBEX_RSP_BAD_REQUEST);
-		return FALSE;
-	}
-
 	ret = os->service->chkput(os, os->service_data);
 	switch (ret) {
 	case 0:
@@ -812,6 +806,10 @@ static gboolean check_put(obex_t *obex, obex_object_t *obj)
 	case -EPERM:
 		OBEX_ObjectSetRsp(obj, OBEX_RSP_FORBIDDEN, OBEX_RSP_FORBIDDEN);
 		return FALSE;
+	case -EBADR:
+		OBEX_ObjectSetRsp(obj, OBEX_RSP_BAD_REQUEST,
+					OBEX_RSP_BAD_REQUEST);
+		return FALSE;
 	case -EAGAIN:
 		OBEX_SuspendRequest(obex, obj);
 		os->obj = obj;