Ticket #8878: 0001-Prevent-recursive-pain.patch

File 0001-Prevent-recursive-pain.patch, 1.8 KB (added by beirdo, 10 years ago)
  • mythtv/programs/mythbackend/upnpmedia.cpp

    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 
    140140        QString fName = Info.fileName();
    141141        QString fPath = Info.filePath();
    142142
    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 == "?.")
    146148            continue;
    147         }
    148149
    149150        if (Info.isDir())
    150151        {
     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
    151158            itemID++;
    152159
    153160            query.prepare("INSERT INTO upnpmedia "
    int UPnpMedia::buildFileList(QString directory, int rootID, int itemID, MSqlQuer 
    168175            if (!query.exec())
    169176                MythDB::DBError("UPnpMedia::buildFileList", query);
    170177
    171             itemID = buildFileList(Info.filePath(), 0, itemID, query);
     178            itemID = buildFileList(fPath, 0, itemID, query);
    172179            continue;
    173180
    174181        }