diff options
author | Nikias Bassen | 2012-11-29 03:42:06 +0100 |
---|---|---|
committer | Nikias Bassen | 2012-11-29 03:42:06 +0100 |
commit | 36c0192fbb16d068214d2640aecfb731ea24bfaa (patch) | |
tree | 4596eb003c5f074c4ca0b9e1e146680927916d11 /tools/idevicebackup2.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/idevicebackup2.c')
-rw-r--r-- | tools/idevicebackup2.c | 16 |
1 files changed, 8 insertions, 8 deletions
diff --git a/tools/idevicebackup2.c b/tools/idevicebackup2.c index 635a5ab..71afb5b 100644 --- a/tools/idevicebackup2.c +++ b/tools/idevicebackup2.c @@ -1197,9 +1197,8 @@ int main(int argc, char *argv[]) { idevice_error_t ret = IDEVICE_E_UNKNOWN_ERROR; int i; - char udid[41]; + char* udid = NULL; uint16_t port = 0; - udid[0] = 0; int cmd = -1; int cmd_flags = 0; int is_full_backup = 0; @@ -1230,7 +1229,7 @@ int main(int argc, char *argv[]) print_usage(argc, argv); return 0; } - strcpy(udid, argv[i]); + udid = strdup(argv[i]); continue; } else if (!strcmp(argv[i], "-h") || !strcmp(argv[i], "--help")) { @@ -1294,7 +1293,7 @@ int main(int argc, char *argv[]) return -1; } - if (udid[0] != 0) { + if (udid) { ret = idevice_new(&phone, udid); if (ret != IDEVICE_E_SUCCESS) { printf("No device found with udid %s, is it plugged in?\n", udid); @@ -1308,10 +1307,7 @@ int main(int argc, char *argv[]) printf("No device found, is it plugged in?\n"); return -1; } - char *newudid = NULL; - idevice_get_udid(phone, &newudid); - strcpy(udid, newudid); - free(newudid); + idevice_get_udid(phone, &udid); } /* backup directory must contain an Info.plist */ @@ -1893,6 +1889,10 @@ files_out: idevice_free(phone); + if (udid) { + free(udid); + } + return 0; } |