summaryrefslogtreecommitdiffstats
path: root/src/tss.c
diff options
context:
space:
mode:
authorGravatar 1377349492019-09-10 12:43:16 +0800
committerGravatar Nikias Bassen2019-09-11 09:03:11 +0200
commit573c3688c83f395ec4174a04b9adc2013e4ccab3 (patch)
tree6428268ba65ed433f8fa952189533d3e3a4784dd /src/tss.c
parentb6e408c16923ef6d093c02c13cd7ac0e014dc4fe (diff)
downloadidevicerestore-573c3688c83f395ec4174a04b9adc2013e4ccab3.tar.gz
idevicerestore-573c3688c83f395ec4174a04b9adc2013e4ccab3.tar.bz2
tss: Fix crash due to use-after-free in tss_request_send() if connection fails
Diffstat (limited to 'src/tss.c')
-rw-r--r--src/tss.c7
1 files changed, 4 insertions, 3 deletions
diff --git a/src/tss.c b/src/tss.c
index 391d730..b812b55 100644
--- a/src/tss.c
+++ b/src/tss.c
@@ -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;
}