Opened 7 years ago
Closed 7 years ago
Last modified 7 years ago
#3608 closed defect (fixed)
Shp2pgsql invalid free when -W UTF-8
|Reported by:||Matt Amos||Owned by:||pramsey|
Shp2pgsql crashes with an invalid free when passed a
-W UTF-8 argument on the command line and the shapefile contains a code page. This is because shp2pgsql assumes that if the
encoding is the string
UTF-8 then the user has not overridden it. If the code page exists in the shapefile, the previous value of
encoding is freed and, if it came from a command line argument, it is not heap-allocated.
The patch in https://github.com/postgis/postgis/pull/111 prevents the crash by
strduping the command line argument, but doesn't address the wider issue of distinguishing a user-provided "UTF-8" from a default-supplied "UTF-8".
Change History (7)
comment:1 by , 7 years ago
|Milestone:||PostGIS 2.3.0 → PostGIS 2.2.3|
comment:2 by , 7 years ago
comment:3 by , 7 years ago
I actually see the default encoding being strdup'ed already, in shp2pgsql-core.c, line 756:
config->encoding = strdup(ENCODING_DEFAULT);
The crash you're seeing might have another cause ?
comment:4 by , 7 years ago
Figured: the issue of distinguishing a user-provided from a default-supplied is unrelated to the crash. So I will committed your patch and invite you to file another ticket for that separate issue (which for the record affects using or not the shapefile-provided CodePage, in shp2pgsql-core.c:870)
comment:5 by , 7 years ago
|Status:||new → closed|
comment:6 by , 7 years ago
comment:7 by , 7 years ago
Where's the assumption that "UTF-8" was not passed ? I'd rather remove that assumption by always strduping the default-supplied string.