diff options
author | Claudio Takahasi <claudio.takahasi@openbossa.org> | 2010-05-26 17:57:30 -0300 |
---|---|---|
committer | Claudio Takahasi <claudio.takahasi@openbossa.org> | 2010-05-27 17:45:11 -0300 |
commit | 2d0b26070d6e6b7efe37ca7ee8c8cbb1c77c9bc5 (patch) | |
tree | e7dc15b14b94fa17806a469b811892f09ee3e874 | |
parent | 13afccf6cc99e1a1beb862aad6fb0e9e3d6685ba (diff) | |
download | obexd-2d0b26070d6e6b7efe37ca7ee8c8cbb1c77c9bc5.tar.gz |
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.
-rw-r--r-- | plugins/phonebook-dummy.c | 19 |
1 files changed, 10 insertions, 9 deletions
diff --git a/plugins/phonebook-dummy.c b/plugins/phonebook-dummy.c index 1f32ad8..6ad0266 100644 --- a/plugins/phonebook-dummy.c +++ b/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); } |