diff options
author | Luiz Augusto von Dentz <luiz.dentz-von@nokia.com> | 2010-05-14 11:00:19 +0300 |
---|---|---|
committer | Luiz Augusto von Dentz <luiz.dentz-von@nokia.com> | 2010-05-14 11:00:19 +0300 |
commit | 3fd4aa58522a4eb0254c01506495573559fad293 (patch) | |
tree | 2f89ddb19faa932b67987c7aa9a97aefe481126d | |
parent | 0976fbc2e49a86b674f651e5cc130931b1ebbfd9 (diff) | |
download | obexd-3fd4aa58522a4eb0254c01506495573559fad293.tar.gz |
Fix regression on opp put when name is not set
OBEX specification 1.3 says:
"Though the Name header is very useful for operations like file transfer,
it is optional"
To fix this the drivers .chkput can now return -EBADR which will be
translated to bad request, so in case of opp if the auto answer is not
active it will let the agent to set a proper name to the object.
-rw-r--r-- | plugins/ftp.c | 3 | ||||
-rw-r--r-- | plugins/opp.c | 4 | ||||
-rw-r--r-- | src/obex.c | 10 |
3 files changed, 11 insertions, 6 deletions
diff --git a/plugins/ftp.c b/plugins/ftp.c index bcd6951..ffb00ff 100644 --- a/plugins/ftp.c +++ b/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/plugins/opp.c b/plugins/opp.c index 7637516..729c2ef 100644 --- a/plugins/opp.c +++ b/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); @@ -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; |