diff options
| author | 2017-07-13 01:57:58 +0200 | |
|---|---|---|
| committer | 2017-07-14 12:22:43 +0200 | |
| commit | 260eec04d51fd986f895b676554b1ff6a1799417 (patch) | |
| tree | f7b51f8f800606a9ece92bf36e312f7151862d9e /src | |
| parent | a6716658c543530ac69bf6a4a45778fb224df154 (diff) | |
| download | libideviceactivation-260eec04d51fd986f895b676554b1ff6a1799417.tar.gz libideviceactivation-260eec04d51fd986f895b676554b1ff6a1799417.tar.bz2 | |
activation: Fix wrong argument check of plist_strip_xml()
This also fixes a potential segfault when xmlplist is NULL and adds
check for failing to allocate memory.
Diffstat (limited to 'src')
| -rw-r--r-- | src/activation.c | 11 | 
1 files changed, 6 insertions, 5 deletions
| diff --git a/src/activation.c b/src/activation.c index ddc924f..72e6ee7 100644 --- a/src/activation.c +++ b/src/activation.c @@ -610,22 +610,23 @@ static int plist_strip_xml(char** xmlplist)  {  	uint32_t size = 0; -	if (!xmlplist && !*xmlplist) +	if (!xmlplist || !*xmlplist)  		return -1;  	char* start = strstr(*xmlplist, "<plist version=\"1.0\">\n"); -	if (start == NULL) { +	if (!start)  		return -1; -	}  	char* stop = strstr(*xmlplist, "\n</plist>"); -	if (stop == NULL) { +	if (!stop)  		return -1; -	}  	start += strlen("<plist version=\"1.0\">\n");  	size = stop - start;  	char* stripped = malloc(size + 1); +	if (!stripped) +		return -1; +  	memset(stripped, '\0', size + 1);  	memcpy(stripped, start, size);  	free(*xmlplist); | 
