Skip to content

Commit a01efa8

Browse files
VudentzJohan Hedberg
authored and
Johan Hedberg
committed
obexd/MAP: Fix parsing message handles as decimal numbers
The spec clearly states the handles are hexadecimal: MAP 1.2 - Page 29 ""handle" is the message handle in hexadecimal representation with up to 16 digits; leading zero digits may be used so the MCE shall accept both handles with and without leading zeros (e.g.,"00000012345678AB" or "12345678AB")."
1 parent fd02ee7 commit a01efa8

File tree

2 files changed

+7
-7
lines changed

2 files changed

+7
-7
lines changed

obexd/client/map.c

+6-6
Original file line numberDiff line numberDiff line change
@@ -435,7 +435,7 @@ static DBusMessage *map_msg_get(DBusConnection *connection,
435435
GError *err = NULL;
436436
DBusMessage *reply;
437437
GObexApparam *apparam;
438-
char handle[21];
438+
char handle[17];
439439

440440
if (dbus_message_get_args(message, NULL,
441441
DBUS_TYPE_STRING, &target_file,
@@ -444,7 +444,7 @@ static DBusMessage *map_msg_get(DBusConnection *connection,
444444
return g_dbus_create_error(message,
445445
ERROR_INTERFACE ".InvalidArguments", NULL);
446446

447-
if (snprintf(handle, sizeof(handle), "%" PRIu64, msg->handle) < 0)
447+
if (snprintf(handle, sizeof(handle), "%" PRIx64, msg->handle) < 0)
448448
goto fail;
449449

450450
transfer = obc_transfer_get("x-bt/message", handle, target_file, &err);
@@ -730,7 +730,7 @@ static void set_status(const GDBusPropertyTable *property,
730730
GError *err = NULL;
731731
GObexApparam *apparam;
732732
char contents[1];
733-
char handle[21];
733+
char handle[17];
734734

735735
if (dbus_message_iter_get_arg_type(iter) != DBUS_TYPE_BOOLEAN) {
736736
g_dbus_pending_property_error(id,
@@ -743,7 +743,7 @@ static void set_status(const GDBusPropertyTable *property,
743743

744744
contents[0] = FILLER_BYTE;
745745

746-
if (snprintf(handle, sizeof(handle), "%" PRIu64, msg->handle) < 0)
746+
if (snprintf(handle, sizeof(handle), "%" PRIx64, msg->handle) < 0)
747747
goto fail;
748748

749749
transfer = obc_transfer_put("x-bt/messageStatus", handle, NULL,
@@ -1110,7 +1110,7 @@ static void msg_element(GMarkupParseContext *ctxt, const char *element,
11101110
break;
11111111
}
11121112

1113-
handle = strtoull(values[i], NULL, 10);
1113+
handle = strtoull(values[i], NULL, 16);
11141114

11151115
msg = g_hash_table_lookup(data->messages, &handle);
11161116
if (msg == NULL) {
@@ -1897,7 +1897,7 @@ static void map_handle_notification(struct map_event *event, void *user_data)
18971897

18981898
DBG("Event report for %s:%d", obc_session_get_destination(map->session),
18991899
map->mas_instance_id);
1900-
DBG("type=%x handle=%" PRIu64 " folder=%s old_folder=%s msg_type=%s",
1900+
DBG("type=%x handle=%" PRIx64 " folder=%s old_folder=%s msg_type=%s",
19011901
event->type, event->handle, event->folder, event->old_folder,
19021902
event->msg_type);
19031903

obexd/client/mns.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -185,7 +185,7 @@ static void parse_event_report_type(struct map_event *event, const char *value)
185185
static void parse_event_report_handle(struct map_event *event,
186186
const char *value)
187187
{
188-
event->handle = strtoull(value, NULL, 10);
188+
event->handle = strtoull(value, NULL, 16);
189189
}
190190

191191
static void parse_event_report_folder(struct map_event *event,

0 commit comments

Comments
 (0)