summaryrefslogtreecommitdiffstats
path: root/src/phrecn.c
diff options
context:
space:
mode:
authorChristophe Grenier <grenier@cgsecurity.org>2009-11-01 11:20:54 +0100
committerChristophe Grenier <grenier@cgsecurity.org>2009-11-01 11:20:54 +0100
commit174dc0f7b6fb12f42d8809167c3509b813650a67 (patch)
treedbc7af32468254d1930fe54c97940f7bfdd21726 /src/phrecn.c
parent8abc660f79188ecbd6eb4a4842e8cf839b3c37de (diff)
Add missing fwrite return check
Diffstat (limited to 'src/phrecn.c')
-rw-r--r--src/phrecn.c17
1 files changed, 15 insertions, 2 deletions
diff --git a/src/phrecn.c b/src/phrecn.c
index 3227e3d..4d9d63d 100644
--- a/src/phrecn.c
+++ b/src/phrecn.c
@@ -590,7 +590,13 @@ static void gen_image(const char *filename, disk_t *disk, const alloc_data_t *li
const unsigned int read_size=(current_search_space->end - offset + 1 < buffer_size ?
current_search_space->end - offset + 1 : buffer_size);
disk->pread(disk, buffer, read_size, offset);
- fwrite(buffer, read_size, 1, out);
+ if(fwrite(buffer, read_size, 1, out)<1)
+ {
+ log_critical("Cannot write to file %s:%s\n", filename, strerror(errno));
+ free(buffer);
+ fclose(out);
+ return ;
+ }
}
}
free(buffer);
@@ -664,7 +670,14 @@ static void test_files_aux(disk_t *disk, partition_t *partition, file_recovery_t
return;
}
}
- fwrite(buffer, datasize, 1, file_recovery->handle);
+ if(fwrite(buffer, datasize, 1, file_recovery->handle)<1)
+ {
+ log_critical("Cannot write to file %s:%s\n", file_recovery->filename, strerror(errno));
+ fclose(file_recovery->handle)
+ file_recovery->handle=NULL;
+ free(buffer);
+ return;
+ }
list_append_block(&file_recovery->location, start, datasize, 1);
file_recovery->calculated_file_size=0;
file_recovery->file_size+=datasize;