diff options
| author | 2026-09-29 14:54:21 +0300 | |
|---|---|---|
| committer | 2026-10-27 23:34:51 +0100 | |
| commit | 708ac9f76da507751dd6d80e240e47b74fe9a1b8 (patch) | |
| tree | c31165769426730a4948d4ddf485ef5a5632bd40 | |
| parent | 4b3e847e1d9a1210049a9e3f1d1caa38650c6617 (diff) | |
| download | idevicerestore-708ac9f76da507751dd6d80e240e47b74fe9a1b8.tar.gz idevicerestore-708ac9f76da507751dd6d80e240e47b74fe9a1b8.tar.bz2 | |
Fixed memory handling. Fixed to release mutex on error. Fixed use-after-free on ipsw zip.
| -rw-r--r-- | src/dfu.c | 3 | ||||
| -rw-r--r-- | src/ipsw.c | 8 |
2 files changed, 7 insertions, 4 deletions
@@ -47,11 +47,11 @@ int dfu_client_new(struct idevicerestore_client_t* client) if (client->dfu == NULL) { client->dfu = (struct dfu_client_t*)malloc(sizeof(struct dfu_client_t)); - memset(client->dfu, 0, sizeof(struct dfu_client_t)); if (client->dfu == NULL) { logger(LL_ERROR, "Out of memory\n"); return -1; } + memset(client->dfu, 0, sizeof(struct dfu_client_t)); } if (irecv_open_with_ecid_and_attempts(&dfu, client->ecid, 10) != IRECV_E_SUCCESS) { @@ -461,6 +461,7 @@ int dfu_enter_recovery(struct idevicerestore_client_t* client, plist_t build_ide mutex_lock(&client->device_event_mutex); if (dfu_send_component(client, build_identity, "iBSS") < 0) { + mutex_unlock(&client->device_event_mutex); logger(LL_ERROR, "Unable to send iBSS to device\n"); irecv_close(client->dfu->client); client->dfu->client = NULL; @@ -683,13 +683,15 @@ int ipsw_extract_to_memory(ipsw_archive_t ipsw, const char* infile, void** pbuff } zip_int64_t zr = zip_fread(zfile, buffer, size); + int zep = 0; + int sep = 0; + if (zr < 0) { + zip_file_error_get(zfile, &zep, &sep); + } zip_fclose(zfile); zip_unchange_all(zip); zip_close(zip); if (zr < 0) { - int zep = 0; - int sep = 0; - zip_file_error_get(zfile, &zep, &sep); logger(LL_ERROR, "zip_fread: %s %d %d\n", infile, zep, sep); free(buffer); return -1; |
