summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGravatar Nikias Bassen2012-02-02 02:46:58 +0100
committerGravatar Nikias Bassen2012-02-02 02:46:58 +0100
commit7375f8552d78ed501800fe0cbcfe2b03d069ad8b (patch)
treeb372878f946e42d410c3b431162cef7cc852d13d
parent218fd38b273bd147cf38d79cf7b70da537225be0 (diff)
downloadidevicerestore-7375f8552d78ed501800fe0cbcfe2b03d069ad8b.tar.gz
idevicerestore-7375f8552d78ed501800fe0cbcfe2b03d069ad8b.tar.bz2
ipsw: add 0-termination to buffer returned by ipsw_extract_to_memory
-rw-r--r--src/ipsw.c4
1 files changed, 3 insertions, 1 deletions
diff --git a/src/ipsw.c b/src/ipsw.c
index d3f8839..19cf924 100644
--- a/src/ipsw.c
+++ b/src/ipsw.c
@@ -151,7 +151,7 @@ int ipsw_extract_to_memory(const char* ipsw, const char* infile, char** pbuffer,
}
int size = zstat.size;
- char* buffer = (unsigned char*) malloc(size);
+ char* buffer = (unsigned char*) malloc(size+1);
if (buffer == NULL) {
error("ERROR: Out of memory\n");
zip_fclose(zfile);
@@ -165,6 +165,8 @@ int ipsw_extract_to_memory(const char* ipsw, const char* infile, char** pbuffer,
return -1;
}
+ buffer[size] = '\0';
+
zip_fclose(zfile);
ipsw_close(archive);