From 38e7b85fdde8b3dbf697535f439c96c53564ee72 Mon Sep 17 00:00:00 2001 From: Nikias Bassen Date: Wed, 16 Oct 2019 15:46:32 +0200 Subject: Fix usage of baseband and potential other components from extracted IPSW In case realpath fails, the output filename might be not set and thus fopen will fail on it during copy. Setting the resolved output filename to the given output filename in this case fixed the problem. --- src/ipsw.c | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'src') diff --git a/src/ipsw.c b/src/ipsw.c index bd02bf9..d1d858b 100644 --- a/src/ipsw.c +++ b/src/ipsw.c @@ -231,10 +231,14 @@ int ipsw_extract_to_file_with_progress(const char* ipsw, const char* infile, con ret = -1; goto leave; } else { + actual_outfile[0] = '\0'; if (realpath(outfile, actual_outfile) && (strcmp(actual_filepath, actual_outfile) == 0)) { /* files are identical */ ret = 0; } else { + if (actual_outfile[0] == '\0') { + strcpy(actual_outfile, outfile); + } FILE *fi = fopen(actual_filepath, "rb"); if (!fi) { error("ERROR: fopen: %s: %s\n", actual_filepath, strerror(errno)); -- cgit v1.1-32-gdbae