summaryrefslogtreecommitdiffstats
path: root/tools
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
parent06fe3777633b9231879ba8087acf7803e359680f (diff)
downloadlibimobiledevice-f6dc731a57cb162220433cc77f65999a2d5fd04d.tar.gz
libimobiledevice-f6dc731a57cb162220433cc77f65999a2d5fd04d.tar.bz2
idevicebackup4: don't segfault if opening file for writing fails
Diffstat (limited to 'tools')
-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)
remove(bname);
f = fopen(bname, "wb");
- while (code == CODE_FILE_DATA) {
+ while (f && (code == CODE_FILE_DATA)) {
blocksize = nlen-1;
bdone = 0;
rlen = 0;
@@ -1090,9 +1090,12 @@ static int handle_receive_files(plist_t message, const char *backup_dir)
break;
}
}
- fclose(f);
-
- file_count++;
+ if (f) {
+ fclose(f);
+ file_count++;
+ } else {
+ printf("Error opening '%s' for writing: %s\n", bname, strerror(errno));
+ }
if (backup_total_size > 0)
print_progress(backup_real_size, backup_total_size);
if (nlen == 0) {