diff options
author | Vadim Kochan <vadim4j@gmail.com> | 2017-02-04 11:56:14 +0200 |
---|---|---|
committer | Tobias Klauser <tklauser@distanz.ch> | 2017-02-06 17:26:28 +0100 |
commit | 8fd19eefa46b313673d6ba2a0194a68674ef5ea9 (patch) | |
tree | 569da73381afb80fe8eb70d1183fbac0339da4ef /flowtop.c | |
parent | 1e1383fea55fb35cec96a352da93c2a31d9e897c (diff) |
geoip: Fix memory leak when using GeoIPRecord
GeoIP_record_by_ipnum{,_v6} returns allocated pointer to
GeoIPRecord with allocated city, region & postal_code which is
not freed after the call.
Fixed by xstrdup-ing required GeoIPRecord member (city/region) and
after calling GeoIPRecord_delete to free the geoip record.
Of course it is needed to also free obtained city/region in netsniff-ng,
astraceroute & flowtop tools.
Fixes #169
Signed-off-by: Vadim Kochan <vadim4j@gmail.com>
Signed-off-by: Tobias Klauser <tklauser@distanz.ch>
Diffstat (limited to 'flowtop.c')
-rw-r--r-- | flowtop.c | 4 |
1 files changed, 3 insertions, 1 deletions
@@ -682,7 +682,7 @@ flow_entry_geo_city_lookup_generic(struct flow_entry *n, { struct sockaddr_in sa4; struct sockaddr_in6 sa6; - const char *city = NULL; + char *city = NULL; switch (n->l3_proto) { default: @@ -706,6 +706,8 @@ flow_entry_geo_city_lookup_generic(struct flow_entry *n, sizeof(n->city_src)); else SELFLD(dir, city_src, city_dst)[0] = '\0'; + + free(city); } static void |