diff options
| author | 2012-11-29 03:42:06 +0100 | |
|---|---|---|
| committer | 2012-11-29 03:42:06 +0100 | |
| commit | 36c0192fbb16d068214d2640aecfb731ea24bfaa (patch) | |
| tree | 4596eb003c5f074c4ca0b9e1e146680927916d11 /tools/idevicedate.c | |
| parent | d2b82f9a8330a995a3e913adf734ac2b9ece9916 (diff) | |
| download | libimobiledevice-36c0192fbb16d068214d2640aecfb731ea24bfaa.tar.gz libimobiledevice-36c0192fbb16d068214d2640aecfb731ea24bfaa.tar.bz2 | |
tools: use pointer instead of static buffer for UDID since it can start with '0'
Diffstat (limited to 'tools/idevicedate.c')
| -rw-r--r-- | tools/idevicedate.c | 21 |
1 files changed, 7 insertions, 14 deletions
diff --git a/tools/idevicedate.c b/tools/idevicedate.c index 9de6ed0..19f7c1d 100644 --- a/tools/idevicedate.c +++ b/tools/idevicedate.c | |||
| @@ -57,10 +57,9 @@ int main(int argc, char *argv[]) | |||
| 57 | idevice_t phone = NULL; | 57 | idevice_t phone = NULL; |
| 58 | idevice_error_t ret = IDEVICE_E_UNKNOWN_ERROR; | 58 | idevice_error_t ret = IDEVICE_E_UNKNOWN_ERROR; |
| 59 | int i; | 59 | int i; |
| 60 | char udid[41]; | 60 | const char* udid = NULL; |
| 61 | time_t setdate = 0; | 61 | time_t setdate = 0; |
| 62 | plist_t node = NULL; | 62 | plist_t node = NULL; |
| 63 | udid[0] = 0; | ||
| 64 | uint64_t datetime = 0; | 63 | uint64_t datetime = 0; |
| 65 | time_t rawtime; | 64 | time_t rawtime; |
| 66 | struct tm * tmp; | 65 | struct tm * tmp; |
| @@ -79,7 +78,7 @@ int main(int argc, char *argv[]) | |||
| 79 | print_usage(argc, argv); | 78 | print_usage(argc, argv); |
| 80 | return 0; | 79 | return 0; |
| 81 | } | 80 | } |
| 82 | strcpy(udid, argv[i]); | 81 | udid = argv[i]; |
| 83 | continue; | 82 | continue; |
| 84 | } | 83 | } |
| 85 | else if (!strcmp(argv[i], "-s") || !strcmp(argv[i], "--set")) { | 84 | else if (!strcmp(argv[i], "-s") || !strcmp(argv[i], "--set")) { |
| @@ -124,20 +123,14 @@ int main(int argc, char *argv[]) | |||
| 124 | } | 123 | } |
| 125 | } | 124 | } |
| 126 | 125 | ||
| 127 | if (udid[0] != 0) { | 126 | ret = idevice_new(&phone, udid); |
| 128 | ret = idevice_new(&phone, udid); | 127 | if (ret != IDEVICE_E_SUCCESS) { |
| 129 | if (ret != IDEVICE_E_SUCCESS) { | 128 | if (udid) { |
| 130 | printf("No device found with udid %s, is it plugged in?\n", udid); | 129 | printf("No device found with udid %s, is it plugged in?\n", udid); |
| 131 | return -1; | 130 | } else { |
| 132 | } | ||
| 133 | } | ||
| 134 | else | ||
| 135 | { | ||
| 136 | ret = idevice_new(&phone, NULL); | ||
| 137 | if (ret != IDEVICE_E_SUCCESS) { | ||
| 138 | printf("No device found, is it plugged in?\n"); | 131 | printf("No device found, is it plugged in?\n"); |
| 139 | return -1; | ||
| 140 | } | 132 | } |
| 133 | return -1; | ||
| 141 | } | 134 | } |
| 142 | 135 | ||
| 143 | if (LOCKDOWN_E_SUCCESS != lockdownd_client_new_with_handshake(phone, &client, "idevicedate")) { | 136 | if (LOCKDOWN_E_SUCCESS != lockdownd_client_new_with_handshake(phone, &client, "idevicedate")) { |
