Opened 15 years ago

Closed 15 years ago

#2825 closed defect (invalid)

Buffer overflow detected in ogr2ogr (included in FWTools-2.0.6)

Reported by: jaume Owned by: chaitanya
Priority: normal Milestone:
Component: OGR_SF Version: unspecified
Severity: normal Keywords: mysql
Cc: warmerdam

Description

ogr2ogr -f "MySQL" MYSQL:"BD,host=localhost,user=USER,password=PASSWORD,port=3306" -a_srs "EPSG:23031" 66666 SHP_FILE.shp

Any idea?

Change History (19)

comment:1 by Even Rouault, 15 years ago

Could you provide SHP_FILE.shp or any (possibly small) dataset demonstrating the issue ? And/or give a few more hints on where the buffer overflow occurs, like a stack trace ?

in reply to:  1 comment:2 by jaume, 15 years ago

Replying to rouault:

Could you provide SHP_FILE.shp or any (possibly small) dataset demonstrating the issue ? And/or give a few more hints on where the buffer overflow occurs, like a stack trace ?

The file is about 1.4Mb. Is there any way to attach it?

Anyway tonight I'll add the stack trace

comment:3 by warmerdam, 15 years ago

Component: defaultOGR_SF

Jaume,

If you can stage it somewhere on a web server and provide the url that would do the trick. Alternatively, you can zip it and email it to me (warmerdam@…), and I'll stage it. We try to avoid attaching large files to tickets as it bogs down the OSGeo servers.

comment:4 by warmerdam, 15 years ago

Cc: warmerdam added
Owner: changed from warmerdam to chaitanya

Jaume has provided the data file and it is now available at:

http://home.gdal.org/tmp/bug2825.zip

I'm turning this over to Chaitanya to reproduce and resolve. It may be useful to run things under valgrind while trying to reproduce the problem on linux.

comment:5 by jaume, 15 years ago

Error trace

ogr2ogr -f "MySQL" MYSQL:"geo,host=localhost,user=XXXXXXX,password=XXXXXXXX,port=3306" -a_srs "EPSG:23031" ../../Documents/gvsig/Municipis.shp

* buffer overflow detected *: ogr2ogr terminated ======= Backtrace: ========= /lib/tls/i686/cmov/libc.so.6(fortify_fail+0x48)[0xb7805548] /lib/tls/i686/cmov/libc.so.6[0xb7803670] /lib/tls/i686/cmov/libc.so.6[0xb7802f77] /lib/tls/i686/cmov/libc.so.6(snprintf_chk+0x34)[0xb7802e64] /usr/lib/libgdal1.5.0.so.1(_ZN10OGRFeature16GetFieldAsStringEi+0x36f)[0xb7d5f4ff] /usr/lib/libgdal1.5.0.so.1(_ZN18OGRMySQLTableLayer13CreateFeatureEP10OGRFeature+0x4e7)[0xb7cfc557] ogr2ogr[0x8049720] ogr2ogr[0x804a129] /lib/tls/i686/cmov/libc.so.6(libc_start_main+0xe5)[0xb7721685] ogr2ogr(gxx_personality_v0+0x1c9)[0x8049221] ======= Memory map: ======== 08048000-0804c000 r-xp 00000000 08:01 3188481 /usr/bin/ogr2ogr 0804c000-0804d000 r--p 00003000 08:01 3188481 /usr/bin/ogr2ogr 0804d000-0804e000 rw-p 00004000 08:01 3188481 /usr/bin/ogr2ogr 09e9e000-09eff000 rw-p 09e9e000 00:00 0 [heap] b5a04000-b5a78000 rw-p b5a04000 00:00 0 b5a78000-b5a7b000 r-xp 00000000 08:01 917570 /lib/libgpg-error.so.0.3.0 b5a7b000-b5a7c000 rw-p 00002000 08:01 917570 /lib/libgpg-error.so.0.3.0 b5a7c000-b5a7d000 rw-p b5a7c000 00:00 0 b5a7d000-b5a93000 r-xp 00000000 08:01 3189087 /usr/lib/libsasl2.so.2.0.22 b5a93000-b5a94000 r--p 00015000 08:01 3189087 /usr/lib/libsasl2.so.2.0.22 b5a94000-b5a95000 rw-p 00016000 08:01 3189087 /usr/lib/libsasl2.so.2.0.22 b5a95000-b5aa1000 r-xp 00000000 08:01 3186808 /usr/lib/liblber-2.4.so.2.1.0 b5aa1000-b5aa2000 r--p 0000b000 08:01 3186808 /usr/lib/liblber-2.4.so.2.1.0 b5aa2000-b5aa3000 rw-p 0000c000 08:01 3186808 /usr/lib/liblber-2.4.so.2.1.0 b5aa3000-b5ab3000 r-xp 00000000 08:01 934296 /lib/tls/i686/cmov/libresolv-2.8.90.so b5ab3000-b5ab4000 r--p 0000f000 08:01 934296 /lib/tls/i686/cmov/libresolv-2.8.90.so b5ab4000-b5ab5000 rw-p 00010000 08:01 934296 /lib/tls/i686/cmov/libresolv-2.8.90.so b5ab5000-b5ab7000 rw-p b5ab5000 00:00 0 b5ab7000-b5ab9000 r-xp 00000000 08:01 917575 /lib/libkeyutils-1.2.so b5ab9000-b5abb000 rw-p 00001000 08:01 917575 /lib/libkeyutils-1.2.so b5abb000-b5ac2000 r-xp 00000000 08:01 3188867 /usr/lib/libkrb5support.so.0.1 b5ac2000-b5ac3000 r--p 00006000 08:01 3188867 /usr/lib/libkrb5support.so.0.1 b5ac3000-b5ac4000 rw-p 00007000 08:01 3188867 /usr/lib/libkrb5support.so.0.1 b5ac4000-b5ac5000 rw-p b5ac4000 00:00 0 b5ac5000-b5ada000 r-xp 00000000 08:01 934287 /lib/tls/i686/cmov/libnsl-2.8.90.so b5ada000-b5adb000 r--p 00014000 08:01 934287 /lib/tls/i686/cmov/libnsl-2.8.90.so b5adb000-b5adc000 rw-p 00015000 08:01 934287 /lib/tls/i686/cmov/libnsl-2.8.90.so b5adc000-b5ade000 rw-p b5adc000 00:00 0 b5ade000-b5b44000 r-xp 00000000 08:01 917568 /lib/libgcrypt.so.11.4.4 b5b44000-b5b45000 r--p 00065000 08:01 917568 /lib/libgcrypt.so.11.4.4 b5b45000-b5b47000 rw-p 00066000 08:01 917568 /lib/libgcrypt.so.11.4.4 b5b47000-b5b57000 r-xp 00000000 08:01 3189147 /usr/lib/libtasn1.so.3.0.15 b5b57000-b5b59000 rw-p 0000f000 08:01 3189147 /usr/lib/libtasn1.so.3.0.15 b5b59000-b5bf0000 r-xp 00000000 08:01 3186827 /usr/lib/libgnutls.so.26.4.5 b5bf0000-b5bf5000 r--p 00096000 08:01 3186827 /usr/lib/libgnutls.so.26.4.5 b5bf5000-b5bf6000 rw-p 0009b000 08:01 3186827 /usr/lib/libgnutls.so.26.4.5 b5bf6000-b5c18000 r-xp 00000000 08:01 3188859 /usr/lib/libk5crypto.so.3.1 b5c18000-b5c19000 r--p 00022000 08:01 3188859 /usr/lib/libk5crypto.so.3.1 b5c19000-b5c1a000 rw-p 00023000 08:01 3188859 /usr/lib/libk5crypto.so.3.1 b5c1a000-b5c1b000 rw-p b5c1a000 00:00 0 b5c1b000-b5c4b000 r-xp 00000000 08:01 3188841 /usr/lib/libidn.so.11.5.37 b5c4b000-b5c4c000 r--p 00030000 08:01 3188841 /usr/lib/libidn.so.11.5.37 b5c4c000-b5c4d000 rw-p 00031000 08:01 3188841 /usr/lib/libidn.so.11.5.37 b5c4d000-b5c8c000 r-xp 00000000 08:01 3187058 /usr/lib/libldap_r-2.4.so.2.1.0 b5c8c000-b5c8d000 r--p 0003e000 08:01 3187058 /usr/lib/libldap_r-2.4.so.2.1.0 b5c8d000-b5c8e000 rw-p 0003f000 08:01 3187058 /usr/lib/libldap_r-2.4.so.2.1.0 b5c8e000-b5c8f000 rw-p b5c8e000 00:00 0 b5c8f000-b5c98000 r-xp 00000000 08:01 934283 /lib/tls/i686/cmov/libcrypt-2.8.90.so b5c98000-b5c99000 r--p 00008000 08:01 934283 /lib/tls/i686/cmov/libcrypt-2.8.90.so b5c99000-b5c9a000 rw-p 00009000 08:01 934283 /lib/tls/i686/cmov/libcrypt-2.8.90.so b5c9a000-b5cc1000 rw-p b5c9a000 00:00 0 b5cc1000-b5ce9000 r-xp 00000000 08:01 3188722 /usr/lib/libgssapi_krb5.so.2.2 b5ce9000-b5cea000 r--p 00028000 08:01 3188722 /usr/lib/libgssapi_krb5.so.2.2 b5cea000-b5ceb000 rw-p 00029000 08:01 3188722 /usr/lib/libgssapi_krb5.so.2.2 b5ceb000-b5ced000 r-xp 00000000 08:01 917552 /lib/libcom_err.so.2.1 b5ced000-b5cee000 r--p 00001000 08:01 917552 /lib/libcom_err.so.2.1 b5cee000-b5cef000 rw-p 00002000 08:01 917552 /lib/libcom_err.so.2.1 b5cef000-b5cf0000 rw-p b5cef000 00:00 0 b5cf0000-b5d7f000 r-xp 00000000 08:01 3188865 /usr/lib/libkrb5.so.3.3 b5d7f000-b5d81000 r--p 0008e000 08:01 3188865 /usr/lib/libkrb5.so.3.3 b5d81000-b5d82000 rw-p 00090000 08:01 3188865 /usr/lib/libkrb5.so.3.3 b5d82000-b5eb4000 r-xp 00000000 08:01 7806977 /usr/lib/i686/cmov/libcrypto.so.0.9.8 b5eb4000-b5eb5000 ---p 00132000 08:01 7806977 /usr/lib/i686/cmov/libcrypto.so.0.9.8 b5eb5000-b5ebd000 r--p 00132000 08:01 7806977 /usr/lib/i686/cmov/libcrypto.so.0.9.8 b5ebd000-b5eca000 rw-p 0013a000 08:01 7806977 /usr/lib/i686/cmov/libcrypto.so.0.9.8 b5eca000-b5ece000 rw-p b5eca000 00:00 0 b5ece000-b5f10000 r-xp 00000000 08:01 7806978 /usr/lib/i686/cmov/libssl.so.0.9.8 b5f10000-b5f11000 r--p 00041000 08:01 7806978 /usr/lib/i686/cmov/libssl.so.0.9.8 b5f11000-b5f14000 rw-p 00042000 08:01 7806978 /usr/lib/i686/cmov/libssl.so.0.9.8 b5f14000-b5f44000 r-xp 00000000 08:01 3188174 /usr/lib/libproj.so.0.5.4 b5f44000-b5f46000 rw-p 0002f000 08:01 3188174 /usr/lib/libproj.so.0.5.4 b5f46000-b6a1c000 r--p 00000000 08:01 3188826 /usr/lib/libicudata.so.38.1 b6a1c000-b6a1d000 r--p 00ad5000 08:01 3188826 /usr/lib/libicudata.so.38.1 b6a1d000-b6a1e000 rw-p b6a1d000 00:00 0 b6a1e000-b6b3b000 r-xp 00000000 08:01 3188838 /usr/lib/libicuuc.so.38.1 b6b3b000-b6b43000 r--p 0011d000 08:01 3188838 /usr/lib/libicuuc.so.38.1 b6b43000-b6b44000 rw-p 00125000 08:01 3188838 /usr/lib/libicuuc.so.38.1 b6b44000-b6b46000 rw-p b6b44000 00:00 0 b6b46000-b6b4d000 r-xp 00000000 08:01 3188887 /usr/lib/libltdl.so.7.1.2 b6b4d000-b6b4e000 r--p 00006000 08:01 3188887 /usr/lib/libltdl.so.7.1.2 b6b4e000-b6b4f000 rw-p 00007000 08:01 3188887 /usr/lib/libltdl.so.7.1.2 b6b4f000-b6c75000 r-xp 00000000 08:01 3186943 /usr/lib/libgeos-3.0.0.so b6c75000-b6c79000 rw-p 00125000 08:01 3186943 /usr/lib/libgeos-3.0.0.so b6c79000-b6e17000 r-xp 00000000 08:01 3189624 /usr/lib/libmysqlclient.so.15.0.0 b6e17000-b6e18000 ---p 0019e000 08:01 3189624 /usr/lib/libmysqlclient.so.15.0.0 b6e18000-b6e1b000 r--p 0019e000 08:01 3189624 /usr/lib/libmysqlclient.so.15.0.0 b6e1b000-b6e5b000 rw-p 001a1000 08:01 3189624 /usr/lib/libmysqlclient.so.15.0.0 b6e5b000-b6e5c000 rw-p b6e5b000 00:00 0 b6e5c000-b6e95000 r-xp 00000000 08:01 3188455 /usr/lib/libcurl-gnutls.so.4.1.0 b6e95000-b6e96000 r--p 00038000 08:01 3188455 /usr/lib/libcurl-gnutls.so.4.1.0 b6e96000-b6e97000 rw-p 00039000 08:01 3188455 /usr/lib/libcurl-gnutls.so.4.1.0 b6e97000-b6e98000 rw-p b6e97000 00:00 0 b6e98000-b6e9a000 r-xp 00000000 08:01 934284 /lib/tls/i686/cmov/libdl-2.8.90.so b6e9a000-b6e9b000 r--p 00001000 08:01 934284 /lib/tls/i686/cmov/libdl-2.8.90.so b6e9b000-b6e9c000 rw-p 00002000 08:01 934284 /lib/tls/i686/cmov/libdl-2.8.90.so b6e9c000-b6ea3000 r-xp 00000000 08:01 934297 /lib/tls/i686/cmov/librt-2.8.90.so b6ea3000-b6ea4000 r--p 00007000 08:01 934297 /lib/tls/i686/cmov/librt-2.8.90.so b6ea4000-b6ea5000 rw-p 00008000 08:01 934297 /lib/tls/i686/cmov/librt-2.8.90.so b6ea5000-b6eba000 r-xp 00000000 08:01 934295 /lib/tls/i686/cmov/libpthread-2.8.90.so b6eba000-b6ebb000 r--p 00014000 08:01 934295 /lib/tls/i686/cmov/libpthread-2.8.90.so b6ebb000-b6ebc000 rw-p 00015000 08:01 934295 /lib/tls/i686/cmov/libpthread-2.8.90.so b6ebc000-b6ebe000 rw-p b6ebc000 00:00 0 b6ebe000-b6ed2000 r-xp 00000000 08:01 3189235 /usr/lib/libz.so.1.2.3.3 b6ed2000-b6ed4000 rw-p 00013000 08:01 3189235 /usr/lib/libz.so.1.2.3.3 b6ed4000-b6ef3000 r-xp 00000000 08:01 3189704 /usr/lib/libpq.so.5.1 b6ef3000-b6ef4000 r--p 0001e000 08:01 3189704 /usr/lib/libpq.so.5.1 b6ef4000-b6ef5000 rw-p 0001f000 08:01 3189704 /usr/lib/libpq.so.5.1 b6ef5000-b6f24000 r-xp 00000000 08:01 3188169 /usr/lib/libnetcdf.so.4.0.0 b6f24000-b6f25000 rw-p 0002e000 08:01 3188169 /usr/lib/libnetcdf.so.4.0.0 b6f25000-b6f27000 rw-p b6f25000 00:00 0 b6f27000-b6f4b000 r-xp 00000000 08:01 3189023 /usr/lib/libpng12.so.0.27.0 b6f4b000Aborted

comment:6 by warmerdam, 15 years ago

Keywords: mysql added

From the dump log above it looks like the issue is with the mysql driver. I'd note that FWTools 2.0.6 for linux is fairly old now (roughly spring 2008?) so one thing we need to determine is if it still happens with the current version - but it would likely be good to start by reproducing the problem with the acttual FWTools 2.0.6 binaries (see http://fwtools.maptools.org).

comment:7 by chaitanya, 15 years ago

I couldn't reproduce the error with FWTools2.2.8 on Windows except for some character encoding issues which were resolved by converting the data to utf8. Everything went smoothly. I was also able to extract the data from the MySQL DB to other formats. I am going to try 2.0.6

comment:8 by chaitanya, 15 years ago

Status: newassigned

comment:9 by chaitanya, 15 years ago

I just checked FWTools2.0.6 on Windows. It worked with the given data.

comment:10 by Even Rouault, 15 years ago

Jaume,

In the stack trace, I can see a mention to /usr/lib/libgdal1.5.0.so.1. The location of the file is unusual for a FWTools installation and... FWTools 2.0.6 actually contains libgdal.so.1.6.0, not libgdal1.5.0.so.1.

My guess is that you don't source properly the ./fwtools_env.sh script and that you end up running the binaries from FWTools with another older install of GDAL in your system directories. And/or maybe it's just a bug in that older version. You should probably clean up your previous install and try again with FWTools. If that still doesn't work, you should consider upgrading to the latest stable version : 1.6.0

comment:11 by jaume, 15 years ago

Hi,

I'm new in linux and it's possible that I have a wrong installation. I'll follow for your advices the next weekend

Regards

comment:12 by jaume, 15 years ago

Hi,

I had installed gdal_bin 1.5 .2-2 and libgdal 1-1.5.0. I uninstalled them and reinstalled FWTools (I just do ./install.sh from FWtools folder). Now, when I execute

ogr2ogr -f "MySQL" MYSQL:"geo,host=localhost,user=XXXXXX,password=XXXXXX,port=3306" -a_srs "EPSG:23031" ../Documents/gvsig/Municipis.shp ERROR 1: MySQL connect failed for: geo,host=localhost,user=XXXXXX,password=XXXXXX,port=3306 Can't connect to local MySQL server through socket '/tmp/mysql.sock' (2) ERROR 1: MySQL driver doesn't currently support database creation. Please create database before using. MySQL driver failed to create MYSQL:geo,host=localhost,user=XXXXXX,password=XXXXXX,port=3306

Loking in my Mysql administrator - Server information I found Socket: /var/run/mysqld/mysqld.sock I copied the file in the /tmp/ and renamed it to mysql.sock. The error message is the sameone with a distinct code¿? number Can't connect to local MySQL server through socket '/tmp/mysql.sock' (111) look than before was (2)

Of course than geo database exists.

If there's no idea about what could happen I'll look for a windows computer :-(

Thank's a lot

Jaume

comment:13 by Even Rouault, 15 years ago

Jaume,

I experience the same error with the MySQL driver when using FWTools-2.0.6 on my Ubuntu 8.04. But it works fine with GDAL 1.6.0. I think that the MySQL client library included in FWTools-2.0.6 is too old to work with a recent version of MySQL server. So, I'd advise you to build GDAL 1.6.0 from source or find some pre-packaged version and stick with it.

comment:14 by jaume, 15 years ago

Hi again,

sorry for the delay. I've installed gdal 1.6.0 (I guess that correctly) Now when I execute the call the error message is

Unable to find driver `MySQL'. The following drivers are available:

-> `ESRI Shapefile'

....

It seems that gdal 1.6.0 not comes with support for Mysql or is not installed. Is that possible? How can I install Mysql driver?

Thank's again

Jaume

comment:15 by chaitanya, 15 years ago

Dear Jaume,

The driver names are case sensitive. Use MYSQL:"dbname[,options]" instead of MySQL:"dbname[,options]"

comment:16 by warmerdam, 15 years ago

I am not aware of the MYSQL: prefix for connection strings being case sensitive, nor is the identification of a driver with the -f switch. If you find this not to be accurate, lets look into it as it ought to be fixed. OGR and GDAL attempt to be case insensitive except where there is a specific reason to be case sensitive.

comment:17 by Even Rouault, 15 years ago

Jaume,

if you build GDAL yourself from source, you must specify --with-mysql=yes as an option of the ./configure command line, and make sure that the mysql development package is installed (on my Ubuntu 8.04, this package is called libmysqlclient15-dev).

comment:18 by jaume, 15 years ago

Great!

Now all works fine. Thank's for your support

Summarizing:

Ubuntu 8.10 comes with with GDAL 1.5 and the README for FWTools-2.0.6 says

"GDAL - 1.5.0 (trunk). Includes support (above base formats) for

RPF via OGDI, FITS, JPEG2000, DODS, netCDF, HDF, ECW, MrSID, GRI "

It seems that not (or fails) for mysql, and we need GDAL 1.6.0

First test that libmysqlclient15-dev is installed (I went to Synaptic and it not was). After installed

Install GDAL 1.6.0

cd /usr/local/lib (my folder)

sudo wget http://download.osgeo.org/gdal/gdal-1.6.0.tar.gz

sudo tar xzf gdal-1.6.0.tar.gz

cd gdal-1.6.0

sudo ./configure --with-mysql=yes

sudo make

sudo make install

That's all. Now you can use ogr2ogr -f "MySQL" MYSQL:....

comment:19 by Even Rouault, 15 years ago

Resolution: invalid
Status: assignedclosed

Cool. Closing.

Note: See TracTickets for help on using tickets.