From owner-svn-ports-all@freebsd.org Tue Aug 4 09:59:58 2020 Return-Path: Delivered-To: svn-ports-all@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id A6BDE3B6B92; Tue, 4 Aug 2020 09:59:58 +0000 (UTC) (envelope-from zi@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4BLVby4Ljdz48qM; Tue, 4 Aug 2020 09:59:58 +0000 (UTC) (envelope-from zi@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 74F3F234F0; Tue, 4 Aug 2020 09:59:58 +0000 (UTC) (envelope-from zi@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id 0749xwLt041566; Tue, 4 Aug 2020 09:59:58 GMT (envelope-from zi@FreeBSD.org) Received: (from zi@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id 0749xwU6041565; Tue, 4 Aug 2020 09:59:58 GMT (envelope-from zi@FreeBSD.org) Message-Id: <202008040959.0749xwU6041565@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: zi set sender to zi@FreeBSD.org using -f From: Ryan Steinmetz Date: Tue, 4 Aug 2020 09:59:58 +0000 (UTC) To: ports-committers@freebsd.org, svn-ports-all@freebsd.org, svn-ports-head@freebsd.org Subject: svn commit: r544161 - in head/net/ip2location: . files X-SVN-Group: ports-head X-SVN-Commit-Author: zi X-SVN-Commit-Paths: in head/net/ip2location: . files X-SVN-Commit-Revision: 544161 X-SVN-Commit-Repository: ports MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-ports-all@freebsd.org X-Mailman-Version: 2.1.33 Precedence: list List-Id: SVN commit messages for the ports tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 04 Aug 2020 09:59:58 -0000 Author: zi Date: Tue Aug 4 09:59:57 2020 New Revision: 544161 URL: https://svnweb.freebsd.org/changeset/ports/544161 Log: - Merge in upstream patch to address memory leaks - Bump PORTREVISION Added: head/net/ip2location/files/ head/net/ip2location/files/patch-memleak (contents, props changed) Modified: head/net/ip2location/Makefile Modified: head/net/ip2location/Makefile ============================================================================== --- head/net/ip2location/Makefile Tue Aug 4 09:47:33 2020 (r544160) +++ head/net/ip2location/Makefile Tue Aug 4 09:59:57 2020 (r544161) @@ -3,6 +3,7 @@ PORTNAME= ip2location PORTVERSION= 8.0.9 +PORTREVISION= 1 CATEGORIES= net MAINTAINER= zi@FreeBSD.org Added: head/net/ip2location/files/patch-memleak ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ head/net/ip2location/files/patch-memleak Tue Aug 4 09:59:57 2020 (r544161) @@ -0,0 +1,369 @@ +diff --git a/libIP2Location/IP2Location.c b/libIP2Location/IP2Location.c +index fbe7fe0..a57ba2f 100644 +--- libIP2Location/IP2Location.c ++++ libIP2Location/IP2Location.c +@@ -151,8 +151,8 @@ static int IP2Location_initialize(IP2Location *loc) + loc->ipv6databasecount = IP2Location_read32(loc->filehandle, 14); + loc->ipv6databaseaddr = IP2Location_read32(loc->filehandle, 18); + +- loc->ipv4indexbaseaddr = IP2Location_read32(loc->filehandle, 22); +- loc->ipv6indexbaseaddr = IP2Location_read32(loc->filehandle, 26); ++ loc->ipv4indexbaseaddr = IP2Location_read32(loc->filehandle, 22); ++ loc->ipv6indexbaseaddr = IP2Location_read32(loc->filehandle, 26); + + return 0; + } +@@ -381,47 +381,77 @@ static IP2LocationRecord *IP2Location_read_record(IP2Location *loc, uint32_t row + + if ((mode & COUNTRYSHORT) && (COUNTRY_POSITION[dbtype] != 0)) + { +- record->country_short = IP2Location_readStr(handle, IP2Location_read32(handle, rowaddr + 4 * (COUNTRY_POSITION[dbtype]-1))); ++ if (!record->country_short) ++ { ++ record->country_short = IP2Location_readStr(handle, IP2Location_read32(handle, rowaddr + 4 * (COUNTRY_POSITION[dbtype]-1))); ++ } + } + else + { +- record->country_short = strdup(NOT_SUPPORTED); ++ if (!record->country_short) ++ { ++ record->country_short = strdup(NOT_SUPPORTED); ++ } + } + + if ((mode & COUNTRYLONG) && (COUNTRY_POSITION[dbtype] != 0)) + { +- record->country_long = IP2Location_readStr(handle, IP2Location_read32(handle, rowaddr + 4 * (COUNTRY_POSITION[dbtype]-1))+3); ++ if (!record->country_long) ++ { ++ record->country_long = IP2Location_readStr(handle, IP2Location_read32(handle, rowaddr + 4 * (COUNTRY_POSITION[dbtype]-1))+3); ++ } + } + else + { +- record->country_long = strdup(NOT_SUPPORTED); ++ if (!record->country_long) ++ { ++ record->country_long = strdup(NOT_SUPPORTED); ++ } + } + + if ((mode & REGION) && (REGION_POSITION[dbtype] != 0)) + { +- record->region = IP2Location_readStr(handle, IP2Location_read32(handle, rowaddr + 4 * (REGION_POSITION[dbtype]-1))); ++ if (!record->region) ++ { ++ record->region = IP2Location_readStr(handle, IP2Location_read32(handle, rowaddr + 4 * (REGION_POSITION[dbtype]-1))); ++ } + } + else + { +- record->region = strdup(NOT_SUPPORTED); ++ if (!record->region) ++ { ++ record->region = strdup(NOT_SUPPORTED); ++ } + } + + if ((mode & CITY) && (CITY_POSITION[dbtype] != 0)) + { +- record->city = IP2Location_readStr(handle, IP2Location_read32(handle, rowaddr + 4 * (CITY_POSITION[dbtype]-1))); ++ if (!record->city) ++ { ++ record->city = IP2Location_readStr(handle, IP2Location_read32(handle, rowaddr + 4 * (CITY_POSITION[dbtype]-1))); ++ } + } + else + { +- record->city = strdup(NOT_SUPPORTED); ++ if (!record->city) ++ { ++ record->city = strdup(NOT_SUPPORTED); ++ } + } + + if ((mode & ISP) && (ISP_POSITION[dbtype] != 0)) + { +- record->isp = IP2Location_readStr(handle, IP2Location_read32(handle, rowaddr + 4 * (ISP_POSITION[dbtype]-1))); ++ if (!record->isp) ++ { ++ record->isp = IP2Location_readStr(handle, IP2Location_read32(handle, rowaddr + 4 * (ISP_POSITION[dbtype]-1))); ++ } + } + else + { +- record->isp = strdup(NOT_SUPPORTED); ++ if (!record->isp) ++ { ++ record->isp = strdup(NOT_SUPPORTED); ++ } + } + + if ((mode & LATITUDE) && (LATITUDE_POSITION[dbtype] != 0)) +@@ -444,108 +474,174 @@ static IP2LocationRecord *IP2Location_read_record(IP2Location *loc, uint32_t row + + if ((mode & DOMAIN_) && (DOMAIN_POSITION[dbtype] != 0)) + { +- record->domain = IP2Location_readStr(handle, IP2Location_read32(handle, rowaddr + 4 * (DOMAIN_POSITION[dbtype]-1))); ++ if (!record->domain) ++ { ++ record->domain = IP2Location_readStr(handle, IP2Location_read32(handle, rowaddr + 4 * (DOMAIN_POSITION[dbtype]-1))); ++ } + } + else + { +- record->domain = strdup(NOT_SUPPORTED); ++ if (!record->domain) ++ { ++ record->domain = strdup(NOT_SUPPORTED); ++ } + } + + if ((mode & ZIPCODE) && (ZIPCODE_POSITION[dbtype] != 0)) + { +- record->zipcode = IP2Location_readStr(handle, IP2Location_read32(handle, rowaddr + 4 * (ZIPCODE_POSITION[dbtype]-1))); ++ if (!record->zipcode) ++ { ++ record->zipcode = IP2Location_readStr(handle, IP2Location_read32(handle, rowaddr + 4 * (ZIPCODE_POSITION[dbtype]-1))); ++ } + } + else + { +- record->zipcode = strdup(NOT_SUPPORTED); ++ if (!record->zipcode) ++ { ++ record->zipcode = strdup(NOT_SUPPORTED); ++ } + } + + if ((mode & TIMEZONE) && (TIMEZONE_POSITION[dbtype] != 0)) + { +- record->timezone = IP2Location_readStr(handle, IP2Location_read32(handle, rowaddr + 4 * (TIMEZONE_POSITION[dbtype]-1))); ++ if (!record->timezone) ++ { ++ record->timezone = IP2Location_readStr(handle, IP2Location_read32(handle, rowaddr + 4 * (TIMEZONE_POSITION[dbtype]-1))); ++ } + } + else + { +- record->timezone = strdup(NOT_SUPPORTED); ++ if (!record->timezone) ++ { ++ record->timezone = strdup(NOT_SUPPORTED); ++ } + } + + if ((mode & NETSPEED) && (NETSPEED_POSITION[dbtype] != 0)) + { +- record->netspeed = IP2Location_readStr(handle, IP2Location_read32(handle, rowaddr + 4 * (NETSPEED_POSITION[dbtype]-1))); ++ if (!record->netspeed) ++ { ++ record->netspeed = IP2Location_readStr(handle, IP2Location_read32(handle, rowaddr + 4 * (NETSPEED_POSITION[dbtype]-1))); ++ } + } + else + { +- record->netspeed = strdup(NOT_SUPPORTED); ++ if (!record->netspeed) ++ { ++ record->netspeed = strdup(NOT_SUPPORTED); ++ } + } + + if ((mode & IDDCODE) && (IDDCODE_POSITION[dbtype] != 0)) + { +- record->iddcode = IP2Location_readStr(handle, IP2Location_read32(handle, rowaddr + 4 * (IDDCODE_POSITION[dbtype]-1))); ++ if (!record->iddcode) ++ { ++ record->iddcode = IP2Location_readStr(handle, IP2Location_read32(handle, rowaddr + 4 * (IDDCODE_POSITION[dbtype]-1))); ++ } + } + else + { +- record->iddcode = strdup(NOT_SUPPORTED); ++ if (!record->iddcode) ++ { ++ record->iddcode = strdup(NOT_SUPPORTED); ++ } + } + + if ((mode & AREACODE) && (AREACODE_POSITION[dbtype] != 0)) + { +- record->areacode = IP2Location_readStr(handle, IP2Location_read32(handle, rowaddr + 4 * (AREACODE_POSITION[dbtype]-1))); ++ if (!record->areacode) ++ { ++ record->areacode = IP2Location_readStr(handle, IP2Location_read32(handle, rowaddr + 4 * (AREACODE_POSITION[dbtype]-1))); ++ } + } + else + { +- record->areacode = strdup(NOT_SUPPORTED); ++ if (!record->areacode) ++ { ++ record->areacode = strdup(NOT_SUPPORTED); ++ } + } + + if ((mode & WEATHERSTATIONCODE) && (WEATHERSTATIONCODE_POSITION[dbtype] != 0)) + { +- record->weatherstationcode = IP2Location_readStr(handle, IP2Location_read32(handle, rowaddr + 4 * (WEATHERSTATIONCODE_POSITION[dbtype]-1))); ++ if (!record->weatherstationcode) ++ { ++ record->weatherstationcode = IP2Location_readStr(handle, IP2Location_read32(handle, rowaddr + 4 * (WEATHERSTATIONCODE_POSITION[dbtype]-1))); ++ } + } + else + { +- record->weatherstationcode = strdup(NOT_SUPPORTED); ++ if (!record->weatherstationcode) ++ { ++ record->weatherstationcode = strdup(NOT_SUPPORTED); ++ } + } + + if ((mode & WEATHERSTATIONNAME) && (WEATHERSTATIONNAME_POSITION[dbtype] != 0)) + { +- record->weatherstationname = IP2Location_readStr(handle, IP2Location_read32(handle, rowaddr + 4 * (WEATHERSTATIONNAME_POSITION[dbtype]-1))); ++ if (!record->weatherstationname) ++ { ++ record->weatherstationname = IP2Location_readStr(handle, IP2Location_read32(handle, rowaddr + 4 * (WEATHERSTATIONNAME_POSITION[dbtype]-1))); ++ } + } + else + { +- record->weatherstationname = strdup(NOT_SUPPORTED); ++ if (!record->weatherstationname) ++ { ++ record->weatherstationname = strdup(NOT_SUPPORTED); ++ } + } + + if ((mode & MCC) && (MCC_POSITION[dbtype] != 0)) + { +- record->mcc = IP2Location_readStr(handle, IP2Location_read32(handle, rowaddr + 4 * (MCC_POSITION[dbtype]-1))); ++ if (!record->mcc) ++ { ++ record->mcc = IP2Location_readStr(handle, IP2Location_read32(handle, rowaddr + 4 * (MCC_POSITION[dbtype]-1))); ++ } + } + else + { +- record->mcc = strdup(NOT_SUPPORTED); ++ if (!record->mcc) ++ { ++ record->mcc = strdup(NOT_SUPPORTED); ++ } + } + + if ((mode & MNC) && (MNC_POSITION[dbtype] != 0)) + { +- record->mnc = IP2Location_readStr(handle, IP2Location_read32(handle, rowaddr + 4 * (MNC_POSITION[dbtype]-1))); ++ if (!record->mnc) ++ { ++ record->mnc = IP2Location_readStr(handle, IP2Location_read32(handle, rowaddr + 4 * (MNC_POSITION[dbtype]-1))); ++ } + } + else + { +- record->mnc = strdup(NOT_SUPPORTED); ++ if (!record->mnc) ++ { ++ record->mnc = strdup(NOT_SUPPORTED); ++ } + } + + if ((mode & MOBILEBRAND) && (MOBILEBRAND_POSITION[dbtype] != 0)) + { +- record->mobilebrand = IP2Location_readStr(handle, IP2Location_read32(handle, rowaddr + 4 * (MOBILEBRAND_POSITION[dbtype]-1))); ++ if (!record->mobilebrand) ++ { ++ record->mobilebrand = IP2Location_readStr(handle, IP2Location_read32(handle, rowaddr + 4 * (MOBILEBRAND_POSITION[dbtype]-1))); ++ } + } + else + { +- record->mobilebrand = strdup(NOT_SUPPORTED); ++ if (!record->mobilebrand) ++ { ++ record->mobilebrand = strdup(NOT_SUPPORTED); ++ } + } + + if ((mode & ELEVATION) && (ELEVATION_POSITION[dbtype] != 0)) + { + char *mem = IP2Location_readStr(handle, IP2Location_read32(handle, rowaddr + 4 * (ELEVATION_POSITION[dbtype]-1))); +- record->elevation = atof(mem); +- free(mem); ++ record->elevation = atof(mem); ++ free(mem); + } + else + { +@@ -554,11 +650,17 @@ static IP2LocationRecord *IP2Location_read_record(IP2Location *loc, uint32_t row + + if ((mode & USAGETYPE) && (USAGETYPE_POSITION[dbtype] != 0)) + { +- record->usagetype = IP2Location_readStr(handle, IP2Location_read32(handle, rowaddr + 4 * (USAGETYPE_POSITION[dbtype]-1))); ++ if (!record->usagetype) ++ { ++ record->usagetype = IP2Location_readStr(handle, IP2Location_read32(handle, rowaddr + 4 * (USAGETYPE_POSITION[dbtype]-1))); ++ } + } + else + { +- record->usagetype = strdup(NOT_SUPPORTED); ++ if (!record->usagetype) ++ { ++ record->usagetype = strdup(NOT_SUPPORTED); ++ } + } + return record; + } +@@ -658,7 +760,7 @@ static IP2LocationRecord *IP2Location_get_ipv4_record(IP2Location *loc, char *ip + { + mid = (uint32_t)((low + high) >> 1); + ipfrom = IP2Location_read32(handle, baseaddr + mid * dbcolumn * 4); +- ipto = IP2Location_read32(handle, baseaddr + (mid + 1) * dbcolumn * 4); ++ ipto = IP2Location_read32(handle, baseaddr + (mid + 1) * dbcolumn * 4); + + if ((ipno >= ipfrom) && (ipno < ipto)) + { +@@ -683,17 +785,17 @@ static IP2LocationRecord *IP2Location_get_ipv4_record(IP2Location *loc, char *ip + static IP2LocationRecord *IP2Location_get_record(IP2Location *loc, char *ipstring, uint32_t mode) + { + ipv_t parsed_ipv = IP2Location_parse_addr(ipstring); +- if (parsed_ipv.ipversion == 4) +- { +- //process IPv4 +- return IP2Location_get_ipv4_record(loc, ipstring, mode, parsed_ipv); +- } ++ if (parsed_ipv.ipversion == 4) ++ { ++ //process IPv4 ++ return IP2Location_get_ipv4_record(loc, ipstring, mode, parsed_ipv); ++ } + if (parsed_ipv.ipversion == 6) + { +- //process IPv6 ++ //process IPv6 + return IP2Location_get_ipv6_record(loc, ipstring, mode, parsed_ipv); + } +- else ++ else + { + return IP2Location_bad_record(INVALID_IPV4_ADDRESS); + } +diff --git a/libIP2Location/IP2Location.h b/libIP2Location/IP2Location.h +index b425362..34e9ada 100644 +--- libIP2Location/IP2Location.h ++++ libIP2Location/IP2Location.h +@@ -56,7 +56,7 @@ extern "C" { + #include "IP2Loc_DBInterface.h" + + /* API version changes only if functions are added (release) or changed (minor/major) */ +-#define API_VERSION 8.0.8 ++#define API_VERSION 8.0.9 + + + #define API_VERSION_MAJOR 8