From 15173c59a00a8e9c154bd6787e35c243c383160e Mon Sep 17 00:00:00 2001 From: BALATON Zoltan Date: Wed, 23 Sep 2015 02:15:34 +0200 Subject: Avoid potential NULL pointer dereference (leading to segfault) if functions are called with NULL arguments --- src/installation_proxy.c | 14 +++++++++----- src/lockdown.c | 2 +- 2 files changed, 10 insertions(+), 6 deletions(-) diff --git a/src/installation_proxy.c b/src/installation_proxy.c index 8bde154..9f367aa 100644 --- a/src/installation_proxy.c +++ b/src/installation_proxy.c @@ -847,11 +847,12 @@ LIBIMOBILEDEVICE_API instproxy_error_t instproxy_status_get_error(plist_t status LIBIMOBILEDEVICE_API void instproxy_status_get_name(plist_t status, char **name) { - *name = NULL; if (name) { plist_t node = plist_dict_get_item(status, "Status"); if (node) { plist_get_string_val(node, name); + } else { + *name = NULL; } } } @@ -907,10 +908,13 @@ LIBIMOBILEDEVICE_API void instproxy_status_get_current_list(plist_t status, uint LIBIMOBILEDEVICE_API void instproxy_command_get_name(plist_t command, char** name) { - *name = NULL; - plist_t node = plist_dict_get_item(command, "Command"); - if (node) { - plist_get_string_val(node, name); + if (name) { + plist_t node = plist_dict_get_item(command, "Command"); + if (node) { + plist_get_string_val(node, name); + } else { + *name = NULL; + } } } diff --git a/src/lockdown.c b/src/lockdown.c index 85124bd..d2e8c74 100644 --- a/src/lockdown.c +++ b/src/lockdown.c @@ -637,7 +637,7 @@ LIBIMOBILEDEVICE_API lockdownd_error_t lockdownd_get_device_name(lockdownd_clien LIBIMOBILEDEVICE_API lockdownd_error_t lockdownd_client_new(idevice_t device, lockdownd_client_t *client, const char *label) { - if (!client) + if (!device || !client) return LOCKDOWN_E_INVALID_ARG; static struct lockdownd_service_descriptor service = { -- cgit v1.1-32-gdbae