Opened 12 years ago

Last modified 12 years ago

#1512 closed defect (fixed)

osr.ImportFromESRI() method crashes on valid input

Reported by: dron Owned by: hobu
Priority: highest Milestone:
Component: PythonBindings Version: unspecified
Severity: critical Keywords:


In order to reproduce this bug just start a Python interpreter:

>>> from osr import *
>>> o = SpatialReference()
>>> o.ImportFromESRI("""GEOGCS["GCS_North_American_1927",DATUM["D_North_American_1927",SPHEROID["Clarke_1866",6378206.4,294.9786982]],PRIMEM["Greenwich",0],UNIT["Degree",0.017453292519943295]]""")

Program received signal SIGSEGV, Segmentation fault.
[Switching to Thread -1210104128 (LWP 8544)]
0xb78feca8 in OGRSpatialReference::importFromESRI (this=0x81d4bb0, 
    papszPrj=0xbf9f12e4) at ogr_srs_esri.cpp:612
612                     CPLRealloc(pszWKT,strlen(pszWKT)+strlen(papszPrj[i])+1);
Current language:  auto; currently c++
(gdb) bt
#0  0xb78feca8 in OGRSpatialReference::importFromESRI (this=0x81d4bb0, 
    papszPrj=0xbf9f12e4) at ogr_srs_esri.cpp:612
#1  0xb78ffbc2 in OSRImportFromESRI (hSRS=0x81d4bb0, papszPrj=0xbf9f12e4)
    at ogr_srs_esri.cpp:431
#2  0xb7ad00b4 in _wrap_SpatialReference_ImportFromESRI (args=0xb7d7cfec)
    at osr_wrap.cpp:3098
#3  0x080589d7 in PyObject_Call ()
#4  0x080b7e1c in PyEval_EvalFrame ()
#5  0x080ba735 in PyEval_EvalCodeEx ()
#6  0x080b87bb in PyEval_EvalFrame ()
#7  0x080ba735 in PyEval_EvalCodeEx ()
#8  0x080ba799 in PyEval_EvalCode ()
#9  0x080dc985 in PyRun_InteractiveOneFlags ()
#10 0x080dcaa0 in PyRun_InteractiveLoopFlags ()
#11 0x080dd5a2 in PyRun_AnyFileExFlags ()
#12 0x08055ba8 in Py_Main ()
#13 0x08055032 in main ()
(gdb) p i
$3 = 3
(gdb) p papszPrj[i]
$4 = 0x2 <Address 0x2 out of bounds>

I am understand that input for osr.ImportFromESRI() fucntion should be a list, not a string, but we should get an exception instead of crash. I do not undestand in deep the NG bindings, so I am prefer to fill report instead of digging into the problem myself.

Best regards,

Change History (2)

comment:1 Changed 12 years ago by dron

More info on this bug. If we do:

>>> o.ImportFromESRI(['PROJCS["PS Test",GEOGCS["GCS_WGS_1984",DATUM["D_WGS_1984",SPHEROID["WGS_1984",6378137,298.2572235629972]],PRIMEM["Greenwich",0],UNIT["Degree",0.017453292519943295]],PROJECTION["Stereographic_South_Pole"],PARAMETER["standard_parallel_1",-80.2333],PARAMETER["central_meridian",171],PARAMETER["scale_factor",0.9999],PARAMETER["false_easting",0],PARAMETER["false_northing",0],UNIT["Meter",1]]'])

the result will be:

Traceback (most recent call last):
  File "<stdin>", line 1, in ?
  File "/usr/local/lib/python2.4/site-packages/", line 330, in ImportFromESRI
    return _osr.SpatialReference_ImportFromESRI(*args)
RuntimeError: OGR Error: Corrupt data

Does it work or not? It looks like it doesn't. I got the above projection definition from the test, so it should be valid.

comment:2 Changed 12 years ago by hobu

Note: See TracTickets for help on using tickets.