Skip to content

Commit

Permalink
Ensure ogr, postgis and memory providers reject features
Browse files Browse the repository at this point in the history
with too many attributes
  • Loading branch information
nyalldawson committed Feb 17, 2018
1 parent 4ae476d commit 7187ae3
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 2 deletions.
9 changes: 8 additions & 1 deletion src/core/providers/memory/qgsmemoryprovider.cpp
Expand Up @@ -343,6 +343,7 @@ QgsCoordinateReferenceSystem QgsMemoryProvider::crs() const

bool QgsMemoryProvider::addFeatures( QgsFeatureList &flist, Flags )
{
bool result = true;
// whether or not to update the layer extent on the fly as we add features
bool updateExtent = mFeatures.isEmpty() || !mExtent.isEmpty();

Expand All @@ -364,6 +365,12 @@ bool QgsMemoryProvider::addFeatures( QgsFeatureList &flist, Flags )
}
it->setAttributes( attributes );
}
else if ( it->attributes().count() > fieldCount )
{
// too many attributes
result = false;
continue;
}

mFeatures.insert( mNextFeatureId, *it );

Expand All @@ -380,7 +387,7 @@ bool QgsMemoryProvider::addFeatures( QgsFeatureList &flist, Flags )
mNextFeatureId++;
}

return true;
return result;
}

bool QgsMemoryProvider::deleteFeatures( const QgsFeatureIds &id )
Expand Down
2 changes: 1 addition & 1 deletion src/providers/ogr/qgsogrprovider.cpp
Expand Up @@ -1328,7 +1328,7 @@ bool QgsOgrProvider::addFeaturePrivate( QgsFeature &f, Flags flags )
{
// don't try to set field from attribute map if it's not present in layer
if ( ogrAttId >= fdef.GetFieldCount() )
continue;
return false;

//if(!s.isEmpty())
// continue;
Expand Down
6 changes: 6 additions & 0 deletions src/providers/postgres/qgspostgresprovider.cpp
Expand Up @@ -2148,6 +2148,12 @@ bool QgsPostgresProvider::addFeatures( QgsFeatureList &flist, Flags flags )
{
QgsAttributes attrs = features->attributes();

if ( attrs.count() > mAttributeFields.count() )
{
returnvalue = false;
continue;
}

QStringList params;
if ( !mGeometryColumn.isNull() )
{
Expand Down

0 comments on commit 7187ae3

Please sign in to comment.