diff options
author | 137734949 | 2019-09-10 12:43:16 +0800 |
---|---|---|
committer | Nikias Bassen | 2019-09-11 09:03:11 +0200 |
commit | 573c3688c83f395ec4174a04b9adc2013e4ccab3 (patch) | |
tree | 6428268ba65ed433f8fa952189533d3e3a4784dd | |
parent | b6e408c16923ef6d093c02c13cd7ac0e014dc4fe (diff) | |
download | idevicerestore-573c3688c83f395ec4174a04b9adc2013e4ccab3.tar.gz idevicerestore-573c3688c83f395ec4174a04b9adc2013e4ccab3.tar.bz2 |
tss: Fix crash due to use-after-free in tss_request_send() if connection fails
-rw-r--r-- | src/tss.c | 7 |
1 files changed, 4 insertions, 3 deletions
@@ -1188,6 +1188,7 @@ plist_t tss_request_send(plist_t tss_request, const char* server_url_string) { // no status code in response. retry free(response->content); free(response); + response = NULL; sleep(2); continue; } else if (status_code == 8) { @@ -1211,15 +1212,15 @@ plist_t tss_request_send(plist_t tss_request, const char* server_url_string) { } if (status_code != 0) { - if (strstr(response->content, "MESSAGE=") != NULL) { + if (response && strstr(response->content, "MESSAGE=") != NULL) { char* message = strstr(response->content, "MESSAGE=") + strlen("MESSAGE="); error("ERROR: TSS request failed (status=%d, message=%s)\n", status_code, message); } else { error("ERROR: TSS request failed: %s (status=%d)\n", curl_error_message, status_code); } free(request); - free(response->content); - free(response); + if (response) free(response->content); + if (response) free(response); return NULL; } |