diff options
| author | 2026-10-05 11:44:56 +0900 | |
|---|---|---|
| committer | 2026-11-27 02:46:05 +0100 | |
| commit | 784d3d7069cfd9165013542bdc89c107cfc2af2e (patch) | |
| tree | 28f295f8db0fc95c6f9681635ed054f9c0250ff1 /src/idevicerestore.c | |
| parent | 72949d4ce836a815e4cf661a84f549924b407c24 (diff) | |
| download | idevicerestore-784d3d7069cfd9165013542bdc89c107cfc2af2e.tar.gz idevicerestore-784d3d7069cfd9165013542bdc89c107cfc2af2e.tar.bz2 | |
idevicerestore: Handle realloc() failure when reading gzip data
The loop that reads gzip compressed data grew its buffer with
bin = realloc(bin, bufsize), so on out-of-memory the buffer was
leaked and the next gzread() wrote through a NULL pointer.
Check the result and fail the same way as the gzread() error just
above.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Diffstat (limited to 'src/idevicerestore.c')
| -rw-r--r-- | src/idevicerestore.c | 9 |
1 files changed, 8 insertions, 1 deletions
diff --git a/src/idevicerestore.c b/src/idevicerestore.c index c1162a9..b55e585 100644 --- a/src/idevicerestore.c +++ b/src/idevicerestore.c @@ -2406,7 +2406,14 @@ int get_tss_response(struct idevicerestore_client_t* client, plist_t build_ident } } bufsize += readsize; - bin = realloc(bin, bufsize); + char* newbin = realloc(bin, bufsize); + if (!newbin) { + logger(LL_ERROR, "Out of memory while decompressing data\n"); + free(bin); + gzclose(zf); + exit(EXIT_FAILURE); + } + bin = newbin; p = bin + blen; } while (!gzeof(zf)); gzclose(zf); |
