[Tile-serving] [openstreetmap/osm2pgsql] Avoid crashing on out-of-range inputs for int4 columns (#956)

Sarah Hoffmann notifications at github.com
Wed Oct 2 15:42:41 UTC 2019


lonvia commented on this pull request.



> @@ -457,12 +457,21 @@ void table_t::escape_type(const string &value, ColumnType flags)
     switch (flags) {
     case COLUMN_TYPE_INT: {
         // For integers we take the first number, or the average if it's a-b
-        long from, to;
-        int items = sscanf(value.c_str(), "%ld-%ld", &from, &to);
-        if (items == 1) {
+        int64_t from, to;
+        // limit number of digits parsed to avoid undefined behaviour in sscanf
+        int items = sscanf(value.c_str(), "%18ld-%18ld", &from, &to);

The recommendation (in the BUG section of scanf. Who reads that far down? ;) ) is '%18lld' (and `long long`). Can you try that? If it doesn't work either, then we have to go the `strtol` route. I can help out in that case.

-- 
You are receiving this because you are subscribed to this thread.
Reply to this email directly or view it on GitHub:
https://github.com/openstreetmap/osm2pgsql/pull/956#discussion_r330626022
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.openstreetmap.org/pipermail/tile-serving/attachments/20191002/11bc5383/attachment.html>


More information about the Tile-serving mailing list