From 0bfec4d45b29ac992a30061b8f7190ca8fdc9cbc Mon Sep 17 00:00:00 2001 From: Nikias Bassen Date: Fri, 27 Dec 2013 12:47:26 +0100 Subject: preflight: check for device record before trying to read host id --- src/preflight.c | 25 +++++++++++++++---------- 1 file changed, 15 insertions(+), 10 deletions(-) (limited to 'src/preflight.c') diff --git a/src/preflight.c b/src/preflight.c index b011344..5198d8c 100644 --- a/src/preflight.c +++ b/src/preflight.c @@ -161,17 +161,22 @@ retry: int is_device_paired = 0; char *host_id = NULL; - config_device_record_get_host_id(dev->udid, &host_id); - lerr = lockdownd_start_session(lockdown, host_id, NULL, NULL); - free(host_id); - if (lerr == LOCKDOWN_E_SUCCESS) { - usbmuxd_log(LL_INFO, "%s: StartSession success for device %s", __func__, _dev->udid); - usbmuxd_log(LL_INFO, "%s: Finished preflight on device %s", __func__, _dev->udid); - client_device_add(info); - goto leave; - } + if (config_has_device_record(dev->udid)) { + config_device_record_get_host_id(dev->udid, &host_id); + lerr = lockdownd_start_session(lockdown, host_id, NULL, NULL); + if (host_id) + free(host_id); + if (lerr == LOCKDOWN_E_SUCCESS) { + usbmuxd_log(LL_INFO, "%s: StartSession success for device %s", __func__, _dev->udid); + usbmuxd_log(LL_INFO, "%s: Finished preflight on device %s", __func__, _dev->udid); + client_device_add(info); + goto leave; + } - usbmuxd_log(LL_INFO, "%s: StartSession failed on device %s, lockdown error %d", __func__, _dev->udid, lerr); + usbmuxd_log(LL_INFO, "%s: StartSession failed on device %s, lockdown error %d", __func__, _dev->udid, lerr); + } else { + lerr = LOCKDOWN_E_INVALID_HOST_ID; + } switch (lerr) { case LOCKDOWN_E_INVALID_HOST_ID: usbmuxd_log(LL_INFO, "%s: Device %s is not paired with this host.", __func__, _dev->udid); -- cgit v1.1-32-gdbae