diff options
author | XhmikosR <xhmikosr@users.sourceforge.net> | 2010-08-16 18:06:13 +0400 |
---|---|---|
committer | XhmikosR <xhmikosr@users.sourceforge.net> | 2010-08-16 18:06:13 +0400 |
commit | 73d74d54ef543e2b2e2498177c9681996817c29e (patch) | |
tree | a226225a25005eb5bc5587b56f015872187fade8 /src | |
parent | 8bf55c83af1d551378c8b6548e00fb178b857fc5 (diff) |
mpcinfo: -fixed warnings was about using functions without any protection from buffer overflows [Patch by Alexx999]
-added MSVC2010 project and solution files
git-svn-id: https://mpc-hc.svn.sourceforge.net/svnroot/mpc-hc/trunk@2255 10f7b99b-c216-0410-bff0-8a66a9350fd8
Diffstat (limited to 'src')
-rw-r--r-- | src/apps/mpcinfo/mpcinfo.cpp | 29 | ||||
-rw-r--r-- | src/apps/mpcinfo/mpcinfo.vcxproj | 145 | ||||
-rw-r--r-- | src/apps/mpcinfo/mpcinfo.vcxproj.filters | 46 | ||||
-rw-r--r-- | src/apps/mpcinfo/mpcinfo_2010.sln | 25 | ||||
-rw-r--r-- | src/filters/BaseClasses/BaseClasses.vcxproj | 12 |
5 files changed, 246 insertions, 11 deletions
diff --git a/src/apps/mpcinfo/mpcinfo.cpp b/src/apps/mpcinfo/mpcinfo.cpp index 4c24ca24f..8d5468117 100644 --- a/src/apps/mpcinfo/mpcinfo.cpp +++ b/src/apps/mpcinfo/mpcinfo.cpp @@ -168,7 +168,8 @@ extern "C" int WINAPI file(HWND,HWND,char *data,char*,BOOL,BOOL) if(fn.IsEmpty())
return 1;
- sprintf(data, _T("%s"), fn);
+ size_t len = strlen(data);
+ sprintf_s(data,len+1, _T("%s"), fn);
return 3;
}
@@ -189,7 +190,8 @@ extern "C" int WINAPI size(HWND,HWND,char *data,char*,BOOL,BOOL) size.QuadPart = 0;
size.LowPart = GetFileSize(hFile, (DWORD*)&size.HighPart);
- sprintf(data, _T("%I64d"), size.QuadPart);
+ size_t len = strlen(data);
+ sprintf_s(data,len+1, _T("%I64d"), size.QuadPart);
CloseHandle(hFile);
@@ -207,15 +209,16 @@ extern "C" int WINAPI pos(HWND,HWND,char *data,char*,BOOL,BOOL) if(FAILED(pMS->GetCurrentPosition(&pos)) || FAILED(pMS->GetDuration(&dur)))
return 1;
+ size_t len = strlen(data);
if(dur > 10000000i64*60*60)
{
- sprintf(data, _T("%02d:%02d:%02d/%02d:%02d:%02d"),
+ sprintf_s(data,len+1, _T("%02d:%02d:%02d/%02d:%02d:%02d"),
(int)(pos/10000000/60/60), (int)(pos/10000000/60)%60, (int)(pos/10000000)%60,
(int)(dur/10000000/60/60), (int)(dur/10000000/60)%60, (int)(dur/10000000)%60);
}
else
{
- sprintf(data, _T("%02d:%02d/%02d:%02d"),
+ sprintf_s(data,len+1, _T("%02d:%02d/%02d:%02d"),
(int)(pos/10000000/60)%60, (int)(pos/10000000)%60,
(int)(dur/10000000/60)%60, (int)(dur/10000000)%60);
}
@@ -235,14 +238,16 @@ extern "C" int WINAPI info(HWND,HWND,char *data,char*,BOOL,BOOL) if(pos(0,0,data,0,0,0)!=3) return 1;
ret += data;
- strcpy(data, ret);
+ size_t len = strlen(data) + 1;
+ strcpy_s(data,len, ret);
return 3;
}
extern "C" int WINAPI stopped(HWND,HWND,char *data,char*,BOOL,BOOL)
{
- sprintf(data, _T("2"));
+ size_t len = strlen(data) +1;
+ sprintf_s(data,len+1, _T("2"));
CComPtr<IFilterGraph> pFG;
CComQIPtr<IMediaControl> pMC;
@@ -250,14 +255,15 @@ extern "C" int WINAPI stopped(HWND,HWND,char *data,char*,BOOL,BOOL) if(!GetFilterGraph(&pFG) || !(pMC = pFG) || FAILED(pMC->GetState(0, &fs)))
return 3;
- sprintf(data, _T("%d"), fs == State_Stopped ? 1 : 0);
+ sprintf_s(data,len, _T("%d"), fs == State_Stopped ? 1 : 0);
return 3;
}
extern "C" int WINAPI paused(HWND,HWND,char *data,char*,BOOL,BOOL)
{
- sprintf(data, _T("2"));
+ size_t len = strlen(data) +1;
+ sprintf_s(data,len, _T("2"));
CComPtr<IFilterGraph> pFG;
CComQIPtr<IMediaControl> pMC;
@@ -265,14 +271,15 @@ extern "C" int WINAPI paused(HWND,HWND,char *data,char*,BOOL,BOOL) if(!GetFilterGraph(&pFG) || !(pMC = pFG) || FAILED(pMC->GetState(0, &fs)))
return 3;
- sprintf(data, _T("%d"), fs == State_Paused ? 1 : 0);
+ sprintf_s(data,len, _T("%d"), fs == State_Paused ? 1 : 0);
return 3;
}
extern "C" int WINAPI running(HWND,HWND,char *data,char*,BOOL,BOOL)
{
- sprintf(data, _T("2"));
+ size_t len = strlen(data) +1;
+ sprintf_s(data,len, _T("2"));
CComPtr<IFilterGraph> pFG;
CComQIPtr<IMediaControl> pMC;
@@ -280,7 +287,7 @@ extern "C" int WINAPI running(HWND,HWND,char *data,char*,BOOL,BOOL) if(!GetFilterGraph(&pFG) || !(pMC = pFG) || FAILED(pMC->GetState(0, &fs)))
return 3;
- sprintf(data, _T("%d"), fs == State_Running ? 1 : 0);
+ sprintf_s(data,len, _T("%d"), fs == State_Running ? 1 : 0);
return 3;
}
diff --git a/src/apps/mpcinfo/mpcinfo.vcxproj b/src/apps/mpcinfo/mpcinfo.vcxproj new file mode 100644 index 000000000..e8e89078f --- /dev/null +++ b/src/apps/mpcinfo/mpcinfo.vcxproj @@ -0,0 +1,145 @@ +<?xml version="1.0" encoding="utf-8"?>
+<Project DefaultTargets="Build" ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
+ <ItemGroup Label="ProjectConfigurations">
+ <ProjectConfiguration Include="Debug|Win32">
+ <Configuration>Debug</Configuration>
+ <Platform>Win32</Platform>
+ </ProjectConfiguration>
+ <ProjectConfiguration Include="Release|Win32">
+ <Configuration>Release</Configuration>
+ <Platform>Win32</Platform>
+ </ProjectConfiguration>
+ </ItemGroup>
+ <PropertyGroup Label="Globals">
+ <ProjectGuid>{AF754B6B-75F8-4A8A-9A98-2E34DB02D4A8}</ProjectGuid>
+ <RootNamespace>mpcinfo</RootNamespace>
+ <Keyword>MFCDLLProj</Keyword>
+ </PropertyGroup>
+ <Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
+ <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
+ <ConfigurationType>DynamicLibrary</ConfigurationType>
+ <UseOfMfc>Static</UseOfMfc>
+ <CharacterSet>MultiByte</CharacterSet>
+ </PropertyGroup>
+ <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
+ <ConfigurationType>DynamicLibrary</ConfigurationType>
+ <UseOfMfc>Dynamic</UseOfMfc>
+ <CharacterSet>MultiByte</CharacterSet>
+ </PropertyGroup>
+ <Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
+ <ImportGroup Label="ExtensionSettings">
+ </ImportGroup>
+ <ImportGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="PropertySheets">
+ <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
+ <Import Project="..\..\common.props" />
+ <Import Project="..\..\release.props" />
+ </ImportGroup>
+ <ImportGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="PropertySheets">
+ <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
+ <Import Project="..\..\common.props" />
+ <Import Project="..\..\debug.props" />
+ </ImportGroup>
+ <PropertyGroup Label="UserMacros" />
+ <PropertyGroup>
+ <_ProjectFileVersion>10.0.30319.1</_ProjectFileVersion>
+ <OutDir Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">$(SolutionDir)bin\$(Configuration)_$(Platform)\</OutDir>
+ <LinkIncremental Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">true</LinkIncremental>
+ <OutDir Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">$(SolutionDir)bin\$(Configuration)_$(Platform)\</OutDir>
+ <CodeAnalysisRuleSet Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">AllRules.ruleset</CodeAnalysisRuleSet>
+ <CodeAnalysisRules Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" />
+ <CodeAnalysisRuleAssemblies Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" />
+ <CodeAnalysisRuleSet Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">AllRules.ruleset</CodeAnalysisRuleSet>
+ <CodeAnalysisRules Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" />
+ <CodeAnalysisRuleAssemblies Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" />
+ </PropertyGroup>
+ <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
+ <Midl>
+ <PreprocessorDefinitions>_DEBUG;%(PreprocessorDefinitions)</PreprocessorDefinitions>
+ <MkTypLibCompatible>false</MkTypLibCompatible>
+ </Midl>
+ <ClCompile>
+ <AdditionalIncludeDirectories>..\..\filters\BaseClasses;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
+ <PreprocessorDefinitions>WIN32;_WINDOWS;_DEBUG;_USRDLL;_CRT_SECURE_NO_WARNINGS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
+ <MinimalRebuild>true</MinimalRebuild>
+ <BasicRuntimeChecks>EnableFastChecks</BasicRuntimeChecks>
+ <RuntimeLibrary>MultiThreadedDebugDLL</RuntimeLibrary>
+ <PrecompiledHeader>Use</PrecompiledHeader>
+ </ClCompile>
+ <ResourceCompile>
+ <PreprocessorDefinitions>_DEBUG;%(PreprocessorDefinitions)</PreprocessorDefinitions>
+ <Culture>0x0409</Culture>
+ <AdditionalIncludeDirectories>$(IntDir);%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
+ </ResourceCompile>
+ <Link>
+ <AdditionalDependencies>BaseClasses.lib;Delayimp.lib;Winmm.lib;%(AdditionalDependencies)</AdditionalDependencies>
+ <AdditionalLibraryDirectories>bin/lib/$(Configuration)_$(Platform);%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
+ <IgnoreSpecificDefaultLibraries>LIBCMTD.lib;%(IgnoreSpecificDefaultLibraries)</IgnoreSpecificDefaultLibraries>
+ <ModuleDefinitionFile>.\mpcinfo.def</ModuleDefinitionFile>
+ <GenerateDebugInformation>true</GenerateDebugInformation>
+ <SubSystem>Windows</SubSystem>
+ <RandomizedBaseAddress>false</RandomizedBaseAddress>
+ <DataExecutionPrevention>
+ </DataExecutionPrevention>
+ <ImportLibrary>$(OutDir)mpcinfo.lib</ImportLibrary>
+ <TargetMachine>MachineX86</TargetMachine>
+ </Link>
+ </ItemDefinitionGroup>
+ <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
+ <Midl>
+ <PreprocessorDefinitions>NDEBUG;%(PreprocessorDefinitions)</PreprocessorDefinitions>
+ <MkTypLibCompatible>false</MkTypLibCompatible>
+ </Midl>
+ <ClCompile>
+ <AdditionalOptions>/MP %(AdditionalOptions)</AdditionalOptions>
+ <AdditionalIncludeDirectories>..\..\filters\BaseClasses;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
+ <PreprocessorDefinitions>WIN32;_WINDOWS;NDEBUG;_USRDLL;_CRT_SECURE_NO_WARNINGS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
+ <RuntimeLibrary>MultiThreaded</RuntimeLibrary>
+ <PrecompiledHeader>Use</PrecompiledHeader>
+ <DebugInformationFormat>ProgramDatabase</DebugInformationFormat>
+ </ClCompile>
+ <ResourceCompile>
+ <PreprocessorDefinitions>NDEBUG;%(PreprocessorDefinitions)</PreprocessorDefinitions>
+ <Culture>0x0409</Culture>
+ <AdditionalIncludeDirectories>$(IntDir);%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
+ </ResourceCompile>
+ <Link>
+ <AdditionalDependencies>BaseClasses.lib;Delayimp.lib;Winmm.lib;%(AdditionalDependencies)</AdditionalDependencies>
+ <AdditionalLibraryDirectories>bin/lib/$(Configuration)_$(Platform);%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
+ <IgnoreSpecificDefaultLibraries>%(IgnoreSpecificDefaultLibraries)</IgnoreSpecificDefaultLibraries>
+ <ModuleDefinitionFile>.\mpcinfo.def</ModuleDefinitionFile>
+ <DelayLoadDLLs>oleacc.dll;%(DelayLoadDLLs)</DelayLoadDLLs>
+ <SubSystem>Windows</SubSystem>
+ <RandomizedBaseAddress>false</RandomizedBaseAddress>
+ <DataExecutionPrevention>true</DataExecutionPrevention>
+ <ImportLibrary>$(OutDir)mpcinfo.lib</ImportLibrary>
+ <TargetMachine>MachineX86</TargetMachine>
+ </Link>
+ </ItemDefinitionGroup>
+ <ItemGroup>
+ <ClCompile Include="mpcinfo.cpp" />
+ <ClCompile Include="stdafx.cpp">
+ <PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">Create</PrecompiledHeader>
+ <PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">Create</PrecompiledHeader>
+ </ClCompile>
+ </ItemGroup>
+ <ItemGroup>
+ <None Include="mpcinfo.def" />
+ </ItemGroup>
+ <ItemGroup>
+ <ClInclude Include="mpcinfo.h" />
+ <ClInclude Include="Resource.h" />
+ <ClInclude Include="stdafx.h" />
+ </ItemGroup>
+ <ItemGroup>
+ <ResourceCompile Include="mpcinfo.rc" />
+ </ItemGroup>
+ <ItemGroup>
+ <ProjectReference Include="..\..\filters\BaseClasses\BaseClasses.vcxproj">
+ <Project>{e8a3f6fa-ae1c-4c8e-a0b6-9c8480324eaa}</Project>
+ <ReferenceOutputAssembly>false</ReferenceOutputAssembly>
+ </ProjectReference>
+ </ItemGroup>
+ <Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
+ <ImportGroup Label="ExtensionTargets">
+ </ImportGroup>
+</Project>
\ No newline at end of file diff --git a/src/apps/mpcinfo/mpcinfo.vcxproj.filters b/src/apps/mpcinfo/mpcinfo.vcxproj.filters new file mode 100644 index 000000000..34c3cd638 --- /dev/null +++ b/src/apps/mpcinfo/mpcinfo.vcxproj.filters @@ -0,0 +1,46 @@ +<?xml version="1.0" encoding="utf-8"?>
+<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
+ <ItemGroup>
+ <Filter Include="Source Files">
+ <UniqueIdentifier>{3e9b6a2e-a486-4295-8f38-4256fe575e8c}</UniqueIdentifier>
+ <Extensions>cpp;c;cxx;def;odl;idl;hpj;bat;asm</Extensions>
+ </Filter>
+ <Filter Include="Header Files">
+ <UniqueIdentifier>{0ab878f7-9669-49f7-a15c-f63a116445a2}</UniqueIdentifier>
+ <Extensions>h;hpp;hxx;hm;inl;inc</Extensions>
+ </Filter>
+ <Filter Include="Resource Files">
+ <UniqueIdentifier>{3b1c4a4c-1f79-4a00-82dd-78aced7c2c9e}</UniqueIdentifier>
+ <Extensions>rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe</Extensions>
+ </Filter>
+ </ItemGroup>
+ <ItemGroup>
+ <ClCompile Include="mpcinfo.cpp">
+ <Filter>Source Files</Filter>
+ </ClCompile>
+ <ClCompile Include="stdafx.cpp">
+ <Filter>Source Files</Filter>
+ </ClCompile>
+ </ItemGroup>
+ <ItemGroup>
+ <None Include="mpcinfo.def">
+ <Filter>Source Files</Filter>
+ </None>
+ </ItemGroup>
+ <ItemGroup>
+ <ClInclude Include="mpcinfo.h">
+ <Filter>Header Files</Filter>
+ </ClInclude>
+ <ClInclude Include="Resource.h">
+ <Filter>Header Files</Filter>
+ </ClInclude>
+ <ClInclude Include="stdafx.h">
+ <Filter>Header Files</Filter>
+ </ClInclude>
+ </ItemGroup>
+ <ItemGroup>
+ <ResourceCompile Include="mpcinfo.rc">
+ <Filter>Resource Files</Filter>
+ </ResourceCompile>
+ </ItemGroup>
+</Project>
\ No newline at end of file diff --git a/src/apps/mpcinfo/mpcinfo_2010.sln b/src/apps/mpcinfo/mpcinfo_2010.sln new file mode 100644 index 000000000..5158058b7 --- /dev/null +++ b/src/apps/mpcinfo/mpcinfo_2010.sln @@ -0,0 +1,25 @@ +Microsoft Visual Studio Solution File, Format Version 11.00
+# Visual Studio 2010
+Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "mpcinfo", "mpcinfo.vcxproj", "{AF754B6B-75F8-4A8A-9A98-2E34DB02D4A8}"
+EndProject
+Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "BaseClasses", "..\..\filters\BaseClasses\BaseClasses.vcxproj", "{E8A3F6FA-AE1C-4C8E-A0B6-9C8480324EAA}"
+EndProject
+Global
+ GlobalSection(SolutionConfigurationPlatforms) = preSolution
+ Debug|Win32 = Debug|Win32
+ Release|Win32 = Release|Win32
+ EndGlobalSection
+ GlobalSection(ProjectConfigurationPlatforms) = postSolution
+ {AF754B6B-75F8-4A8A-9A98-2E34DB02D4A8}.Debug|Win32.ActiveCfg = Debug|Win32
+ {AF754B6B-75F8-4A8A-9A98-2E34DB02D4A8}.Debug|Win32.Build.0 = Debug|Win32
+ {AF754B6B-75F8-4A8A-9A98-2E34DB02D4A8}.Release|Win32.ActiveCfg = Release|Win32
+ {AF754B6B-75F8-4A8A-9A98-2E34DB02D4A8}.Release|Win32.Build.0 = Release|Win32
+ {E8A3F6FA-AE1C-4C8E-A0B6-9C8480324EAA}.Debug|Win32.ActiveCfg = Debug|Win32
+ {E8A3F6FA-AE1C-4C8E-A0B6-9C8480324EAA}.Debug|Win32.Build.0 = Debug|Win32
+ {E8A3F6FA-AE1C-4C8E-A0B6-9C8480324EAA}.Release|Win32.ActiveCfg = Release|Win32
+ {E8A3F6FA-AE1C-4C8E-A0B6-9C8480324EAA}.Release|Win32.Build.0 = Release|Win32
+ EndGlobalSection
+ GlobalSection(SolutionProperties) = preSolution
+ HideSolutionNode = FALSE
+ EndGlobalSection
+EndGlobal
diff --git a/src/filters/BaseClasses/BaseClasses.vcxproj b/src/filters/BaseClasses/BaseClasses.vcxproj index 5b9739622..a46f27c49 100644 --- a/src/filters/BaseClasses/BaseClasses.vcxproj +++ b/src/filters/BaseClasses/BaseClasses.vcxproj @@ -70,6 +70,18 @@ <PropertyGroup Label="UserMacros" />
<PropertyGroup>
<_ProjectFileVersion>10.0.30319.1</_ProjectFileVersion>
+ <CodeAnalysisRuleSet Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">AllRules.ruleset</CodeAnalysisRuleSet>
+ <CodeAnalysisRules Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" />
+ <CodeAnalysisRuleAssemblies Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" />
+ <CodeAnalysisRuleSet Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">AllRules.ruleset</CodeAnalysisRuleSet>
+ <CodeAnalysisRules Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" />
+ <CodeAnalysisRuleAssemblies Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" />
+ <CodeAnalysisRuleSet Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">AllRules.ruleset</CodeAnalysisRuleSet>
+ <CodeAnalysisRules Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" />
+ <CodeAnalysisRuleAssemblies Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" />
+ <CodeAnalysisRuleSet Condition="'$(Configuration)|$(Platform)'=='Release|x64'">AllRules.ruleset</CodeAnalysisRuleSet>
+ <CodeAnalysisRules Condition="'$(Configuration)|$(Platform)'=='Release|x64'" />
+ <CodeAnalysisRuleAssemblies Condition="'$(Configuration)|$(Platform)'=='Release|x64'" />
</PropertyGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
<ClCompile>
|