From 959a2a203577b5505468fbaa10e6cd54f497213b Mon Sep 17 00:00:00 2001 From: Nikias Bassen Date: Tue, 24 Sep 2013 02:14:54 +0200 Subject: lockdown: improve lockdownd_query_type result checking --- src/lockdown.c | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) (limited to 'src') diff --git a/src/lockdown.c b/src/lockdown.c index f616d25..a8f5307 100644 --- a/src/lockdown.c +++ b/src/lockdown.c @@ -376,14 +376,21 @@ lockdownd_error_t lockdownd_query_type(lockdownd_client_t client, char **type) return ret; ret = LOCKDOWN_E_UNKNOWN_ERROR; - if (lockdown_check_result(dict, "QueryType") == RESULT_SUCCESS) { + plist_t type_node = plist_dict_get_item(dict, "Type"); + if (type_node && (plist_get_node_type(type_node) == PLIST_STRING)) { + char* typestr = NULL; + plist_get_string_val(type_node, &typestr); + debug_info("success with type %s", typestr); /* return the type if requested */ if (type != NULL) { - plist_t type_node = plist_dict_get_item(dict, "Type"); - plist_get_string_val(type_node, type); + *type = typestr; + } else { + free(typestr); } - debug_info("success with type %s", *type); ret = LOCKDOWN_E_SUCCESS; + } else { + debug_info("hmm. QueryType response does not contain a type?!\n"); + debug_plist(dict); } plist_free(dict); dict = NULL; -- cgit v1.1-32-gdbae