Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/mpc-hc/mpc-hc.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorUnderground78 <underground78@users.sourceforge.net>2012-05-08 17:00:07 +0400
committerUnderground78 <underground78@users.sourceforge.net>2012-05-08 17:00:07 +0400
commit4a6ffbbf57fae3f3873e6f82d2dba9e7d0d614a2 (patch)
tree8342c117478dde76876378449eb30c0c56ace122
parent008010c53a8b5a3fe7b9af03ac8bb04bcc9c4b7a (diff)
Use secure version of the string copy functions.
git-svn-id: https://mpc-hc.svn.sourceforge.net/svnroot/mpc-hc/trunk@4643 10f7b99b-c216-0410-bff0-8a66a9350fd8
-rw-r--r--src/Subtitles/RTS.cpp2
-rw-r--r--src/Subtitles/VobSubFile.cpp4
-rw-r--r--src/apps/mplayerc/OpenDirHelper.cpp17
-rw-r--r--src/apps/mplayerc/PPageFileMediaInfo.cpp6
-rw-r--r--src/apps/mplayerc/PlayerPlaylistBar.cpp4
-rw-r--r--src/apps/mplayerc/RealMediaGraph.cpp4
-rw-r--r--src/apps/mplayerc/ShaderAutoCompleteDlg.cpp2
-rw-r--r--src/filters/muxer/MatroskaMuxer/MatroskaFile.h2
-rw-r--r--src/filters/parser/BaseSplitter/BaseSplitter.cpp4
-rw-r--r--src/filters/parser/RealMediaSplitter/RealMediaSplitter.cpp10
-rw-r--r--src/filters/reader/CDDAReader/CDDAReader.cpp2
-rw-r--r--src/filters/reader/CDXAReader/CDXAReader.cpp2
-rw-r--r--src/filters/reader/UDPReader/UDPReader.cpp2
-rw-r--r--src/filters/reader/VTSReader/VTSReader.cpp2
-rw-r--r--src/filters/source/FLICSource/FLICSource.cpp2
-rw-r--r--src/filters/source/ShoutcastSource/ShoutcastSource.cpp2
-rw-r--r--src/filters/source/SubtitleSource/SubtitleSource.cpp2
-rw-r--r--src/filters/switcher/AudioSwitcher/StreamSwitcher.cpp4
18 files changed, 38 insertions, 35 deletions
diff --git a/src/Subtitles/RTS.cpp b/src/Subtitles/RTS.cpp
index 6a4e2298f..464a644d8 100644
--- a/src/Subtitles/RTS.cpp
+++ b/src/Subtitles/RTS.cpp
@@ -2834,7 +2834,7 @@ STDMETHODIMP CRenderedTextSubtitle::GetStreamInfo(int iStream, WCHAR** ppName, L
return E_OUTOFMEMORY;
}
- wcscpy(*ppName, CStringW(m_name));
+ wcscpy_s(*ppName, m_name.GetLength() + 1, CStringW(m_name));
if (pLCID) {
*pLCID = ISO6391ToLcid (W2A(*ppName));
diff --git a/src/Subtitles/VobSubFile.cpp b/src/Subtitles/VobSubFile.cpp
index cab605d33..fbcb80561 100644
--- a/src/Subtitles/VobSubFile.cpp
+++ b/src/Subtitles/VobSubFile.cpp
@@ -1339,7 +1339,7 @@ STDMETHODIMP CVobSubFile::GetStreamInfo(int iStream, WCHAR** ppName, LCID* pLCID
return E_OUTOFMEMORY;
}
- wcscpy(*ppName, CStringW(sl.alt));
+ wcscpy_s(*ppName, sl.alt.GetLength() + 1, CStringW(sl.alt));
}
if (pLCID) {
@@ -2499,7 +2499,7 @@ STDMETHODIMP CVobSubStream::GetStreamInfo(int i, WCHAR** ppName, LCID* pLCID)
if (!(*ppName)) {
return E_OUTOFMEMORY;
}
- wcscpy(*ppName, CStringW(m_name));
+ wcscpy_s(*ppName, m_name.GetLength() + 1, CStringW(m_name));
}
if (pLCID) {
diff --git a/src/apps/mplayerc/OpenDirHelper.cpp b/src/apps/mplayerc/OpenDirHelper.cpp
index 65963d5c9..71020ccc7 100644
--- a/src/apps/mplayerc/OpenDirHelper.cpp
+++ b/src/apps/mplayerc/OpenDirHelper.cpp
@@ -31,27 +31,26 @@ WNDPROC COpenDirHelper::CBProc;
bool COpenDirHelper::m_incl_subdir;
CString COpenDirHelper::strLastOpenDir;
-void COpenDirHelper::SetFont(HWND hwnd,LPTSTR FontName,int FontSize)
+void COpenDirHelper::SetFont(HWND hwnd, LPTSTR FontName, int FontSize)
{
HFONT hf, hfOld;
LOGFONT lf = {0};
HDC hdc = GetDC(hwnd);
- GetObject(GetWindowFont(hwnd),sizeof(lf),&lf);
+ GetObject(GetWindowFont(hwnd), sizeof(lf), &lf);
lf.lfWeight = FW_REGULAR;
lf.lfHeight = (LONG)FontSize;
- StringCchCopy(lf.lfFaceName, countof(lf.lfFaceName), FontName);
- hf=CreateFontIndirect(&lf);
+ _tcscpy_s(lf.lfFaceName, FontName);
+ hf = CreateFontIndirect(&lf);
SetBkMode(hdc,OPAQUE);
- hfOld = (HFONT)SendMessage(hwnd,WM_GETFONT,NULL,NULL); // get old font
- SendMessage(hwnd,WM_SETFONT,(WPARAM)hf,TRUE); // set new font
+ hfOld = (HFONT)SendMessage(hwnd, WM_GETFONT, NULL, NULL); // get old font
+ SendMessage(hwnd, WM_SETFONT, (WPARAM)hf, TRUE); // set new font
- if (!hfOld && (hfOld!=hf)) {
+ if (!hfOld && (hfOld != hf)) {
DeleteObject(hfOld); // if the old font is not system font or the same as newfont, release it.
}
- ReleaseDC(hwnd,hdc);
-
+ ReleaseDC(hwnd, hdc);
}
// Subclass procedure
diff --git a/src/apps/mplayerc/PPageFileMediaInfo.cpp b/src/apps/mplayerc/PPageFileMediaInfo.cpp
index fbf45d002..7acba5ce3 100644
--- a/src/apps/mplayerc/PPageFileMediaInfo.cpp
+++ b/src/apps/mplayerc/PPageFileMediaInfo.cpp
@@ -130,13 +130,13 @@ BOOL CPPageFileMediaInfo::OnInitDialog()
memset(&lf, 0, sizeof(lf));
lf.lfPitchAndFamily = DEFAULT_PITCH | FF_MODERN;
// The empty string will fallback to the first font that matches the other specified attributes.
- CString fonts[] = { _T("Lucida Console"), _T("Courier New"), _T("") };
+ LPCTSTR fonts[] = { _T("Lucida Console"), _T("Courier New"), _T("") };
// Use a negative value to match the character height instead of the cell height.
int fonts_size[] = { -10, -11, -11 };
UINT i = 0;
BOOL success;
do {
- lstrcpy(lf.lfFaceName, fonts[i]);
+ _tcscpy_s(lf.lfFaceName, fonts[i]);
lf.lfHeight = fonts_size[i];
success = IsFontInstalled(fonts[i]) && m_pCFont->CreateFontIndirect(&lf);
i++;
@@ -145,7 +145,7 @@ BOOL CPPageFileMediaInfo::OnInitDialog()
m_mediainfo.SetWindowText(MI_Text);
// subclass the edit control
- OldControlProc = (WNDPROC) SetWindowLongPtr(m_mediainfo.m_hWnd, GWLP_WNDPROC, (LONG_PTR) ControlProc);
+ OldControlProc = (WNDPROC)SetWindowLongPtr(m_mediainfo.m_hWnd, GWLP_WNDPROC, (LONG_PTR)ControlProc);
return TRUE; // return TRUE unless you set the focus to a control
// EXCEPTION: OCX Property Pages should return FALSE
diff --git a/src/apps/mplayerc/PlayerPlaylistBar.cpp b/src/apps/mplayerc/PlayerPlaylistBar.cpp
index 94a244926..35d03f62b 100644
--- a/src/apps/mplayerc/PlayerPlaylistBar.cpp
+++ b/src/apps/mplayerc/PlayerPlaylistBar.cpp
@@ -1204,7 +1204,7 @@ void CPlayerPlaylistBar::DropItemOnList()
m_nDragIndex++;
}
for (int col=1; col < nColumnCount; col++) {
- _tcscpy(lvi.pszText, (LPCTSTR)(m_list.GetItemText(m_nDragIndex, col)));
+ _tcscpy_s(lvi.pszText, _MAX_PATH, (LPCTSTR)(m_list.GetItemText(m_nDragIndex, col)));
lvi.iSubItem = col;
m_list.SetItem(&lvi);
}
@@ -1395,7 +1395,7 @@ void CPlayerPlaylistBar::OnContextMenu(CWnd* /*pWnd*/, CPoint p)
if (HGLOBAL h = GlobalAlloc(GMEM_MOVEABLE, (str.GetLength()+1)*sizeof(TCHAR))) {
if (TCHAR* s = (TCHAR*)GlobalLock(h)) {
- _tcscpy(s, str);
+ _tcscpy_s(s, str.GetLength() + 1, str);
GlobalUnlock(h);
SetClipboardData(CF_UNICODETEXT, h);
}
diff --git a/src/apps/mplayerc/RealMediaGraph.cpp b/src/apps/mplayerc/RealMediaGraph.cpp
index a375b3391..a0233dc69 100644
--- a/src/apps/mplayerc/RealMediaGraph.cpp
+++ b/src/apps/mplayerc/RealMediaGraph.cpp
@@ -107,7 +107,7 @@ bool CRealMediaPlayer::Init()
if (!dllpaths.IsEmpty()) {
char* s = DNew char[dllpaths.GetLength()+1];
- strcpy(s, CStringA(dllpaths));
+ strcpy_s(s, dllpaths.GetLength() + 1, CStringA(dllpaths));
for (int i = 0, j = strlen(s); i < j; i++) {
if (s[i] == '|') {
s[i] = '\0';
@@ -241,7 +241,7 @@ char* AllocateErrorMessage(const char* msg)
if (len > 0) {
errmsg = (char*)CoTaskMemAlloc(len+1);
if (errmsg) {
- strcpy(errmsg, msg);
+ strcpy_s(errmsg, len + 1, msg);
}
}
return errmsg;
diff --git a/src/apps/mplayerc/ShaderAutoCompleteDlg.cpp b/src/apps/mplayerc/ShaderAutoCompleteDlg.cpp
index d16563142..9e0941a6a 100644
--- a/src/apps/mplayerc/ShaderAutoCompleteDlg.cpp
+++ b/src/apps/mplayerc/ShaderAutoCompleteDlg.cpp
@@ -182,7 +182,7 @@ void CShaderAutoCompleteDlg::OnLbnSelchangeList1()
if (sl.GetCount() != 2) {
return;
}
- _tcscpy(m_ti.lpszText, sl.RemoveTail());
+ _tcscpy_s(m_ti.lpszText, countof(m_text), sl.RemoveTail());
CRect r;
GetWindowRect(r);
::SendMessage(m_hToolTipWnd, TTM_UPDATETIPTEXT, 0, (LPARAM)&m_ti);
diff --git a/src/filters/muxer/MatroskaMuxer/MatroskaFile.h b/src/filters/muxer/MatroskaMuxer/MatroskaFile.h
index 190542bf8..d86d7a715 100644
--- a/src/filters/muxer/MatroskaMuxer/MatroskaFile.h
+++ b/src/filters/muxer/MatroskaMuxer/MatroskaFile.h
@@ -71,7 +71,7 @@ namespace MatroskaWriter
}
CBinary& Set(CStringA str) {
SetCount(str.GetLength()+1);
- strcpy((char*)GetData(), str);
+ strcpy_s((char*)GetData(), str.GetLength() + 1, str);
return(*this);
}
// CBinary& Set(CStringA str) {SetCount(str.GetLength()); memcpy((char*)GetData(), str, str.GetLength()); return(*this);}
diff --git a/src/filters/parser/BaseSplitter/BaseSplitter.cpp b/src/filters/parser/BaseSplitter/BaseSplitter.cpp
index daf9e7a8b..63a7b7ccb 100644
--- a/src/filters/parser/BaseSplitter/BaseSplitter.cpp
+++ b/src/filters/parser/BaseSplitter/BaseSplitter.cpp
@@ -243,7 +243,7 @@ HRESULT CBaseSplitterOutputPin::SetName(LPCWSTR pName)
}
m_pName = DNew WCHAR[wcslen(pName)+1];
CheckPointer(m_pName, E_OUTOFMEMORY);
- wcscpy(m_pName, pName);
+ wcscpy_s(m_pName, wcslen(pName) + 1, pName);
return S_OK;
}
@@ -1284,7 +1284,7 @@ STDMETHODIMP CBaseSplitterFilter::GetCurFile(LPOLESTR* ppszFileName, AM_MEDIA_TY
if (!(*ppszFileName)) {
return E_OUTOFMEMORY;
}
- wcscpy(*ppszFileName, m_fn);
+ wcscpy_s(*ppszFileName, m_fn.GetLength() + 1, m_fn);
return S_OK;
}
diff --git a/src/filters/parser/RealMediaSplitter/RealMediaSplitter.cpp b/src/filters/parser/RealMediaSplitter/RealMediaSplitter.cpp
index 32defdcbe..b31cc49de 100644
--- a/src/filters/parser/RealMediaSplitter/RealMediaSplitter.cpp
+++ b/src/filters/parser/RealMediaSplitter/RealMediaSplitter.cpp
@@ -708,17 +708,21 @@ bool CRealMediaSplitterFilter::DemuxLoop()
p->rtStart = 0;
p->rtStop = 1;
- p->SetCount((4+1) + (2+4+(s.name.GetLength()+1)*2) + (2+4+s.data.GetLength()));
+ size_t count = (4+1) + (2+4+(s.name.GetLength()+1)*2) + (2+4+s.data.GetLength());
+ p->SetCount(count);
BYTE* ptr = p->GetData();
- strcpy((char*)ptr, "GAB2");
+ strcpy_s((char*)ptr, count, "GAB2");
ptr += 4+1;
+ count -= 4+1;
*(WORD*)ptr = 2;
ptr += 2;
+ count -= 2;
*(DWORD*)ptr = (s.name.GetLength()+1)*2;
ptr += 4;
- wcscpy((WCHAR*)ptr, CStringW(s.name));
+ count -= 4;
+ wcscpy_s((WCHAR*)ptr, count / 2, CStringW(s.name));
ptr += (s.name.GetLength()+1)*2;
*(WORD*)ptr = 4;
diff --git a/src/filters/reader/CDDAReader/CDDAReader.cpp b/src/filters/reader/CDDAReader/CDDAReader.cpp
index 817bf5b90..2bc895c9b 100644
--- a/src/filters/reader/CDDAReader/CDDAReader.cpp
+++ b/src/filters/reader/CDDAReader/CDDAReader.cpp
@@ -135,7 +135,7 @@ STDMETHODIMP CCDDAReader::GetCurFile(LPOLESTR* ppszFileName, AM_MEDIA_TYPE* pmt)
return E_OUTOFMEMORY;
}
- wcscpy(*ppszFileName, m_fn);
+ wcscpy_s(*ppszFileName, m_fn.GetLength() + 1, m_fn);
return S_OK;
}
diff --git a/src/filters/reader/CDXAReader/CDXAReader.cpp b/src/filters/reader/CDXAReader/CDXAReader.cpp
index 183410e50..b7163ffa9 100644
--- a/src/filters/reader/CDXAReader/CDXAReader.cpp
+++ b/src/filters/reader/CDXAReader/CDXAReader.cpp
@@ -211,7 +211,7 @@ STDMETHODIMP CCDXAReader::GetCurFile(LPOLESTR* ppszFileName, AM_MEDIA_TYPE* pmt)
return E_OUTOFMEMORY;
}
- wcscpy(*ppszFileName, m_fn);
+ wcscpy_s(*ppszFileName, m_fn.GetLength() + 1, m_fn);
return S_OK;
}
diff --git a/src/filters/reader/UDPReader/UDPReader.cpp b/src/filters/reader/UDPReader/UDPReader.cpp
index a149be7b3..083f873b1 100644
--- a/src/filters/reader/UDPReader/UDPReader.cpp
+++ b/src/filters/reader/UDPReader/UDPReader.cpp
@@ -123,7 +123,7 @@ STDMETHODIMP CUDPReader::GetCurFile(LPOLESTR* ppszFileName, AM_MEDIA_TYPE* pmt)
return E_OUTOFMEMORY;
}
- wcscpy(*ppszFileName, m_fn);
+ wcscpy_s(*ppszFileName, m_fn.GetLength() + 1, m_fn);
return S_OK;
}
diff --git a/src/filters/reader/VTSReader/VTSReader.cpp b/src/filters/reader/VTSReader/VTSReader.cpp
index 2a1554005..242382e89 100644
--- a/src/filters/reader/VTSReader/VTSReader.cpp
+++ b/src/filters/reader/VTSReader/VTSReader.cpp
@@ -149,7 +149,7 @@ STDMETHODIMP CVTSReader::GetCurFile(LPOLESTR* ppszFileName, AM_MEDIA_TYPE* pmt)
return E_OUTOFMEMORY;
}
- wcscpy(*ppszFileName, m_fn);
+ wcscpy_s(*ppszFileName, m_fn.GetLength() + 1, m_fn);
return S_OK;
}
diff --git a/src/filters/source/FLICSource/FLICSource.cpp b/src/filters/source/FLICSource/FLICSource.cpp
index 68d7c8001..2459bc566 100644
--- a/src/filters/source/FLICSource/FLICSource.cpp
+++ b/src/filters/source/FLICSource/FLICSource.cpp
@@ -141,7 +141,7 @@ STDMETHODIMP CFLICSource::GetCurFile(LPOLESTR* ppszFileName, AM_MEDIA_TYPE* pmt)
return E_OUTOFMEMORY;
}
- wcscpy(*ppszFileName, m_fn);
+ wcscpy_s(*ppszFileName, m_fn.GetLength() + 1, m_fn);
return S_OK;
}
diff --git a/src/filters/source/ShoutcastSource/ShoutcastSource.cpp b/src/filters/source/ShoutcastSource/ShoutcastSource.cpp
index 7a5da7963..cbd51e111 100644
--- a/src/filters/source/ShoutcastSource/ShoutcastSource.cpp
+++ b/src/filters/source/ShoutcastSource/ShoutcastSource.cpp
@@ -196,7 +196,7 @@ STDMETHODIMP CShoutcastSource::GetCurFile(LPOLESTR* ppszFileName, AM_MEDIA_TYPE*
return E_OUTOFMEMORY;
}
- wcscpy(*ppszFileName, m_fn);
+ wcscpy_s(*ppszFileName, m_fn.GetLength() + 1, m_fn);
return S_OK;
}
diff --git a/src/filters/source/SubtitleSource/SubtitleSource.cpp b/src/filters/source/SubtitleSource/SubtitleSource.cpp
index 16f7ac79a..37f485c8f 100644
--- a/src/filters/source/SubtitleSource/SubtitleSource.cpp
+++ b/src/filters/source/SubtitleSource/SubtitleSource.cpp
@@ -201,7 +201,7 @@ STDMETHODIMP CSubtitleSource::GetCurFile(LPOLESTR* ppszFileName, AM_MEDIA_TYPE*
return E_OUTOFMEMORY;
}
- wcscpy(*ppszFileName, m_fn);
+ wcscpy_s(*ppszFileName, m_fn.GetLength() + 1, m_fn);
return S_OK;
}
diff --git a/src/filters/switcher/AudioSwitcher/StreamSwitcher.cpp b/src/filters/switcher/AudioSwitcher/StreamSwitcher.cpp
index bc1a6bc88..d41bba74a 100644
--- a/src/filters/switcher/AudioSwitcher/StreamSwitcher.cpp
+++ b/src/filters/switcher/AudioSwitcher/StreamSwitcher.cpp
@@ -617,7 +617,7 @@ HRESULT CStreamSwitcherInputPin::CompleteConnect(IPin* pReceivePin)
WCHAR* pName = DNew WCHAR[fileName.GetLength()+1];
if (pName) {
- wcscpy(pName, fileName);
+ wcscpy_s(pName, fileName.GetLength() + 1, fileName);
if (m_pName) {
delete [] m_pName;
}
@@ -1440,7 +1440,7 @@ STDMETHODIMP CStreamSwitcherFilter::Info(long lIndex, AM_MEDIA_TYPE** ppmt, DWOR
if (ppszName) {
*ppszName = (WCHAR*)CoTaskMemAlloc((wcslen(pPin->Name())+1)*sizeof(WCHAR));
if (*ppszName) {
- wcscpy(*ppszName, pPin->Name());
+ wcscpy_s(*ppszName, wcslen(pPin->Name()) + 1, pPin->Name());
}
}