From 8c6245a9040848d7b9366ddc88dc4ad36b96e4f6 Mon Sep 17 00:00:00 2001
From: Gavin Hurlbut <gjhurlbu@gmail.com>
Date: Tue, 7 Sep 2010 00:55:26 -0700
Subject: [PATCH] Prevent recursive pain
diff --git a/mythtv/programs/mythbackend/upnpmedia.cpp b/mythtv/programs/mythbackend/upnpmedia.cpp
index 732ec62..be48294 100644
a
|
b
|
int UPnpMedia::buildFileList(QString directory, int rootID, int itemID, MSqlQuer |
140 | 140 | QString fName = Info.fileName(); |
141 | 141 | QString fPath = Info.filePath(); |
142 | 142 | |
143 | | if (fName == "." || |
144 | | fName == "..") |
145 | | { |
| 143 | // We don't want . or .. or something that specifically globs to |
| 144 | // either. The "??" and "?" cases can happen when the backend is |
| 145 | // running in a non-UTF-8 locale and comes across a UTF-8 filename |
| 146 | if (fName == "." || fName == ".." || fName == "?" || fName == "??" || |
| 147 | fName == ".?" || fName == "?.") |
146 | 148 | continue; |
147 | | } |
148 | 149 | |
149 | 150 | if (Info.isDir()) |
150 | 151 | { |
| 152 | // If we are about to recurse into the current directory (which |
| 153 | // will cause an infinite recursive loop!), skip this entry. |
| 154 | QDir subDir(fPath); |
| 155 | if( subDir.canonicalPath() == vidDir.canonicalPath() ) |
| 156 | continue; |
| 157 | |
151 | 158 | itemID++; |
152 | 159 | |
153 | 160 | query.prepare("INSERT INTO upnpmedia " |
… |
… |
int UPnpMedia::buildFileList(QString directory, int rootID, int itemID, MSqlQuer |
168 | 175 | if (!query.exec()) |
169 | 176 | MythDB::DBError("UPnpMedia::buildFileList", query); |
170 | 177 | |
171 | | itemID = buildFileList(Info.filePath(), 0, itemID, query); |
| 178 | itemID = buildFileList(fPath, 0, itemID, query); |
172 | 179 | continue; |
173 | 180 | |
174 | 181 | } |