From 2f43dee3a51eeb96746c0f27bba837b9e423788b Mon Sep 17 00:00:00 2001 From: Tobias Klauser Date: Wed, 11 Nov 2015 14:46:00 +0100 Subject: geoip: Error out if file is not inflated completely In case the downloaded gzip file got corrupted somehow, the gzread would fail, leaving part of the file uninflated and thus leading to a corrupted GeoIP database. This can in the worst case lead to a crash in libgeoip which in turn causes netsniff-ng/flowtop/astraceroute to crash. So better panic() if we fail to uncompress. Signed-off-by: Tobias Klauser --- geoip.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/geoip.c b/geoip.c index 78b20fe..439c052 100644 --- a/geoip.c +++ b/geoip.c @@ -150,6 +150,9 @@ static void geoip_inflate(int which) while ((ret = gzread(fpi, raw, sizeof(raw))) && ret2) ret2 = fwrite(raw, ret, 1, fpo); + if (!gzeof(fpi)) + panic("Error in gzread: %s\n", gzerror(fpi, &ret)); + gzclose(fpi); fclose(fpo); } -- cgit v1.2.3-54-g00ecf