Changes between Initial Version and Version 1 of Ticket #1602


Ignore:
Timestamp:
May 1, 2007, 8:55:06 PM (17 years ago)
Author:
hobu
Comment:

Replying to ajolma:

Many methods in the GDAL and OGR, which are also defined in the C-API, do not check if the supplied parameter is valid. Invalid parameter values, notably NULLs given where a string or a handle is expected, lead to a segfault. Since the C-API is open to many scripting languages through the SWIG, and given the way scripting languages are used, it is a common case that invalid values end up to the GDAL and OGR core.

Some checks have been introduced to the SWIG interface (for example in ogr.i in OGRLayerShadow *CreateLayer) but it is probably better to implement all these checks in the C-API. Following is a (not necessarily a comprehensive) list of classes and methods which have this defect: (the list should be self-explanatory, it follows the SWIG API)

class Geo::GDAL # GetDataTypeByName (scalar name) # DecToDMS (scalar double, scalar string, scalar int) # GetDriverByName (scalar ShortName) # Open (scalar name, scalar Access=$Geo::GDAL::Const::GA_ReadOnly) # OpenShared (scalar name, scalar Access=$Geo::GDAL::Const::GA_ReadOnly) # AutoCreateWarpedVRT (scalar src_ds, scalar src_wkt=undef, scalar dst_wkt=undef, scalar ResampleAlg=$Geo::GDAL::Const::GRA_NearestNeighbour, scalar maxerror=0.0) class Geo::GDAL::Driver # Delete (scalar name) class Geo::GDAL::MajorObject # SetDescription (scalar NewDesc) class Geo::GDAL::Band # ComputeBandStats (scalar samplestep=1) (if samplestep == 0, the method gets into an eternal loop?) class Geo::OGR # GetDriverByName (scalar name) # Open (scalar filename, scalar update=0) # OpenShared (scalar filename, scalar update=0) class Geo::OGR::Driver # TestCapability (scalar cap) class Geo::OGR::Datasource # TestCapability (scalar cap) # ExecuteSQL (scalar statement, scalar geom=undef, scalar dialect="") class Geo::OGR::Layer # CreateFeature (scalar feature) # TestCapability (scalar cap) # CreateField (scalar field_def, scalar approx_ok=1) class Geo::OGR::Feature # Equal (scalar feature) # SetFrom (scalar other, scalar forgiving=1) class Geo::OGR::FeatureDefn # AddFieldDefn (scalar defn) class Geo::OGR::Geometry # Intersection (scalar other) # Union (scalar other) # Difference (scalar other) # SymmetricDifference (scalar other) # Equal (scalar other) # Disjoint (scalar other) # Touches (scalar other) # Crosses (scalar other) # Within (scalar other) # Contains (scalar other) # Overlaps (scalar other) # Transform (scalar trans) class Geo::OSR # GetWellKnownGeogCSAsWKT (scalar name) # GetUserInputAsWKT (scalar name) # GetProjectionMethodParameterList (scalar method) # GetProjectionMethodParamInfo (scalar method, scalar parameter) class Geo::OSR::SpatialReference # IsSame (scalar rhs) # IsSameGeogCS (scalar rhs) # GetAttrValue (scalar name, scalar child=0) # SetAttrValue (scalar name, scalar value) # GetProjParm (scalar name, scalar default_val=0.0) # SetNormProjParm (scalar name, scalar val) # GetNormProjParm (scalar name, scalar default_val=0.0) # SetWellKnownGeogCS (scalar name) # SetFromUserInput (scalar name) # CopyGeogCSFrom (scalar rhs)

Legend:

Unmodified
Added
Removed
Modified
  • Ticket #1602 – Description

    initial v1  
    1 Many methods in the GDAL and OGR, which are also defined in the C-API, do not check if the supplied parameter is valid. Invalid parameter values, notably NULLs given where a string or a handle is expected, lead to a segfault. Since the C-API is open to many scripting languages through the SWIG, and given the way scripting languages are used, it is a common case that invalid values end up to the GDAL and OGR core.
    2 
    3 Some checks have been introduced to the SWIG interface (for example in ogr.i in OGRLayerShadow *CreateLayer) but it is probably better to implement all these checks in the C-API. Following is a (not necessarily a comprehensive) list of classes and methods which have this defect: (the list should be self-explanatory, it follows the SWIG API)
    4 
    5 class Geo::GDAL
    6 #    GetDataTypeByName (scalar name)
    7 #     DecToDMS (scalar double, scalar string, scalar int)
    8 #     GetDriverByName (scalar ShortName)
    9 #     Open (scalar name, scalar Access=$Geo::GDAL::Const::GA_ReadOnly)
    10 #     OpenShared (scalar name, scalar Access=$Geo::GDAL::Const::GA_ReadOnly)
    11 #     AutoCreateWarpedVRT (scalar src_ds, scalar src_wkt=undef, scalar dst_wkt=undef, scalar ResampleAlg=$Geo::GDAL::Const::GRA_NearestNeighbour, scalar maxerror=0.0)
    12 class Geo::GDAL::Driver
    13 #     Delete (scalar name)
    14 class Geo::GDAL::MajorObject
    15 #     SetDescription (scalar NewDesc)
    16 class Geo::GDAL::Band
    17 #    ComputeBandStats (scalar samplestep=1) (if samplestep == 0, the method gets into an eternal loop?)
    18 class Geo::OGR
    19 #     GetDriverByName (scalar name)
    20 #     Open (scalar filename, scalar update=0)
    21 #     OpenShared (scalar filename, scalar update=0)
    22 class Geo::OGR::Driver
    23 #     TestCapability (scalar cap)
    24 class Geo::OGR::Datasource
    25 #    TestCapability (scalar cap)
    26 #    ExecuteSQL (scalar statement, scalar geom=undef, scalar dialect="")
    27 class Geo::OGR::Layer
    28 #     CreateFeature (scalar feature)
    29 #     TestCapability (scalar cap)
    30 #     CreateField (scalar field_def, scalar approx_ok=1)
    31 class Geo::OGR::Feature
    32 #     Equal (scalar feature)
    33 #    SetFrom (scalar other, scalar forgiving=1)
    34 class Geo::OGR::FeatureDefn
    35 #     AddFieldDefn (scalar defn)
    36 class Geo::OGR::Geometry
    37 #     Intersection (scalar other)
    38 #     Union (scalar other)
    39 #     Difference (scalar other)
    40 #     SymmetricDifference (scalar other)
    41 #     Equal (scalar other)
    42 #     Disjoint (scalar other)
    43 #     Touches (scalar other)
    44 #     Crosses (scalar other)
    45 #     Within (scalar other)
    46 #     Contains (scalar other)
    47 #     Overlaps (scalar other)
    48 #     Transform (scalar trans)
    49 class Geo::OSR
    50 #         GetWellKnownGeogCSAsWKT (scalar name)
    51 #     GetUserInputAsWKT (scalar name)
    52 #     GetProjectionMethodParameterList (scalar method)
    53 #     GetProjectionMethodParamInfo (scalar method, scalar parameter)
    54 class Geo::OSR::SpatialReference
    55 #     IsSame (scalar rhs)
    56 #     IsSameGeogCS (scalar rhs)
    57 #     GetAttrValue (scalar name, scalar child=0)
    58 #     SetAttrValue (scalar name, scalar value)
    59 #     GetProjParm (scalar name, scalar default_val=0.0)
    60 #     SetNormProjParm (scalar name, scalar val)
    61 #     GetNormProjParm (scalar name, scalar default_val=0.0)
    62 #     SetWellKnownGeogCS (scalar name)
    63 #     SetFromUserInput (scalar name)
    64 #     CopyGeogCSFrom (scalar rhs)
     1{{{
     2 
     3 class Geo::GDAL
     4 #    GetDataTypeByName (scalar name)
     5 #     DecToDMS (scalar double, scalar string, scalar int)
     6 #     GetDriverByName (scalar ShortName)
     7 #     Open (scalar name, scalar Access=$Geo::GDAL::Const::GA_ReadOnly)
     8 #     OpenShared (scalar name, scalar Access=$Geo::GDAL::Const::GA_ReadOnly)
     9 #     AutoCreateWarpedVRT (scalar src_ds, scalar src_wkt=undef, scalar dst_wkt=undef, scalar ResampleAlg=$Geo::GDAL::Const::GRA_NearestNeighbour, scalar maxerror=0.0)
     10 class Geo::GDAL::Driver
     11 #     Delete (scalar name)
     12 class Geo::GDAL::MajorObject
     13 #     SetDescription (scalar NewDesc)
     14 class Geo::GDAL::Band
     15 #    ComputeBandStats (scalar samplestep=1) (if samplestep == 0, the method gets into an eternal loop?)
     16 class Geo::OGR
     17 #     GetDriverByName (scalar name)
     18 #     Open (scalar filename, scalar update=0)
     19 #     OpenShared (scalar filename, scalar update=0)
     20 class Geo::OGR::Driver
     21 #     TestCapability (scalar cap)
     22 class Geo::OGR::Datasource
     23 #    TestCapability (scalar cap)
     24 #    ExecuteSQL (scalar statement, scalar geom=undef, scalar dialect="")
     25 class Geo::OGR::Layer
     26 #     CreateFeature (scalar feature)
     27 #     TestCapability (scalar cap)
     28 #     CreateField (scalar field_def, scalar approx_ok=1)
     29 class Geo::OGR::Feature
     30 #     Equal (scalar feature)
     31 #    SetFrom (scalar other, scalar forgiving=1)
     32 class Geo::OGR::FeatureDefn
     33 #     AddFieldDefn (scalar defn)
     34 class Geo::OGR::Geometry
     35 #     Intersection (scalar other)
     36 #     Union (scalar other)
     37 #     Difference (scalar other)
     38 #     SymmetricDifference (scalar other)
     39 #     Equal (scalar other)
     40 #     Disjoint (scalar other)
     41 #     Touches (scalar other)
     42 #     Crosses (scalar other)
     43 #     Within (scalar other)
     44 #     Contains (scalar other)
     45 #     Overlaps (scalar other)
     46 #     Transform (scalar trans)
     47 class Geo::OSR
     48 #         GetWellKnownGeogCSAsWKT (scalar name)
     49 #     GetUserInputAsWKT (scalar name)
     50 #     GetProjectionMethodParameterList (scalar method)
     51 #     GetProjectionMethodParamInfo (scalar method, scalar arameter)
     52 class Geo::OSR::SpatialReference
     53 #     IsSame (scalar rhs)
     54 #     IsSameGeogCS (scalar rhs)
     55 #     GetAttrValue (scalar name, scalar child=0)
     56 #     SetAttrValue (scalar name, scalar value)
     57 #     GetProjParm (scalar name, scalar default_val=0.0)
     58 #     SetNormProjParm (scalar name, scalar val)
     59 #     GetNormProjParm (scalar name, scalar default_val=0.0)
     60 #     SetWellKnownGeogCS (scalar name)
     61 #     SetFromUserInput (scalar name)
     62 #     CopyGeogCSFrom (scalar rhs)
     63}}}