<p><b>@gravitystorm</b> commented on this pull request.</p>

<hr>

<p>In <a href="https://github.com/openstreetmap/osm2pgsql/pull/956#discussion_r330474505">table.cpp</a>:</p>
<pre style='color:#555'>> @@ -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);
</pre>
<p>OK, anyone got any suggestions of what integer type we can use and what format string to pair it with? It needs to parse <em>more than 32 bits</em> so that we can constrain it with a digit specifier and still get the full 32 bit output.</p>
<p>So far we've tried</p>
<ul>
<li><code>int64_t</code> with <code>%18ld</code> (macosx didn't like this)</li>
<li><code>long long</code> with <code>%18Ld</code> (no L in C++11)</li>
</ul>

<p style="font-size:small;-webkit-text-size-adjust:none;color:#666;">—<br />You are receiving this because you are subscribed to this thread.<br />Reply to this email directly, <a href="https://github.com/openstreetmap/osm2pgsql/pull/956?email_source=notifications&email_token=AA6353XZX7VES3TLXYTLFILQMRY2PA5CNFSM4I3YC4KKYY3PNVWWK3TUL52HS4DFWFIHK3DMKJSXC5LFON2FEZLWNFSXPKTDN5WW2ZLOORPWSZGOCGTMRUA#discussion_r330474505">view it on GitHub</a>, or <a href="https://github.com/notifications/unsubscribe-auth/AA6353XL7QKZ4F5V7QP4T6DQMRY2PANCNFSM4I3YC4KA">mute the thread</a>.<img src="https://github.com/notifications/beacon/AA6353XRZXPX3MK6DM2WXN3QMRY2PA5CNFSM4I3YC4KKYY3PNVWWK3TUL52HS4DFWFIHK3DMKJSXC5LFON2FEZLWNFSXPKTDN5WW2ZLOORPWSZGOCGTMRUA.gif" height="1" width="1" alt="" /></p>
<script type="application/ld+json">[
{
"@context": "http://schema.org",
"@type": "EmailMessage",
"potentialAction": {
"@type": "ViewAction",
"target": "https://github.com/openstreetmap/osm2pgsql/pull/956?email_source=notifications\u0026email_token=AA6353XZX7VES3TLXYTLFILQMRY2PA5CNFSM4I3YC4KKYY3PNVWWK3TUL52HS4DFWFIHK3DMKJSXC5LFON2FEZLWNFSXPKTDN5WW2ZLOORPWSZGOCGTMRUA#discussion_r330474505",
"url": "https://github.com/openstreetmap/osm2pgsql/pull/956?email_source=notifications\u0026email_token=AA6353XZX7VES3TLXYTLFILQMRY2PA5CNFSM4I3YC4KKYY3PNVWWK3TUL52HS4DFWFIHK3DMKJSXC5LFON2FEZLWNFSXPKTDN5WW2ZLOORPWSZGOCGTMRUA#discussion_r330474505",
"name": "View Pull Request"
},
"description": "View this Pull Request on GitHub",
"publisher": {
"@type": "Organization",
"name": "GitHub",
"url": "https://github.com"
}
}
]</script>