From decffad5f5a0320b1b6e9e8cda821534ba2ed0ca Mon Sep 17 00:00:00 2001 From: Nikias Bassen Date: Tue, 22 Dec 2015 18:10:35 +0100 Subject: tools: idevicecrashreport: Fix missing 0-term when creating local filename When a .synced file is encountered, the .synced should be stripped off the local filename. However the strncpy doesn't 0-terminate the string by itself so the output filename usually contains some garbage characters at the end. This commit properly 0-terminates the local filename to avoid this. --- tools/idevicecrashreport.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'tools/idevicecrashreport.c') diff --git a/tools/idevicecrashreport.c b/tools/idevicecrashreport.c index 8502938..4d7f41c 100644 --- a/tools/idevicecrashreport.c +++ b/tools/idevicecrashreport.c @@ -144,7 +144,9 @@ static int afc_client_copy_and_remove_crash_reports(afc_client_t afc, const char char* p = strrchr(list[k], '.'); if (p != NULL && !strncmp(p, ".synced", 7)) { /* make sure to strip ".synced" extension as seen on iOS 5 */ - strncpy(((char*)target_filename) + host_directory_length, list[k], strlen(list[k]) - 7); + int newlen = strlen(list[k]) - 7; + strncpy(((char*)target_filename) + host_directory_length, list[k], newlen); + target_filename[host_directory_length + newlen] = '\0'; } else { strcpy(((char*)target_filename) + host_directory_length, list[k]); } -- cgit v1.1-32-gdbae