diff options
author | jmarshallnz <jcmarsha@gmail.com> | 2013-11-15 14:45:19 -0800 |
---|---|---|
committer | jmarshallnz <jcmarsha@gmail.com> | 2013-11-15 14:45:19 -0800 |
commit | a14289bd85a064415cbaf22d8777dc555df174a5 (patch) | |
tree | 8af4cd94bb6e4fd7cefa14c71068ab56d02b4cf4 | |
parent | cc00eb9f810fd3c5e084a4ec70096574a42ddbba (diff) | |
parent | 4d19be5bc321d68973058a9b9df8d4aacae89892 (diff) |
Merge pull request #3654 from jmarshallnz/substr_fixes
Validation substr() usage prior to plowing ahead.
-rw-r--r-- | xbmc/TextureCacheJob.cpp | 2 | ||||
-rw-r--r-- | xbmc/Util.cpp | 6 | ||||
-rw-r--r-- | xbmc/XBDateTime.cpp | 18 | ||||
-rw-r--r-- | xbmc/addons/GUIDialogAddonSettings.cpp | 2 | ||||
-rw-r--r-- | xbmc/dialogs/GUIDialogKeyboardGeneric.cpp | 4 | ||||
-rw-r--r-- | xbmc/filesystem/FavouritesDirectory.cpp | 5 | ||||
-rw-r--r-- | xbmc/filesystem/FileReaderFile.cpp | 1 | ||||
-rw-r--r-- | xbmc/filesystem/HTSPDirectory.cpp | 4 | ||||
-rw-r--r-- | xbmc/filesystem/RTVDirectory.cpp | 36 | ||||
-rw-r--r-- | xbmc/filesystem/SFTPFile.cpp | 4 | ||||
-rw-r--r-- | xbmc/guilib/GUIInfoTypes.cpp | 10 | ||||
-rw-r--r-- | xbmc/linux/LinuxTimezone.cpp | 1 | ||||
-rw-r--r-- | xbmc/network/cddb.cpp | 5 | ||||
-rw-r--r-- | xbmc/network/linux/NetworkLinux.cpp | 18 | ||||
-rw-r--r-- | xbmc/network/upnp/UPnPServer.cpp | 3 | ||||
-rw-r--r-- | xbmc/settings/dialogs/GUIDialogContentSettings.cpp | 2 | ||||
-rw-r--r-- | xbmc/utils/Fanart.cpp | 3 | ||||
-rw-r--r-- | xbmc/utils/HTMLUtil.cpp | 1 | ||||
-rw-r--r-- | xbmc/utils/TuxBoxUtil.cpp | 2 | ||||
-rw-r--r-- | xbmc/utils/URIUtils.cpp | 5 | ||||
-rw-r--r-- | xbmc/video/VideoDatabase.cpp | 27 | ||||
-rw-r--r-- | xbmc/video/dialogs/GUIDialogAudioSubtitleSettings.cpp | 10 | ||||
-rw-r--r-- | xbmc/win32/WIN32Util.cpp | 5 |
23 files changed, 102 insertions, 72 deletions
diff --git a/xbmc/TextureCacheJob.cpp b/xbmc/TextureCacheJob.cpp index 2b2c8bd6f0..0bb3b77b5e 100644 --- a/xbmc/TextureCacheJob.cpp +++ b/xbmc/TextureCacheJob.cpp @@ -145,7 +145,7 @@ CStdString CTextureCacheJob::DecodeImageURL(const CStdString &url, unsigned int image = thumbURL.GetHostName(); - CStdString optionString = thumbURL.GetOptions().substr(1); + CStdString optionString = thumbURL.GetOptions().empty() ? "" : thumbURL.GetOptions().substr(1); StringUtils::TrimRight(optionString, "/"); // In case XBMC adds a slash. std::vector<CStdString> options; diff --git a/xbmc/Util.cpp b/xbmc/Util.cpp index 0c8be08a20..8b1b919e34 100644 --- a/xbmc/Util.cpp +++ b/xbmc/Util.cpp @@ -2205,7 +2205,8 @@ bool CUtil::FindVobSubPair( const std::vector<CStdString>& vecSubtitles, const C CURL::Decode(strSubDirectory); if (URIUtils::HasExtension(strSubFile, ".sub") && (URIUtils::ReplaceExtension(strIdxFile,"").Equals(URIUtils::ReplaceExtension(strSubFile,"")) || - StringUtils::EqualsNoCase(strSubDirectory.substr(6, strSubDirectory.length()-11), URIUtils::ReplaceExtension(strIdxPath,"")))) + (strSubDirectory.size() >= 11 && + StringUtils::EqualsNoCase(strSubDirectory.substr(6, strSubDirectory.length()-11), URIUtils::ReplaceExtension(strIdxPath,""))))) { strSubPath = vecSubtitles[j]; return true; @@ -2233,7 +2234,8 @@ bool CUtil::IsVobSub( const std::vector<CStdString>& vecSubtitles, const CStdStr URIUtils::Split(vecSubtitles[j], strIdxDirectory, strIdxFile); if (URIUtils::HasExtension(strIdxFile, ".idx") && (URIUtils::ReplaceExtension(strIdxFile,"").Equals(URIUtils::ReplaceExtension(strSubFile,"")) || - StringUtils::EqualsNoCase(strSubDirectory.substr(6, strSubDirectory.length()-11), URIUtils::ReplaceExtension(vecSubtitles[j],"")))) + (strSubDirectory.size() >= 11 && + StringUtils::EqualsNoCase(strSubDirectory.substr(6, strSubDirectory.length()-11), URIUtils::ReplaceExtension(vecSubtitles[j],""))))) return true; } } diff --git a/xbmc/XBDateTime.cpp b/xbmc/XBDateTime.cpp index 1d3f9b7f3e..a09c82c320 100644 --- a/xbmc/XBDateTime.cpp +++ b/xbmc/XBDateTime.cpp @@ -175,9 +175,12 @@ void CDateTimeSpan::SetDateTimeSpan(int day, int hour, int minute, int second) void CDateTimeSpan::SetFromTimeString(const CStdString& time) // hh:mm { - int hour = atoi(time.substr(0, 2).c_str()); - int minutes = atoi(time.substr(3, 2).c_str()); - SetDateTimeSpan(0,hour,minutes,0); + if (time.size() >= 5 && time[2] == ':') + { + int hour = atoi(time.substr(0, 2).c_str()); + int minutes = atoi(time.substr(3, 2).c_str()); + SetDateTimeSpan(0,hour,minutes,0); + } } int CDateTimeSpan::GetDays() const @@ -680,6 +683,7 @@ void CDateTime::FromULargeInt(const ULARGE_INTEGER& time) void CDateTime::SetFromDateString(const CStdString &date) { + /* TODO:STRING_CLEANUP */ if (date.empty()) { SetValid(false); @@ -706,7 +710,7 @@ void CDateTime::SetFromDateString(const CStdString &date) } size_t iPos2 = date.find(","); - CStdString strDay = date.substr(iPos, iPos2-iPos); + CStdString strDay = (date.size() >= iPos) ? date.substr(iPos, iPos2-iPos) : ""; CStdString strYear = date.substr(date.find(" ", iPos2) + 1); while (months[j] && stricmp(strMonth.c_str(),months[j]) != 0) j++; @@ -970,10 +974,12 @@ void CDateTime::SetFromDBDateTime(const CStdString &dateTime) void CDateTime::SetFromDBDate(const CStdString &date) { + if (date.size() < 10) + return; // assumes format: // YYYY-MM-DD or DD-MM-YYYY int year = 0, month = 0, day = 0; - if (date.size() > 2 && (date[2] == '-' || date[2] == '.')) + if (date[2] == '-' || date[2] == '.') { day = atoi(date.substr(0, 2).c_str()); month = atoi(date.substr(3, 2).c_str()); @@ -990,6 +996,8 @@ void CDateTime::SetFromDBDate(const CStdString &date) void CDateTime::SetFromDBTime(const CStdString &time) { + if (time.size() < 8) + return; // assumes format: // HH:MM:SS int hour, minute, second; diff --git a/xbmc/addons/GUIDialogAddonSettings.cpp b/xbmc/addons/GUIDialogAddonSettings.cpp index 94b8f17cb8..b61fe8567b 100644 --- a/xbmc/addons/GUIDialogAddonSettings.cpp +++ b/xbmc/addons/GUIDialogAddonSettings.cpp @@ -438,7 +438,7 @@ bool CGUIDialogAddonSettings::ShowVirtualKeyboard(int iControl) else if (strcmp(type, "time") == 0) { SYSTEMTIME timedate; - if (!value.empty()) + if (value.size() >= 5) { // assumes HH:MM timedate.wHour = atoi(value.substr(0, 2).c_str()); diff --git a/xbmc/dialogs/GUIDialogKeyboardGeneric.cpp b/xbmc/dialogs/GUIDialogKeyboardGeneric.cpp index 3152e51f77..9d898de665 100644 --- a/xbmc/dialogs/GUIDialogKeyboardGeneric.cpp +++ b/xbmc/dialogs/GUIDialogKeyboardGeneric.cpp @@ -761,7 +761,9 @@ void CGUIDialogKeyboardGeneric::OnPasteClipboard(void) { g_charsetConverter.utf8ToW(utf8_text, unicode_text); - int i = GetCursorPos(); + size_t i = GetCursorPos(); + if (i > m_strEdit.size()) + i = m_strEdit.size(); CStdStringW left_end = m_strEdit.substr(0, i); CStdStringW right_end = m_strEdit.substr(i); diff --git a/xbmc/filesystem/FavouritesDirectory.cpp b/xbmc/filesystem/FavouritesDirectory.cpp index 5339fb8fab..523ec47002 100644 --- a/xbmc/filesystem/FavouritesDirectory.cpp +++ b/xbmc/filesystem/FavouritesDirectory.cpp @@ -192,9 +192,10 @@ CStdString CFavouritesDirectory::GetExecutePath(const CFileItem &item, const std if (!contextWindow.empty()) execute = StringUtils::Format("ActivateWindow(%s,%s,return)", contextWindow.c_str(), StringUtils::Paramify(item.GetPath()).c_str()); } - else if (item.IsScript()) + /* TODO:STRING_CLEANUP */ + else if (item.IsScript() && item.GetPath().size() > 9) // plugin://<foo> execute = StringUtils::Format("RunScript(%s)", StringUtils::Paramify(item.GetPath().substr(9)).c_str()); - else if (item.IsAndroidApp()) + else if (item.IsAndroidApp() && item.GetPath().size() > 26) // androidapp://sources/apps/<foo> execute = StringUtils::Format("StartAndroidActivity(%s)", StringUtils::Paramify(item.GetPath().substr(26)).c_str()); else // assume a media file { diff --git a/xbmc/filesystem/FileReaderFile.cpp b/xbmc/filesystem/FileReaderFile.cpp index 2b27aeae6f..3cb3af0da4 100644 --- a/xbmc/filesystem/FileReaderFile.cpp +++ b/xbmc/filesystem/FileReaderFile.cpp @@ -43,6 +43,7 @@ CFileReaderFile::~CFileReaderFile() //********************************************************************************************* bool CFileReaderFile::Open(const CURL& url) { + // URL is of the form filereader://<foo> CStdString strURL = url.Get(); strURL = strURL.substr(13); return m_reader.Open(strURL,READ_CACHED); diff --git a/xbmc/filesystem/HTSPDirectory.cpp b/xbmc/filesystem/HTSPDirectory.cpp index c0986865ea..cab6b13247 100644 --- a/xbmc/filesystem/HTSPDirectory.cpp +++ b/xbmc/filesystem/HTSPDirectory.cpp @@ -406,7 +406,9 @@ bool CHTSPDirectory::GetTag(const CURL &base, CFileItemList &items) { CURL url(base); - int id = atoi(url.GetFileName().substr(5).c_str()); + int id = 0; + if (url.GetFileName().size() >= 5) + id = atoi(url.GetFileName().substr(5).c_str()); SChannels channels = m_session->GetChannels(id); if(channels.empty()) diff --git a/xbmc/filesystem/RTVDirectory.cpp b/xbmc/filesystem/RTVDirectory.cpp index c0e046824c..7b2ffb38cb 100644 --- a/xbmc/filesystem/RTVDirectory.cpp +++ b/xbmc/filesystem/RTVDirectory.cpp @@ -190,22 +190,26 @@ bool CRTVDirectory::GetDirectory(const CStdString& strPath, CFileItemList &items if (recordedNode) { CStdString strRecorded = recordedNode->FirstChild()->Value(); - int iYear, iMonth, iDay; - - iYear = atoi(strRecorded.substr(0, 4).c_str()); - iMonth = atoi(strRecorded.substr(5, 2).c_str()); - iDay = atoi(strRecorded.substr(8, 2).c_str()); - dtDateTime.wYear = iYear; - dtDateTime.wMonth = iMonth; - dtDateTime.wDay = iDay; - - int iHour, iMin, iSec; - iHour = atoi(strRecorded.substr(11, 2).c_str()); - iMin = atoi(strRecorded.substr(14, 2).c_str()); - iSec = atoi(strRecorded.substr(17, 2).c_str()); - dtDateTime.wHour = iHour; - dtDateTime.wMinute = iMin; - dtDateTime.wSecond = iSec; + + if (strRecorded.size() >= 19) + { + /* TODO:STRING_CLEANUP */ + int iYear, iMonth, iDay; + iYear = atoi(strRecorded.substr(0, 4).c_str()); + iMonth = atoi(strRecorded.substr(5, 2).c_str()); + iDay = atoi(strRecorded.substr(8, 2).c_str()); + dtDateTime.wYear = iYear; + dtDateTime.wMonth = iMonth; + dtDateTime.wDay = iDay; + + int iHour, iMin, iSec; + iHour = atoi(strRecorded.substr(11, 2).c_str()); + iMin = atoi(strRecorded.substr(14, 2).c_str()); + iSec = atoi(strRecorded.substr(17, 2).c_str()); + dtDateTime.wHour = iHour; + dtDateTime.wMinute = iMin; + dtDateTime.wSecond = iSec; + } } // PATH diff --git a/xbmc/filesystem/SFTPFile.cpp b/xbmc/filesystem/SFTPFile.cpp index 6d8a9d5dd3..84fce18b1f 100644 --- a/xbmc/filesystem/SFTPFile.cpp +++ b/xbmc/filesystem/SFTPFile.cpp @@ -50,7 +50,9 @@ using namespace std; static CStdString CorrectPath(const CStdString path) { - if(path == "~" || path.substr(0, 2) == "~/") + if (path == "~") + return "./"; + else if (path.substr(0, 2) == "~/") return "./" + path.substr(2); else return "/" + path; diff --git a/xbmc/guilib/GUIInfoTypes.cpp b/xbmc/guilib/GUIInfoTypes.cpp index 95084dcd59..d2039d2242 100644 --- a/xbmc/guilib/GUIInfoTypes.cpp +++ b/xbmc/guilib/GUIInfoTypes.cpp @@ -105,7 +105,7 @@ void CGUIInfoColor::Parse(const CStdString &label, int context) if (label.Equals("-", false)) return; - if (StringUtils::StartsWithNoCase(label, "$var")) + if (StringUtils::StartsWithNoCase(label, "$var[")) { label2 = label.substr(5, label.length() - 6); m_info = g_infoManager.TranslateSkinVariableString(label2, context); @@ -114,7 +114,7 @@ void CGUIInfoColor::Parse(const CStdString &label, int context) return; } - if (StringUtils::StartsWithNoCase(label, "$info")) + if (StringUtils::StartsWithNoCase(label, "$info[")) label2 = label.substr(6, label.length()-7); m_info = g_infoManager.TranslateString(label2); @@ -208,7 +208,7 @@ CStdString CGUIInfoLabel::ReplaceLocalize(const CStdString &label) while (pos1 != std::string::npos) { size_t pos2 = StringUtils::FindEndBracket(work, '[', ']', pos1 + 10); - if (pos2 > pos1) + if (pos2 != std::string::npos) { CStdString left = work.substr(0, pos1); CStdString right = work.substr(pos2 + 1); @@ -236,7 +236,7 @@ CStdString CGUIInfoLabel::ReplaceAddonStrings(const CStdString &label) while (pos1 != std::string::npos) { size_t pos2 = StringUtils::FindEndBracket(work, '[', ']', pos1 + 7); - if (pos2 > pos1) + if (pos2 != std::string::npos) { CStdString left = work.substr(0, pos1); CStdString right = work.substr(pos2 + 1); @@ -300,7 +300,7 @@ void CGUIInfoLabel::Parse(const CStdString &label, int context) m_info.push_back(CInfoPortion(0, work.substr(0, pos1), "")); pos2 = StringUtils::FindEndBracket(work, '[', ']', pos1 + len); - if (pos2 > pos1) + if (pos2 != std::string::npos) { // decipher the block CStdString block = work.substr(pos1 + len, pos2 - pos1 - len); diff --git a/xbmc/linux/LinuxTimezone.cpp b/xbmc/linux/LinuxTimezone.cpp index 29844f9816..be7bce6a3b 100644 --- a/xbmc/linux/LinuxTimezone.cpp +++ b/xbmc/linux/LinuxTimezone.cpp @@ -116,6 +116,7 @@ CLinuxTimezone::CLinuxTimezone() : m_IsDST(0) s = line; StringUtils::Trim(s); + /* TODO:STRING_CLEANUP */ if (s.length() == 0) continue; diff --git a/xbmc/network/cddb.cpp b/xbmc/network/cddb.cpp index d2a524a064..50d89499b0 100644 --- a/xbmc/network/cddb.cpp +++ b/xbmc/network/cddb.cpp @@ -523,6 +523,7 @@ void Xcddb::parseData(const char *buffer) CStdString strKeyword = *it; CStdString strValue = keywords[strKeyword]; + /* TODO:STRING_CLEANUP */ if (strKeyword == "DTITLE") { // DTITLE may contain artist and disc title, separated with " / ", @@ -556,7 +557,7 @@ void Xcddb::parseData(const char *buffer) { // Extract Year from extended info // as a fallback - size_t iPos = strExtd.find("YEAR:"); + size_t iPos = strExtd.find("YEAR: "); if (iPos != std::string::npos) // You never know if you really get UTF-8 strings from cddb g_charsetConverter.unknownToUTF8(strExtd.substr(iPos + 6, 4), m_strYear); } @@ -565,7 +566,7 @@ void Xcddb::parseData(const char *buffer) { // Extract ID3 Genre // as a fallback - size_t iPos = strExtd.find("ID3G:"); + size_t iPos = strExtd.find("ID3G: "); if (iPos != std::string::npos) { CStdString strGenre = strExtd.substr(iPos + 5, 4); diff --git a/xbmc/network/linux/NetworkLinux.cpp b/xbmc/network/linux/NetworkLinux.cpp index 9c4a8d68cb..71375e13c6 100644 --- a/xbmc/network/linux/NetworkLinux.cpp +++ b/xbmc/network/linux/NetworkLinux.cpp @@ -209,14 +209,13 @@ CStdString CNetworkInterfaceLinux::GetCurrentDefaultGateway(void) if (fread(buffer, sizeof(char), sizeof(buffer), pipe) > 0 && !ferror(pipe)) { tmpStr = buffer; - result = tmpStr.substr(11); - } - else - { - CLog::Log(LOGWARNING, "Unable to determine gateway"); + if (tmpStr.length() >= 11) + result = tmpStr.substr(11); } pclose(pipe); } + if (result.empty()) + CLog::Log(LOGWARNING, "Unable to determine gateway"); #elif defined(TARGET_FREEBSD) size_t needed; int mib[6]; @@ -482,14 +481,13 @@ std::vector<CStdString> CNetworkLinux::GetNameServers(void) if (fread(buffer, sizeof(char), sizeof(buffer), pipe) > 0 && !ferror(pipe)) { tmpStr = buffer; - result.push_back(tmpStr.substr(17)); - } - else - { - CLog::Log(LOGWARNING, "Unable to determine nameserver"); + if (tmpStr.length() >= 17) + result.push_back(tmpStr.substr(17)); } pclose(pipe); } + if (result.empty()) + CLog::Log(LOGWARNING, "Unable to determine nameserver"); #elif defined(TARGET_ANDROID) char nameserver[PROP_VALUE_MAX]; diff --git a/xbmc/network/upnp/UPnPServer.cpp b/xbmc/network/upnp/UPnPServer.cpp index 4b6e26c92d..5c9e982f74 100644 --- a/xbmc/network/upnp/UPnPServer.cpp +++ b/xbmc/network/upnp/UPnPServer.cpp @@ -1199,11 +1199,10 @@ CUPnPServer::SortItems(CFileItemList& items, const char* sort_criteria) bool sorted = false; CStdStringArray tokens = StringUtils::SplitString(criteria, ","); for (vector<CStdString>::reverse_iterator itr = tokens.rbegin(); itr != tokens.rend(); itr++) { - CStdString method = itr->substr(1); - SortDescription sorting; /* Platinum guarantees 1st char is - or + */ sorting.sortOrder = StringUtils::StartsWith(*itr, "+") ? SortOrderAscending : SortOrderDescending; + CStdString method = itr->substr(1); /* resource specific */ if (method.Equals("res@duration")) diff --git a/xbmc/settings/dialogs/GUIDialogContentSettings.cpp b/xbmc/settings/dialogs/GUIDialogContentSettings.cpp index 14043732b3..825c22ff1e 100644 --- a/xbmc/settings/dialogs/GUIDialogContentSettings.cpp +++ b/xbmc/settings/dialogs/GUIDialogContentSettings.cpp @@ -92,7 +92,7 @@ bool CGUIDialogContentSettings::OnMessage(CGUIMessage &message) g_windowManager.SendMessage(msg); int iSelected = msg.GetParam1(); if (iSelected == m_vecItems->Size() - 1) - { // Get More... item. + { // Get More... item, path 'addons://more/<content>' // This is tricky - ideally we want to completely save the state of this dialog, // close it while linking to the addon manager, then reopen it on return. // For now, we just close the dialog + send the GetPath() to open the addons window diff --git a/xbmc/utils/Fanart.cpp b/xbmc/utils/Fanart.cpp index 6026d10b31..0142a9e430 100644 --- a/xbmc/utils/Fanart.cpp +++ b/xbmc/utils/Fanart.cpp @@ -107,7 +107,8 @@ CStdString CFanart::GetPreviewURL(unsigned int index) const const CStdString CFanart::GetColor(unsigned int index) const { - if (index >= max_fanart_colors || m_fanart.size() == 0) + if (index >= max_fanart_colors || m_fanart.size() == 0 || + m_fanart[0].strColors.size() < index*9+8) return "FFFFFFFF"; // format is AARRGGBB,AARRGGBB etc. diff --git a/xbmc/utils/HTMLUtil.cpp b/xbmc/utils/HTMLUtil.cpp index 5562a9b63c..fbf2baed90 100644 --- a/xbmc/utils/HTMLUtil.cpp +++ b/xbmc/utils/HTMLUtil.cpp @@ -287,6 +287,7 @@ static const HTMLMapping mappings[] = void CHTMLUtil::ConvertHTMLToW(const CStdStringW& strHTML, CStdStringW& strStripped) { + /* TODO:STRING_CLEANUP */ if (strHTML.size() == 0) { strStripped.clear(); diff --git a/xbmc/utils/TuxBoxUtil.cpp b/xbmc/utils/TuxBoxUtil.cpp index 5f4dd344ef..2ab9681b89 100644 --- a/xbmc/utils/TuxBoxUtil.cpp +++ b/xbmc/utils/TuxBoxUtil.cpp @@ -561,7 +561,7 @@ bool CTuxBoxUtil::GetZapUrl(const CStdString& strPath, CFileItem &items ) { for (vector<sAudioChannel>::iterator sChannel = sCurSrvData.audio_channels.begin(); sChannel!=sCurSrvData.audio_channels.end(); ++sChannel) { - if (sChannel->pid != sRequestedAudioChannel.pid) + if (sChannel->pid != sRequestedAudioChannel.pid && sChannel->pid.size() >= 4) strAPids += "," + sChannel->pid.substr(sChannel->pid.size() - 4); } CLog::Log(LOGDEBUG, "%s - Sending all audio pids: %s%s", __FUNCTION__, strAudioChannelPid.c_str(), strAPids.c_str()); diff --git a/xbmc/utils/URIUtils.cpp b/xbmc/utils/URIUtils.cpp index 9c1bfa9dd9..122de01b96 100644 --- a/xbmc/utils/URIUtils.cpp +++ b/xbmc/utils/URIUtils.cpp @@ -460,7 +460,7 @@ bool URIUtils::IsRemote(const CStdString& strFile) bool URIUtils::IsOnDVD(const CStdString& strFile) { #ifdef TARGET_WINDOWS - if (strFile.substr(1,1) == ":") + if (strFile.size() >= 2 && strFile.substr(1,1) == ":") return (GetDriveType(strFile.substr(0, 3).c_str()) == DRIVE_CDROM); #endif @@ -593,8 +593,7 @@ bool URIUtils::IsDVD(const CStdString& strFile) if (StringUtils::StartsWithNoCase(strFile, "dvd://")) return true; - if(strFile.substr(1) != ":\\" - && strFile.substr(1) != ":") + if(strFile.size() < 2 || (strFile.substr(1) != ":\\" && strFile.substr(1) != ":")) return false; if(GetDriveType(strFile.c_str()) == DRIVE_CDROM) diff --git a/xbmc/video/VideoDatabase.cpp b/xbmc/video/VideoDatabase.cpp index ed02f667d7..3c04cf274c 100644 --- a/xbmc/video/VideoDatabase.cpp +++ b/xbmc/video/VideoDatabase.cpp @@ -7321,20 +7321,19 @@ void CVideoDatabase::GetMusicVideoAlbumsByName(const CStdString& strSearch, CFil if (NULL == m_pDB.get()) return; if (NULL == m_pDS.get()) return; - CStdString strLike; + strSQL = StringUtils::Format("SELECT DISTINCT" + " musicvideo.c%02d," + " musicvideo.idMVideo," + " path.strPath" + " FROM" + " musicvideo" + " JOIN files ON" + " files.idFile=musicvideo.idFile" + " JOIN path ON" + " path.idPath=files.idPath", VIDEODB_ID_MUSICVIDEO_ALBUM); if (!strSearch.empty()) - { - strLike = StringUtils::Format("and musicvideo.c%02d",VIDEODB_ID_MUSICVIDEO_ALBUM); - strLike += "like '%%s%%%'"; - } - if (CProfilesManager::Get().GetMasterProfile().getLockMode() != LOCK_MODE_EVERYONE && !g_passwordManager.bMasterUser) - strSQL=PrepareSQL("select distinct musicvideo.c%02d,musicvideo.idMVideo,path.strPath from musicvideo,files,path where files.idFile=musicvideo.idFile and files.idPath=path.idPath"+strLike,VIDEODB_ID_MUSICVIDEO_ALBUM,strSearch.c_str()); - else - { - if (!strLike.empty()) - strLike = "where " + strLike.substr(4); - strSQL=PrepareSQL("select distinct musicvideo.c%02d,musicvideo.idMVideo from musicvideo"+strLike,VIDEODB_ID_MUSICVIDEO_ALBUM,strSearch.c_str()); - } + strSQL += PrepareSQL(" WHERE musicvideo.c%02d like '%%%s%%'",VIDEODB_ID_MUSICVIDEO_ALBUM, strSearch.c_str()); + m_pDS->query( strSQL.c_str() ); while (!m_pDS->eof()) @@ -7346,7 +7345,7 @@ void CVideoDatabase::GetMusicVideoAlbumsByName(const CStdString& strSearch, CFil } if (CProfilesManager::Get().GetMasterProfile().getLockMode() != LOCK_MODE_EVERYONE && !g_passwordManager.bMasterUser) - if (!g_passwordManager.IsDatabasePathUnlocked(CStdString(m_pDS->fv("path.strPath").get_asString()),*CMediaSourceSettings::Get().GetSources("video"))) + if (!g_passwordManager.IsDatabasePathUnlocked(CStdString(m_pDS->fv(2).get_asString()),*CMediaSourceSettings::Get().GetSources("video"))) { m_pDS->next(); continue; diff --git a/xbmc/video/dialogs/GUIDialogAudioSubtitleSettings.cpp b/xbmc/video/dialogs/GUIDialogAudioSubtitleSettings.cpp index 584df714d1..8dfd760a39 100644 --- a/xbmc/video/dialogs/GUIDialogAudioSubtitleSettings.cpp +++ b/xbmc/video/dialogs/GUIDialogAudioSubtitleSettings.cpp @@ -138,8 +138,14 @@ void CGUIDialogAudioSubtitleSettings::AddAudioStreams(unsigned int id) { CStdString strAudioInfo; g_application.m_pPlayer->GetAudioInfo(strAudioInfo); - int iNumChannels = atoi(strAudioInfo.substr(strAudioInfo.find("chns:") + 5).c_str()); - CStdString strAudioCodec = strAudioInfo.substr(7, strAudioInfo.find(") VBR") - 5); + /* TODO:STRING_CLEANUP */ + int iNumChannels = 0; + size_t pos = strAudioInfo.find("chns:"); + if (pos != std::string::npos) + iNumChannels = atoi(strAudioInfo.substr(pos + 5).c_str()); + CStdString strAudioCodec; + if (strAudioInfo.size() > 7) + strAudioCodec = strAudioInfo.substr(7, strAudioInfo.find(") VBR") - 5); bool bDTS = strstr(strAudioCodec.c_str(), "DTS") != 0; bool bAC3 = strstr(strAudioCodec.c_str(), "AC3") != 0; if (iNumChannels == 2 && !(bDTS || bAC3)) diff --git a/xbmc/win32/WIN32Util.cpp b/xbmc/win32/WIN32Util.cpp index d5bde11c95..97202fd131 100644 --- a/xbmc/win32/WIN32Util.cpp +++ b/xbmc/win32/WIN32Util.cpp @@ -866,7 +866,7 @@ void CWIN32Util::GetDrivesByType(VECSOURCES &localDrives, Drive_Types eDriveType UINT uDriveType= GetDriveTypeW( strWdrive.c_str() ); // don't use GetVolumeInformation on fdd's as the floppy controller may be enabled in Bios but // no floppy HW is attached which causes huge delays. - if(strWdrive.substr(0,2) != L"A:" && strWdrive.substr(0,2) != L"B:") + if(strWdrive.size() >= 2 && strWdrive.substr(0,2) != L"A:" && strWdrive.substr(0,2) != L"B:") nResult= GetVolumeInformationW( strWdrive.c_str() , cVolumeName, 100, 0, 0, 0, NULL, 25); if(nResult == 0 && bonlywithmedia) { @@ -1592,6 +1592,9 @@ extern "C" bool CWIN32Util::IsUsbDevice(const CStdStringW &strWdrive) { + if (strWdrive.size() < 2) + return false; + CStdStringW strWDevicePath = StringUtils::Format(L"\\\\.\\%s",strWdrive.substr(0, 2).c_str()); HANDLE deviceHandle = CreateFileW( |