From 19a28b0ed18c8ca2f855e7d129ddcdb8c939a707 Mon Sep 17 00:00:00 2001 From: Martin Szulecki Date: Fri, 24 Jul 2009 23:51:53 +0200 Subject: Use iphone_device_get_uuid() not lockdown, for less overhead where possible --- src/iphone.c | 12 ++++++------ src/lockdown.c | 21 ++++++++++----------- 2 files changed, 16 insertions(+), 17 deletions(-) (limited to 'src') diff --git a/src/iphone.c b/src/iphone.c index 0e179e7..93d7b5d 100644 --- a/src/iphone.c +++ b/src/iphone.c @@ -104,13 +104,13 @@ uint32_t iphone_get_device_handle(iphone_device_t device) } } -char* iphone_get_uuid(iphone_device_t device) +iphone_error_t iphone_device_get_uuid(iphone_device_t device, char **uuid) { - if (device) { - return device->serial_number; - } else { - return NULL; - } + if (!device) + return IPHONE_E_INVALID_ARG; + + *uuid = strdup(device->serial_number); + return IPHONE_E_SUCCESS; } /** Cleans up an iPhone structure, then frees the structure itself. diff --git a/src/lockdown.c b/src/lockdown.c index bfb44d0..3d2b04c 100644 --- a/src/lockdown.c +++ b/src/lockdown.c @@ -673,24 +673,24 @@ iphone_error_t lockdownd_new_client(iphone_device_t device, lockdownd_client_t * ret = IPHONE_E_NOT_ENOUGH_DATA; } - char *uid = NULL; - ret = lockdownd_get_device_uid(client_loc, &uid); + char *uuid = NULL; + ret = iphone_device_get_uuid(device, &uuid); if (IPHONE_E_SUCCESS != ret) { log_debug_msg("%s: failed to get device uuid.\n", __func__); } - log_debug_msg("%s: device uuid: %s\n", __func__, uid); + log_debug_msg("%s: device uuid: %s\n", __func__, uuid); host_id = get_host_id(); if (IPHONE_E_SUCCESS == ret && !host_id) { ret = IPHONE_E_INVALID_CONF; } - if (IPHONE_E_SUCCESS == ret && !is_device_known(uid)) - ret = lockdownd_pair(client_loc, uid, host_id); + if (IPHONE_E_SUCCESS == ret && !is_device_known(uuid)) + ret = lockdownd_pair(client_loc, uuid, host_id); - if (uid) { - free(uid); - uid = NULL; + if (uuid) { + free(uuid); + uuid = NULL; } if (IPHONE_E_SUCCESS == ret) { @@ -779,9 +779,8 @@ iphone_error_t lockdownd_pair(lockdownd_client_t client, char *uid, char *host_i /* store public key in config if pairing succeeded */ if (ret == IPHONE_E_SUCCESS) { - log_dbg_msg(DBGMASK_LOCKDOWND, "%s: pair success\n", __func__); - store_device_public_key(uid, public_key); - ret = IPHONE_E_SUCCESS; + log_dbg_msg(DBGMASK_LOCKDOWND, "%s: pair success\n", __func__); + store_device_public_key(uuid, public_key); } else { log_dbg_msg(DBGMASK_LOCKDOWND, "%s: pair failure\n", __func__); ret = IPHONE_E_PAIRING_FAILED; -- cgit v1.1-32-gdbae