[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Bug#776404: unblock: geoip/1.6.2-4



Package: release.debian.org
Severity: normal
User: release.debian.org@packages.debian.org
Usertags: unblock

Please unblock package geoip

It fixes the RC bug #775851


diff -Naur '--exclude=.svn' 1.6.2-3/debian/changelog 1.6.2-4/debian/changelog
--- 1.6.2-3/debian/changelog    2015-01-05 10:19:53.916837259 +0100
+++ 1.6.2-4/debian/changelog    2015-01-27 12:25:28.416240069 +0100
@@ -1,3 +1,10 @@
+geoip (1.6.2-4) unstable; urgency=high
+
+  * Fix for generating v6 and city database.
+    Closes: #775851
+
+ -- Patrick Matthäi <pmatthaei@debian.org>  Tue, 27 Jan 2015 12:20:30 +0100
+
 geoip (1.6.2-3) unstable; urgency=low
 
   * geoip-generator: Add support for skipping locations if the location ID is
diff -Naur '--exclude=.svn' 1.6.2-3/debian/src/geoip-csv-to-dat.cpp 1.6.2-4/debian/src/geoip-csv-to-dat.cpp
--- 1.6.2-3/debian/src/geoip-csv-to-dat.cpp     2015-01-05 10:19:53.920837251 +0100
+++ 1.6.2-4/debian/src/geoip-csv-to-dat.cpp     2015-01-27 12:25:28.440240068 +0100
@@ -705,8 +705,18 @@
                // location info's out of order).
                std::vector<int> location_pos;
 
+               // Set of location IDs that are actually going to be used;
+               // we'll silently ignore any locations not in this set.
+               std::set<int> needed_locations;
+         
                city_dat_writer(const char *dat_file_name, GeoIPDBTypes database_type);
 
+               // Notify of a location ID we need -- this MUST be
+               // called for every location ID you care about before
+               // the location CSV is read; any ID not explicitly
+               // notified will be discarded.
+               void notify_need_location(int loc_id);
+
                void serialize_location_info(std::vector<std::string> &info,
                                             const char *input_file_name,
                                             int input_line_number);
@@ -722,6 +732,11 @@
        : dat_writer(dat_file_name, database_type)
 { }
 
+void city_dat_writer::notify_need_location(int loc_id)
+{
+       needed_locations.insert(loc_id);
+}
+
 void city_dat_writer::finalize_location_offsets(binary_trie &trie)
 {
        // We're going to convert the location numbers in the trie
@@ -751,7 +766,11 @@
                        int loc_id = it->edges[0] - 0x1000000;
                        if (loc_id >= location_pos.size() || location_pos[loc_id] == -1)
                                error(EX_DATAERR, 1, "Location %d exists in blocks but not in locations", loc_id);
-                       it->edges[0] = location_pos[loc_id] + trie_size;
+
+                       int offset = location_pos[loc_id] + trie_size;
+                       if (offset > 0xFFFFFF)
+                               error(EX_DATAERR, 1, "Overflow! Offset for location %d too large (0x%x > 0xFFFFFF)", loc_id, offset);
+                       it->edges[0] = offset;
                }
                // Any other value would indicate a non-leaf node
 
@@ -761,7 +780,11 @@
                        int loc_id = it->edges[1] - 0x1000000;
                        if (loc_id >= location_pos.size() || location_pos[loc_id] == -1)
                                error(EX_DATAERR, 1, "Location %d exists in blocks but not in locations", loc_id);
-                       it->edges[1] = location_pos[loc_id] + trie_size;
+
+                       int offset = location_pos[loc_id] + trie_size;
+                       if (offset > 0xFFFFFF)
+                               error(EX_DATAERR, 1, "Overflow! Offset for location %d too large (0x%x > 0xFFFFFF)", loc_id, offset);
+                       it->edges[1] = offset;
                }
                // Any other value would indicate a non-leaf node
        }
@@ -812,8 +835,16 @@
                                              const char *input_file_name,
                                              int input_line_number)
 {
-       // First, we save the offset of this location block.
+       // First, we determine the offset of this location block.
        int loc_id = ::atoi(info[0].c_str());
+
+       if (needed_locations.find(loc_id) == needed_locations.end()) {
+               // We don't need this location, so we skip serializing
+               // it altogether.
+
+               return;
+       }
+
        if (loc_id >= location_pos.size()) {
                // We need to add to the location table (this is the
                // usual case).
@@ -881,8 +912,8 @@
 
        // Area code and metro code
        if (info[1] == "US") {
-               int area_code = ::atoi(info[7].c_str());
-               int metro_code = ::atoi(info[8].c_str());
+               int metro_code = ::atoi(info[7].c_str());
+               int area_code = ::atoi(info[8].c_str());
                int area_metro_combined = metro_code * 1000 + area_code;
                location_stream.put((area_metro_combined >>  0) & 0xFF);
                location_stream.put((area_metro_combined >>  8) & 0xFF);
@@ -959,6 +990,7 @@
                        address_family = AF_INET;
                        break;
                case '6':
+                       database_type = GEOIP_COUNTRY_EDITION_V6;
                        address_family = AF_INET6;
                        break;
                case 'i':
@@ -1365,6 +1397,7 @@
                              "Invalid max IP address");
        }
 
+       writer.notify_need_location(loc_id);
        trie.set_range(minaddr.inetbytes, maxaddr.inetbytes, 32, leaf);
 }
 



unblock geoip/1.6.2-4

-- System Information:
Debian Release: 7.8
  APT prefers stable-updates
  APT policy: (500, 'stable-updates'), (500, 'stable')
Architecture: amd64 (x86_64)

Kernel: Linux 3.2.0-4-amd64 (SMP w/2 CPU cores)
Locale: LANG=de_DE.UTF-8, LC_CTYPE=de_DE.UTF-8 (charmap=UTF-8)
Shell: /bin/sh linked to /bin/dash


Reply to: