Skip to content

Commit a20c3cf

Browse files
committed
Guard against circular symbolic links in SVG selector widget
1 parent c60c4f7 commit a20c3cf

File tree

2 files changed

+20
-1
lines changed

2 files changed

+20
-1
lines changed

src/gui/symbology-ng/qgssvgselectorwidget.cpp

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,7 @@ void QgsSvgSelectorLoader::run()
5151
{
5252
mCancelled = false;
5353
mQueuedSvgs.clear();
54+
mTraversedPaths.clear();
5455

5556
// start with a small initial timeout (ms)
5657
mTimerThreshold = 10;
@@ -92,9 +93,17 @@ void QgsSvgSelectorLoader::loadPath( const QString& path )
9293
}
9394
else
9495
{
96+
QDir dir( path );
97+
98+
//guard against circular symbolic links
99+
QString canonicalPath = dir.canonicalPath();
100+
if ( mTraversedPaths.contains( canonicalPath ) )
101+
return;
102+
103+
mTraversedPaths.insert( canonicalPath );
104+
95105
loadImages( path );
96106

97-
QDir dir( path );
98107
Q_FOREACH ( const QString& item, dir.entryList( QDir::Dirs | QDir::NoDotAndDotDot ) )
99108
{
100109
if ( mCancelled )
@@ -159,6 +168,7 @@ QgsSvgGroupLoader::~QgsSvgGroupLoader()
159168
void QgsSvgGroupLoader::run()
160169
{
161170
mCancelled = false;
171+
mTraversedPaths.clear();
162172

163173
while ( !mCancelled && !mParentPaths.isEmpty() )
164174
{
@@ -177,6 +187,13 @@ void QgsSvgGroupLoader::loadGroup( const QString& parentPath )
177187
{
178188
QDir parentDir( parentPath );
179189

190+
//guard against circular symbolic links
191+
QString canonicalPath = parentDir.canonicalPath();
192+
if ( mTraversedPaths.contains( canonicalPath ) )
193+
return;
194+
195+
mTraversedPaths.insert( canonicalPath );
196+
180197
Q_FOREACH ( const QString& item, parentDir.entryList( QDir::Dirs | QDir::NoDotAndDotDot ) )
181198
{
182199
if ( mCancelled )

src/gui/symbology-ng/qgssvgselectorwidget.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -91,6 +91,7 @@ class GUI_EXPORT QgsSvgSelectorLoader : public QThread
9191

9292
QElapsedTimer mTimer;
9393
int mTimerThreshold;
94+
QSet< QString > mTraversedPaths;
9495

9596
void loadPath( const QString& path );
9697
void loadImages( const QString& path );
@@ -145,6 +146,7 @@ class GUI_EXPORT QgsSvgGroupLoader : public QThread
145146

146147
QStringList mParentPaths;
147148
bool mCancelled;
149+
QSet< QString > mTraversedPaths;
148150

149151
void loadGroup( const QString& parentPath );
150152

0 commit comments

Comments
 (0)