summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGravatar Nikias Bassen2022-09-20 16:30:27 +0200
committerGravatar Nikias Bassen2022-09-20 16:30:27 +0200
commite9c800732b9a2be95f74b136ad6d2903d3bee56d (patch)
tree6bc571ff5c67cef48f722264bf94eaba57cb699e
parent403d2956bee60c321669421edbde29c97c238928 (diff)
downloadidevicerestore-e9c800732b9a2be95f74b136ad6d2903d3bee56d.tar.gz
idevicerestore-e9c800732b9a2be95f74b136ad6d2903d3bee56d.tar.bz2
ipsw: Add some NULL checks to ipsw_extract_to_file_with_progress()
-rw-r--r--src/ipsw.c13
1 files changed, 12 insertions, 1 deletions
diff --git a/src/ipsw.c b/src/ipsw.c
index 639ecf5..d4ee5e5 100644
--- a/src/ipsw.c
+++ b/src/ipsw.c
@@ -393,7 +393,14 @@ int ipsw_get_file_size(const char* ipsw, const char* infile, uint64_t* size)
int ipsw_extract_to_file_with_progress(const char* ipsw, const char* infile, const char* outfile, int print_progress)
{
int ret = 0;
- ipsw_archive* archive = ipsw_open(ipsw);
+ ipsw_archive* archive = NULL;
+
+ if (!ipsw || !infile || !outfile) {
+ error("ERROR: Invalid argument\n");
+ return -1;
+ }
+
+ archive = ipsw_open(ipsw);
if (archive == NULL) {
error("ERROR: Invalid archive\n");
return -1;
@@ -468,6 +475,10 @@ int ipsw_extract_to_file_with_progress(const char* ipsw, const char* infile, con
char *filepath = build_path(archive->path, infile);
char actual_filepath[PATH_MAX+1];
char actual_outfile[PATH_MAX+1];
+ if (!filepath) {
+ ret = -1;
+ goto leave;
+ }
if (!realpath(filepath, actual_filepath)) {
error("ERROR: realpath failed on %s: %s\n", filepath, strerror(errno));
ret = -1;