diff options
| author | 2015-12-22 18:10:35 +0100 | |
|---|---|---|
| committer | 2015-12-22 18:10:35 +0100 | |
| commit | decffad5f5a0320b1b6e9e8cda821534ba2ed0ca (patch) | |
| tree | 95c57bf6c29ae4a43a9a08a27d86848e83611b7b /tools | |
| parent | cae19fa6cf28074b51ce421d64142f7ec1e1dde2 (diff) | |
| download | libimobiledevice-decffad5f5a0320b1b6e9e8cda821534ba2ed0ca.tar.gz libimobiledevice-decffad5f5a0320b1b6e9e8cda821534ba2ed0ca.tar.bz2 | |
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.
Diffstat (limited to 'tools')
| -rw-r--r-- | tools/idevicecrashreport.c | 4 |
1 files changed, 3 insertions, 1 deletions
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 | |||
| 144 | char* p = strrchr(list[k], '.'); | 144 | char* p = strrchr(list[k], '.'); |
| 145 | if (p != NULL && !strncmp(p, ".synced", 7)) { | 145 | if (p != NULL && !strncmp(p, ".synced", 7)) { |
| 146 | /* make sure to strip ".synced" extension as seen on iOS 5 */ | 146 | /* make sure to strip ".synced" extension as seen on iOS 5 */ |
| 147 | strncpy(((char*)target_filename) + host_directory_length, list[k], strlen(list[k]) - 7); | 147 | int newlen = strlen(list[k]) - 7; |
| 148 | strncpy(((char*)target_filename) + host_directory_length, list[k], newlen); | ||
| 149 | target_filename[host_directory_length + newlen] = '\0'; | ||
| 148 | } else { | 150 | } else { |
| 149 | strcpy(((char*)target_filename) + host_directory_length, list[k]); | 151 | strcpy(((char*)target_filename) + host_directory_length, list[k]); |
| 150 | } | 152 | } |
