Wireshark-dev: Re: [Wireshark-dev] Crash in epan/geoip_db.c
From: João Valverde <joao.valverde@xxxxxxxxxxxxxxxxxx>
Date: Tue, 21 Feb 2017 22:38:55 +0000


On 02/21/2017 09:09 PM, Gisle Vanem wrote:
Hi list.

I got a crash in epan/geoip_db.c and MSVCRT:free().
Due to the use of g_free() at line 379:

            case GEOIP_ASNUM_EDITION:
                raw_val = GeoIP_name_by_ipnum(gi, addr);
                if (raw_val) {
                    ret = db_val_to_utf_8(raw_val, gi);
                    g_free((char*)raw_val);  << line 379
                }

In my case, the 'raw_val' was not allocated by Glib, but
by MSVC's CRT directly. So shouldn't these 'g_free()' really be
'free()'? Or is the "official" GeoIP-1.6.6-win32ws.zip built using
Glib now?

This works for me:

--- a/epan/geoip_db.c 2017-02-21 20:23:21
+++ b/epan/geoip_db.c 2017-02-21 21:58:27
@@ -376,7 +376,7 @@
                 raw_val = GeoIP_name_by_ipnum(gi, addr);
                 if (raw_val) {
                     ret = db_val_to_utf_8(raw_val, gi);
-                    g_free((char*)raw_val);
+                    free((char*)raw_val);
                 }
                 break;

@@ -507,7 +507,7 @@
                 raw_val = GeoIP_name_by_ipnum_v6(gi, gaddr);
                 if (raw_val) {
                     ret = db_val_to_utf_8(raw_val, gi);
-                    g_free((char*)raw_val);
+                    free((char*)raw_val);
                 }
                 break;


Fixes 850393b57bdd7011780f4cf897d4a2467f58a673. Please push to Gerrit. Bonus points for fixing the cast too.