[gdal-dev] GDAL error from Mapserver 7.0

Jukka Rahkonen jukka.rahkonen at maanmittauslaitos.fi
Fri Sep 11 00:40:03 PDT 2015


Even Rouault <even.rouault <at> spatialys.com> writes:

 
> The crash is indeed linked to the fact that a wrong table name was passed.
And 
> to reach that point the table name was of the form 
> "table_name(geom_column_name)", right ?
> 
> Fixed by https://trac.osgeo.org/gdal/ticket/6103
> 
> As far as the why there's this one character offset, the fundamental cause
for 
> the issue, I don't know without having a way to reproduce.

Hi,

I got a hint that it might originate from the SQLite driver as well but we
have not yet understood the code well enough:



    size_t nFromPos = osSQLBase.ifind(" from ");
    if (nFromPos == std::string::npos)
    {
        return std::pair<OGRLayer*,
IOGRSQLiteGetSpatialWhere*>((OGRLayer*)NULL, (IOGRSQLiteGetSpatialWhere*)NULL);
    }

    char chQuote = osSQLBase[nFromPos + 6];
    int bInQuotes = (chQuote == '\'' || chQuote == '"' );
    CPLString osBaseLayerName;
    for( i = nFromPos + 6 + (bInQuotes ? 1 : 0);
         i < osSQLBase.size(); i++ )
    {
        if (osSQLBase[i] == chQuote && i + 1 < osSQLBase.size() &&
            osSQLBase[i + 1] == chQuote )
        {
            osBaseLayerName += osSQLBase[i];
            i++;
        }
        else if (osSQLBase[i] == chQuote && bInQuotes)
        {
            i++;
            break;
        }
        else if (osSQLBase[i] == ' ' && !bInQuotes)
            break;
        else
            osBaseLayerName += osSQLBase[i];
    }

-Jukka-



More information about the gdal-dev mailing list