From 784d3d7069cfd9165013542bdc89c107cfc2af2e Mon Sep 17 00:00:00 2001 From: Comtea04 Date: Mon, 5 Oct 2026 11:44:56 +0900 Subject: 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 --- src/idevicerestore.c | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) (limited to 'src') 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); -- cgit v1.1-32-gdbae