summaryrefslogtreecommitdiffstats
path: root/tools/idevicebackup4.c
diff options
context:
space:
mode:
authorGravatar Nikias Bassen2011-01-07 23:46:07 +0100
committerGravatar Martin Szulecki2011-04-11 19:42:19 +0200
commitf6dc731a57cb162220433cc77f65999a2d5fd04d (patch)
tree8e215068471bcb56e0819b0b680137c02fde1a3b /tools/idevicebackup4.c
parent06fe3777633b9231879ba8087acf7803e359680f (diff)
downloadlibimobiledevice-f6dc731a57cb162220433cc77f65999a2d5fd04d.tar.gz
libimobiledevice-f6dc731a57cb162220433cc77f65999a2d5fd04d.tar.bz2
idevicebackup4: don't segfault if opening file for writing fails
Diffstat (limited to 'tools/idevicebackup4.c')
-rw-r--r--tools/idevicebackup4.c11
1 files changed, 7 insertions, 4 deletions
diff --git a/tools/idevicebackup4.c b/tools/idevicebackup4.c
index c4ee847..ef3fdd0 100644
--- a/tools/idevicebackup4.c
+++ b/tools/idevicebackup4.c
@@ -1056,7 +1056,7 @@ static int handle_receive_files(plist_t message, const char *backup_dir)
1056 1056
1057 remove(bname); 1057 remove(bname);
1058 f = fopen(bname, "wb"); 1058 f = fopen(bname, "wb");
1059 while (code == CODE_FILE_DATA) { 1059 while (f && (code == CODE_FILE_DATA)) {
1060 blocksize = nlen-1; 1060 blocksize = nlen-1;
1061 bdone = 0; 1061 bdone = 0;
1062 rlen = 0; 1062 rlen = 0;
@@ -1090,9 +1090,12 @@ static int handle_receive_files(plist_t message, const char *backup_dir)
1090 break; 1090 break;
1091 } 1091 }
1092 } 1092 }
1093 fclose(f); 1093 if (f) {
1094 1094 fclose(f);
1095 file_count++; 1095 file_count++;
1096 } else {
1097 printf("Error opening '%s' for writing: %s\n", bname, strerror(errno));
1098 }
1096 if (backup_total_size > 0) 1099 if (backup_total_size > 0)
1097 print_progress(backup_real_size, backup_total_size); 1100 print_progress(backup_real_size, backup_total_size);
1098 if (nlen == 0) { 1101 if (nlen == 0) {