summaryrefslogtreecommitdiff
path: root/obexd
diff options
context:
space:
mode:
authorLuiz Augusto von Dentz <luiz.von.dentz@intel.com>2014-09-01 16:01:40 +0300
committerLuiz Augusto von Dentz <luiz.von.dentz@intel.com>2014-09-03 14:36:31 +0300
commit55eebc598b1e182b2cbcfb78b4202d2ae2e52d73 (patch)
treea91a82608c9dfa3176f1bbac8b6ce065107b50f4 /obexd
parentd61484c5dea53fe7c99e8efbfeb34e01b79c413f (diff)
downloadbluez-55eebc598b1e182b2cbcfb78b4202d2ae2e52d73.tar.gz
obexd/mas: Fix parsing of application parameters
Some commands don't have any mandatory application parameter which means inparams can be NULL which should not be treated as a bad request.
Diffstat (limited to 'obexd')
-rw-r--r--obexd/plugins/mas.c24
1 files changed, 18 insertions, 6 deletions
diff --git a/obexd/plugins/mas.c b/obexd/plugins/mas.c
index 5729c22e0..24b26ae0e 100644
--- a/obexd/plugins/mas.c
+++ b/obexd/plugins/mas.c
@@ -83,8 +83,8 @@ static int get_params(struct obex_session *os, struct mas_session *mas)
ssize_t size;
size = obex_get_apparam(os, &buffer);
- if (size < 0)
- size = 0;
+ if (size <= 0)
+ return 0;
mas->inparams = g_obex_apparam_decode(buffer, size);
if (mas->inparams == NULL) {
@@ -249,7 +249,9 @@ static void get_messages_listing_cb(void *session, int err, uint16_t size,
return;
}
- g_obex_apparam_get_uint16(mas->inparams, MAP_AP_MAXLISTCOUNT, &max);
+ if (mas->inparams)
+ g_obex_apparam_get_uint16(mas->inparams, MAP_AP_MAXLISTCOUNT,
+ &max);
if (max == 0) {
if (!entry)
@@ -397,7 +399,9 @@ static void get_folder_listing_cb(void *session, int err, uint16_t size,
return;
}
- g_obex_apparam_get_uint16(mas->inparams, MAP_AP_MAXLISTCOUNT, &max);
+ if (mas->inparams)
+ g_obex_apparam_get_uint16(mas->inparams, MAP_AP_MAXLISTCOUNT,
+ &max);
if (max == 0) {
if (err != -EAGAIN)
@@ -493,8 +497,12 @@ static void *folder_listing_open(const char *name, int oflag, mode_t mode,
DBG("name = %s", name);
- g_obex_apparam_get_uint16(mas->inparams, MAP_AP_MAXLISTCOUNT, &max);
- g_obex_apparam_get_uint16(mas->inparams, MAP_AP_STARTOFFSET, &offset);
+ if (mas->inparams) {
+ g_obex_apparam_get_uint16(mas->inparams, MAP_AP_MAXLISTCOUNT,
+ &max);
+ g_obex_apparam_get_uint16(mas->inparams, MAP_AP_STARTOFFSET,
+ &offset);
+ }
*err = messages_get_folder_listing(mas->backend_data, name, max,
offset, get_folder_listing_cb, mas);
@@ -526,6 +534,9 @@ static void *msg_listing_open(const char *name, int oflag, mode_t mode,
return NULL;
}
+ if (!mas->inparams)
+ goto done;
+
g_obex_apparam_get_uint16(mas->inparams, MAP_AP_MAXLISTCOUNT, &max);
g_obex_apparam_get_uint16(mas->inparams, MAP_AP_STARTOFFSET, &offset);
g_obex_apparam_get_uint8(mas->inparams, MAP_AP_SUBJECTLENGTH,
@@ -548,6 +559,7 @@ static void *msg_listing_open(const char *name, int oflag, mode_t mode,
g_obex_apparam_get_uint8(mas->inparams, MAP_AP_FILTERPRIORITY,
&filter.priority);
+done:
*err = messages_get_messages_listing(mas->backend_data, name, max,
offset, subject_len, &filter,
get_messages_listing_cb, mas);