From e368ac5eeb4c7031e36eee8468e8e990a4f4dc6a Mon Sep 17 00:00:00 2001 From: Claudio Takahasi Date: Wed, 26 May 2010 17:57:30 -0300 Subject: [PATCH] obexd: Fix handle range problem for PBAP dummy back-end If the handle value is bigger than the maximum possible addressable value(32bits), it is better to ignore this unusual situation than try to map it to a valid handle value and add extra logic to translate this new value when a PullvCardEntry request is received. --- obexd/plugins/phonebook-dummy.c | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-) diff --git a/obexd/plugins/phonebook-dummy.c b/obexd/plugins/phonebook-dummy.c index 1f32ad854..6ad026610 100644 --- a/obexd/plugins/phonebook-dummy.c +++ b/obexd/plugins/phonebook-dummy.c @@ -257,12 +257,18 @@ static void entry_notify(const char *filename, VObject *v, void *user_data) VObject *property, *subproperty; GString *name; const char *tel; - unsigned int handle; + long unsigned int handle; property = isAPropertyOf(v, VCNameProp); if (!property) return; + if (sscanf(filename, "%lu.vcf", &handle) != 1) + return; + + if (handle > UINT32_MAX) + return; + /* LastName; FirstName; MiddleName; Prefix; Suffix */ name = g_string_new(""); @@ -294,16 +300,11 @@ static void entry_notify(const char *filename, VObject *v, void *user_data) fakeCString(vObjectUStringZValue(subproperty))); property = isAPropertyOf(v, VCTelephoneProp); - if (!property) - goto done; - tel = fakeCString(vObjectUStringZValue(property)); - if (sscanf(filename, "%u.vcf", &handle) == 1) - handle = handle > UINT32_MAX ? UINT32_MAX : handle; - query->entry_cb(filename, handle, name->str, NULL, tel, - query->user_data); + tel = property ? fakeCString(vObjectUStringZValue(property)) : NULL; -done: + query->entry_cb(filename, handle, name->str, NULL, tel, + query->user_data); g_string_free(name, TRUE); } -- 2.47.3