Package: geoip-bin
Version: 1.6.2-4
Severity: normal
Tags: patch
Dear Maintainer,
I noticed that some ASN looks mangled (first and last character cut off,
e.g. `geopiplookup 163.172.217.0|tail -1` -> 'GeoIP ASNum Edition:
S1287' [it should've been 'GeoIP ASNum Edition: AS12876'])
and discovered that geoip-generator-asn misparses unquoted CSV fields.
This bug also affects geoip-database-extra in jessie-backports (and
likely jessie too).
Patch attached (note: I only made minimal effort to make things work,
this "CSV parser" is still incomplete and fails to handle full CSV syntax).
P.S. ASN/v6 change in patch is completely untested (it seems produces
mangled database [as before]).
-- System Information:
Debian Release: 8.6
APT prefers stable-updates
APT policy: (500, 'stable-updates'), (500, 'stable'), (100,
'proposed-updates')
Architecture: i386 (x86_64)
Foreign Architectures: amd64
Kernel: Linux 3.16.0-4-amd64 (SMP w/2 CPU cores)
Locale: LANG=ru_RU.KOI8-R, LC_CTYPE=ru_RU.KOI8-R (charmap=KOI8-R)
Shell: /bin/sh linked to /bin/dash
Init: systemd (via /run/systemd/system)
Versions of packages geoip-bin depends on:
ii libc6 2.19-18+deb8u6
ii libgcc1 1:4.9.2-10
ii libgeoip1 1.6.2-4
ii libstdc++6 4.9.2-10
geoip-bin recommends no packages.
geoip-bin suggests no packages.
-- no debconf information
--- geoip_1.6.7-2~bpo8+1/debian/src/geoip-asn-csv-to-dat.cpp.orig 2016-10-12 12:17:11.000000000 +0300
+++ geoip_1.6.7-2~bpo8+1/debian/src/geoip-asn-csv-to-dat.cpp 2016-10-12 12:28:38.000000000 +0300
@@ -480,7 +480,10 @@
fields.push_back(buf.substr(0,fs));
buf.erase(0,fs + 1);
}
+ if (buf[0] == '"' || buf[0] == '\'')
fields.push_back(buf.substr(1, buf.length() - 2));
+ else
+ fields.push_back(buf);
}
void
@@ -489,13 +492,16 @@
std::vector<std::string> & fields)
{
std::string buf(line);
- std::string delim = ", ";
+ std::string delim = ",";
std::size_t fs;
for(int i = 0; i<3;++i) {
fs = buf.rfind(delim);
fields.push_back(buf.substr(fs+2, buf.length()));
buf.erase(fs,buf.length());
}
+ if (buf[0] == '"' || buf[0] == '\'')
+ fields.push_back(buf.substr(1, buf.length() - 2));
+ else
fields.push_back(buf.substr(0, buf.length()));
}