[Gdal-dev] Testing arguments in the swig-bindings

Ari Jolma ari.jolma at tkk.fi
Tue Aug 28 12:32:17 EDT 2007


Frank Warmerdam kirjoitti:
> Can you provide more information on the kinds of input validation you
> would like to see added, and the rationale?  I think one of the examples
> you gave was passing in NULL strings where they are required.

Here's a list. The NULL strings and object pointers cause problems. The 
rationale is that an interpreted language should never segfault.

Regards,

Ari

-- MajorObject.SetDescription

If  pszNewDesc == NULL the application terminates (in Windows) with:

"This application has requested the Runtime to terminate it in an 
unusual way.
Please contact the application's support team for more information."

i.e. it does issue a normal error

-- Band.ComputeBandStats

setting nSampleStep == 0 causes an eternal loop

-- OGR::Datasource.TestCapability

segfault if pszCap == NULL

-- OGR::Datasource.ExecuteSQL

segfault if pszStatement == NULL

-- OGR::Layer.CreateFeature (separate for each driver, I'm testing MEM)

segfault if poFeature == NULL

-- OGR::Layer.TestCapability

segfault if pszCap == NULL

-- OGR::Layer.CreateField

segfault if poField == NULL

-- OGR::FeatureDefn.AddFieldDefn

segfault if poNewDefn == NULL

-- OGR::Geometry.* GEOS methods (at least Intersection, Disjoint, Overlaps)

segfault if poOtherGeom == NULL

-- OGR::Geometry.Transform

segfault if hTransform == NULL

-- OSR.GetWellKnownGeogCSAsWKT (OSRSetWellKnownGeogCS)

segfault if pszName == NULL

-- OSRSetFromUserInput

segfault if pszDefinition == NULL

-- OSR.GetProjectionMethodParameterList
-- OSR.GetProjectionMethodParamInfo

segfault if pszProjectionMethod == NULL

-- OSR::SpatialReference.GetAttrValue, SetAttrValue, GetProjParm, 
SetNormProjParm, GetNormProjParm, SetWellKnownGeogCS, SetFromUserInput

segfault if pszNodeName == NULL

-- OSR::SpatialReference.ExportToUSGS

segfault is piProjSys == NULL

>
> Some kind of argument checking, for instance passing in an unsupported
> resampling type when building overviews, would seem to be best checked
> in the appropriate C++ methods and a runtime error reported.
>
> NULL objects seemed to me to be best checked for the C wrappers which
> we have done.
>
> Best regards,


-- 
Prof. Ari Jolma
Geoinformaatio- ja paikannustekniikka / Geoinformation and positioning
Teknillinen Korkeakoulu / Helsinki University of Technology
tel: +358 9 451 3886 address: POBox 1200, 02015 TKK, Finland
Email: ari.jolma at tkk.fi URL: http://www.tkk.fi/~jolma





More information about the Gdal-dev mailing list