summaryrefslogtreecommitdiffstats
path: root/IP2Location-8.0.9-adebc0ef.patch
diff options
context:
space:
mode:
Diffstat (limited to 'IP2Location-8.0.9-adebc0ef.patch')
-rw-r--r--IP2Location-8.0.9-adebc0ef.patch711
1 files changed, 0 insertions, 711 deletions
diff --git a/IP2Location-8.0.9-adebc0ef.patch b/IP2Location-8.0.9-adebc0ef.patch
deleted file mode 100644
index bb3940a..0000000
--- a/IP2Location-8.0.9-adebc0ef.patch
+++ /dev/null
@@ -1,711 +0,0 @@
-diff --git a/README.md b/README.md
-index 85a3d1f..806b3cd 100644
---- a/README.md
-+++ b/README.md
-@@ -46,6 +46,12 @@ For more details, please visit:
- * Use the IPv4 BIN file if you just need to query IPv4 addresses.
- * Use the IPv6 BIN file if you need to query BOTH IPv4 and IPv6 addresses.
-
-+# NOTES
-+If you encountered **error while loading shared libraries** in linux platform, that could be due to the shared library was saved into **usr/local/lib** that might not be the default library path. You can run the below command
-+```
-+ldconfig /usr/local/lib
-+```
-+
- # Support
- Email: support@ip2location.com.
- URL: [https://www.ip2location.com](https://www.ip2location.com)
-diff --git a/contrib/IP2Location.spec b/contrib/IP2Location.spec
-index 7b76cb8..8fed016 100644
---- a/contrib/IP2Location.spec
-+++ b/contrib/IP2Location.spec
-@@ -3,12 +3,10 @@
- Name: IP2Location
- Summary: C library for mapping IP address to geolocation information
- Version: %{version}
--Release: 5%{?dist}
--Group: System Environment/Libraries
-+Release: 6%{?dist}
- License: MIT
- URL: http://www.ip2location.com/
--Source0: https://github.com/chrislim2888/IP2Location-C-Library/archive/%{version}.tar.gz
--BuildRoot: %{_tmppath}/%{name}-%{version}-%{release}-root-%(%{__id_u} -n)
-+Source0: https://github.com/chrislim2888/IP2Location-C-Library/archive/%{version}/%{name}-%{version}.tar.gz
- BuildRequires: libtool
-
-
-@@ -26,7 +24,6 @@ the included downloader.
-
- %package devel
- Summary: Static library and header files for the ip2location library
--Group: Development/C
- Requires: %{name} = %{version}-%{release}
- Provides: %{name}-devel = %{version}-%{release}
-
-@@ -51,63 +48,60 @@ perl -pi -e 's/-Wno-unused-result//' configure.ac
-
- %build
- sh ./bootstrap
--autoreconf -fi
-+autoreconf -fiv
-
- %configure --disable-static
--make clean
--make %{?_smp_mflags} COPTS="$RPM_OPT_FLAGS"
-+%make_build COPTS="$RPM_OPT_FLAGS"
-
- # convert CSV to BIN
- make -C data convert
-
-+
- %check
- LD_LIBRARY_PATH=%{buildroot}%{_libdir}:$LD_LIBRARY_PATH make check
-
-
- %install
--rm -rf %{buildroot}
--
--make install DESTDIR=%{buildroot}
-+%make_install
-
- # cleanup
- rm -f %{buildroot}%{_libdir}/*.*a
-
- # tools
- install -d %{buildroot}%{_datadir}/%{name}/tools
--cp tools/download.pl %{buildroot}%{_datadir}/%{name}/tools
-+install -pm 0755 tools/download.pl %{buildroot}%{_datadir}/%{name}/tools
-
- # database directory
- install -d %{buildroot}%{_datadir}/%{name}/
-
-
--%post -p /sbin/ldconfig
--
--%postun -p /sbin/ldconfig
--
--
--%clean
--rm -rf %{buildroot}
--
- %files
--%defattr(644,root,root,755)
-+%license COPYING LICENSE.TXT
-
--%doc AUTHORS ChangeLog COPYING README.md LICENSE.TXT NEWS INSTALL LICENSE.TXT
-+%doc AUTHORS ChangeLog README.md NEWS
-
--%attr(755,-,-) %{_libdir}/*.so*
-+%{_libdir}/libIP2Location.so.1
-+%{_libdir}/libIP2Location.so.1.0.0
-
--%attr(755,-,-) %{_datadir}/%{name}/tools/*
-+%{_datadir}/%{name}/tools/
-
- %dir %{_datadir}/%{name}/
-
-
- %files devel
--%defattr(-,root,root)
--%{_includedir}/*
-+%{_includedir}/IP2Loc*.h
-+%{_libdir}/libIP2Location.so
-
- %doc Developers_Guide.txt
-
-
- %changelog
-+* Fri Aug 28 2020 Peter Bieringer <pb@bieringer.de>
-+- fix spec file according to BZ#1873302
-+
-+* Sat Oct 5 2019 Peter Bieringer <pb@bieringer.de> - 8.0.9-5
-+- update version to 8.0.9
-+
- * Sun Feb 26 2017 Peter Bieringer <pb@bieringer.de> - 8.0.4-5
- - update to 8.0.4
- - add some fixes related to move to github
-diff --git a/contrib/IP2Location.spec.in b/contrib/IP2Location.spec.in
-index b544e8a..be95898 100644
---- a/contrib/IP2Location.spec.in
-+++ b/contrib/IP2Location.spec.in
-@@ -3,12 +3,10 @@
- Name: IP2Location
- Summary: C library for mapping IP address to geolocation information
- Version: %{version}
--Release: 5%{?dist}
--Group: System Environment/Libraries
-+Release: 6%{?dist}
- License: MIT
- URL: http://www.ip2location.com/
--Source0: https://github.com/chrislim2888/IP2Location-C-Library/archive/%{version}.tar.gz
--BuildRoot: %{_tmppath}/%{name}-%{version}-%{release}-root-%(%{__id_u} -n)
-+Source0: https://github.com/chrislim2888/IP2Location-C-Library/archive/%{version}/%{name}-%{version}.tar.gz
- BuildRequires: libtool
-
-
-@@ -26,7 +24,6 @@ the included downloader.
-
- %package devel
- Summary: Static library and header files for the ip2location library
--Group: Development/C
- Requires: %{name} = %{version}-%{release}
- Provides: %{name}-devel = %{version}-%{release}
-
-@@ -51,63 +48,60 @@ perl -pi -e 's/-Wno-unused-result//' configure.ac
-
- %build
- sh ./bootstrap
--autoreconf -fi
-+autoreconf -fiv
-
- %configure --disable-static
--make clean
--make %{?_smp_mflags} COPTS="$RPM_OPT_FLAGS"
-+%make_build COPTS="$RPM_OPT_FLAGS"
-
- # convert CSV to BIN
- make -C data convert
-
-+
- %check
- LD_LIBRARY_PATH=%{buildroot}%{_libdir}:$LD_LIBRARY_PATH make check
-
-
- %install
--rm -rf %{buildroot}
--
--make install DESTDIR=%{buildroot}
-+%make_install
-
- # cleanup
- rm -f %{buildroot}%{_libdir}/*.*a
-
- # tools
- install -d %{buildroot}%{_datadir}/%{name}/tools
--cp tools/download.pl %{buildroot}%{_datadir}/%{name}/tools
-+install -pm 0755 tools/download.pl %{buildroot}%{_datadir}/%{name}/tools
-
- # database directory
- install -d %{buildroot}%{_datadir}/%{name}/
-
-
--%post -p /sbin/ldconfig
--
--%postun -p /sbin/ldconfig
--
--
--%clean
--rm -rf %{buildroot}
--
- %files
--%defattr(644,root,root,755)
-+%license COPYING LICENSE.TXT
-
--%doc AUTHORS ChangeLog COPYING README.md LICENSE.TXT NEWS INSTALL LICENSE.TXT
-+%doc AUTHORS ChangeLog README.md NEWS
-
--%attr(755,-,-) %{_libdir}/*.so*
-+%{_libdir}/libIP2Location.so.1
-+%{_libdir}/libIP2Location.so.1.0.0
-
--%attr(755,-,-) %{_datadir}/%{name}/tools/*
-+%{_datadir}/%{name}/tools/
-
- %dir %{_datadir}/%{name}/
-
-
- %files devel
--%defattr(-,root,root)
--%{_includedir}/*
-+%{_includedir}/IP2Loc*.h
-+%{_libdir}/libIP2Location.so
-
- %doc Developers_Guide.txt
-
-
- %changelog
-+* Fri Aug 28 2020 Peter Bieringer <pb@bieringer.de>
-+- fix spec file according to BZ#1873302
-+
-+* Sat Oct 5 2019 Peter Bieringer <pb@bieringer.de> - 8.0.9-5
-+- update version to 8.0.9
-+
- * Sun Feb 26 2017 Peter Bieringer <pb@bieringer.de> - 8.0.4-5
- - update to 8.0.4
- - add some fixes related to move to github
-diff --git a/libIP2Location/IP2Loc_DBInterface.c b/libIP2Location/IP2Loc_DBInterface.c
-index 647ea69..2130e99 100644
---- a/libIP2Location/IP2Loc_DBInterface.c
-+++ b/libIP2Location/IP2Loc_DBInterface.c
-@@ -271,9 +271,13 @@ uint32_t IP2Location_read32(FILE *handle, uint32_t position)
- {
- fseek(handle, position-1, 0);
- temp = fread(&byte1, 1, 1, handle);
-+ if (temp == 0) { return 0; };
- temp = fread(&byte2, 1, 1, handle);
-+ if (temp == 0) { return 0; };
- temp = fread(&byte3, 1, 1, handle);
-+ if (temp == 0) { return 0; };
- temp = fread(&byte4, 1, 1, handle);
-+ if (temp == 0) { return 0; };
- }
- else
- {
-@@ -295,6 +299,7 @@ uint8_t IP2Location_read8(FILE *handle, uint32_t position)
- {
- fseek(handle, position-1, 0);
- temp = fread(&ret, 1, 1, handle);
-+ if (temp == 0) { return 0; };
- }
- else
- {
-@@ -309,13 +314,16 @@ char *IP2Location_readStr(FILE *handle, uint32_t position)
- char *str = 0;
- uint8_t *cache_shm = cache_shm_ptr;
- size_t temp;
-+
- if (DB_access_type == IP2LOCATION_FILE_IO && handle != NULL)
- {
- fseek(handle, position, 0);
- temp = fread(&size, 1, 1, handle);
-+ if (temp == 0) { return ""; };
- str = (char *)malloc(size+1);
- memset(str, 0, size+1);
- temp = fread(str, size, 1, handle);
-+ if (temp == 0) { return ""; };
- }
- else
- {
-@@ -341,9 +349,13 @@ float IP2Location_readFloat(FILE *handle, uint32_t position)
- {
- fseek(handle, position-1, 0);
- temp = fread(p+3, 1, 1, handle);
-+ if (temp == 0) { return 0.0; };
- temp = fread(p+2, 1, 1, handle);
-+ if (temp == 0) { return 0.0; };
- temp = fread(p+1, 1, 1, handle);
-+ if (temp == 0) { return 0.0; };
- temp = fread(p, 1, 1, handle);
-+ if (temp == 0) { return 0.0; };
- }
- else
- {
-@@ -357,6 +369,7 @@ float IP2Location_readFloat(FILE *handle, uint32_t position)
- {
- fseek(handle, position-1, 0);
- temp = fread(&ret, 4, 1, handle);
-+ if (temp == 0) { return 0.0; };
- }
- else
- {
-@@ -365,5 +378,3 @@ float IP2Location_readFloat(FILE *handle, uint32_t position)
- #endif
- return ret;
- }
--
--
-diff --git a/libIP2Location/IP2Location.c b/libIP2Location/IP2Location.c
-index fbe7fe0..a036580 100644
---- a/libIP2Location/IP2Location.c
-+++ b/libIP2Location/IP2Location.c
-@@ -61,7 +61,6 @@ uint8_t USAGETYPE_POSITION[25] = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- static int IP2Location_initialize(IP2Location *loc);
- static IP2LocationRecord *IP2Location_new_record();
- static uint32_t IP2Location_ip2no(char* ip);
--static struct in6_addr_local IP2Location_ipv6_to_no(char* ipaddr);
- static int IP2Location_ip_is_ipv4 (char* ipaddr);
- static int IP2Location_ip_is_ipv6 (char* ipaddr);
- static IP2LocationRecord *IP2Location_get_record(IP2Location *loc, char *ip, uint32_t mode);
-@@ -151,8 +150,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 +380,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 +473,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 +649,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 +759,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 +784,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
---- a/libIP2Location/IP2Location.h
-+++ b/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
-diff --git a/test/test-IP2Location.c b/test/test-IP2Location.c
-index f48eb3f..9ad08a2 100644
---- a/test/test-IP2Location.c
-+++ b/test/test-IP2Location.c
-@@ -38,7 +38,10 @@ int main () {
- f = fopen("country_test_ipv4_data.txt","r");
-
- while (fscanf(f, "%s", ipAddress) != EOF) {
-- fscanf(f, "%s", expectedCountry);
-+ if (fscanf(f, "%s", expectedCountry) == EOF) {
-+ printf("Unexpected EOF, input file broken: country_test_ipv6_data.txt\n");
-+ return -1;
-+ };
- record = IP2Location_get_all(IP2LocationObj, ipAddress);
- if (record != NULL) {
- if (strcmp(expectedCountry,record->country_short) != 0) {
-@@ -86,7 +89,10 @@ int main () {
- f = fopen("country_test_ipv6_data.txt","r");
-
- while (fscanf(f, "%s", ipAddress) != EOF) {
-- fscanf(f, "%s", expectedCountry);
-+ if (fscanf(f, "%s", expectedCountry) == EOF) {
-+ printf("Unexpected EOF, input file broken: country_test_ipv6_data.txt\n");
-+ return -1;
-+ };
- record = IP2Location_get_all(IP2LocationObj, ipAddress);
- if (strcmp(expectedCountry,record->country_short) != 0) {
- fprintf(stdout,"Test IP Address %s (Test %d) failed. We got %s but expected %s,\n",ipAddress,test_num,record->country_short,expectedCountry);