From 7375f8552d78ed501800fe0cbcfe2b03d069ad8b Mon Sep 17 00:00:00 2001 From: Nikias Bassen Date: Thu, 2 Feb 2012 02:46:58 +0100 Subject: ipsw: add 0-termination to buffer returned by ipsw_extract_to_memory --- src/ipsw.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'src/ipsw.c') 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); -- cgit v1.1-32-gdbae