diff options
| author | kahashimoto-ms <[email protected]> | 2023-04-21 14:16:04 -0700 |
|---|---|---|
| committer | GitHub <[email protected]> | 2023-04-21 14:16:04 -0700 |
| commit | 10a103a40e75f4b98092c99e6f1b9ff9c3b20504 (patch) | |
| tree | 35636395dbae6215be16baa8ea7a0acfd25eb7a3 /network | |
| parent | 24f196d40fee8c6fb48618ac7c3bc4ff00cdcbe5 (diff) | |
Ndis mux inf violations (#973)
* Delete deprecated directives DelFiles and DelService
* Add PnpLockdown=1 to the version section of the inf
* Add catalog file in muxp.inf
* Add PnpLockdown=1 to the version section of mux_mp.inf
* Add catalog file in mux_mp.inf
* include mux_mp.inf in the muxvaln project
* include muxp.inf in mux project. Add mux.dll as file to package. Note as of now the Notifyob proj must be built then mux.dll must be moved to the Project Directory
* Changed all DIRID to 13
* change all DIRID to 13
* Create build dependency so that mux.dll is generated before other projects.
* Include the mux.dll from the notifyob project into the build package
* Delete comments
* Edit muxp.inf so that DIRID 13 is used for installation above certain releases
* Change MUXP->MUXP_NC and MUXP_Update->MUXP. This makes the updated version look like the default. Old version called _NC for non-compliant
* Edit muxp.inf so that MUXP comes before MUXP_NC
* Make same edits to mux_mp.inf
* Enable the Control-flow Enforcement Technology (CET) Shadow Stack mitigation
* Fix Warning from runing Prefast static analysis
* Fix more warnings from running Prefast
* Use stampinf ARCH variable to replace all the hard coded architecures in mux_mp.inf
* Use stampinf ARCH variable to replace all the hard coded architecures in muxp.inf
* Delete extra comma typo
* Change encoding of mux_mp.inf to UTF-16 LE
* Change encoding of muxp.inf to UTF-16 LE
* Add the correct build number for installing network drivers with Dlls and upate comment in muxp.inf
* Add the correct build number for installing network drivers with Dlls and upate comment in mux_mp.inf
* Change all instances of MUXP tp MUXMP in mux_mp.inf
* Change Brace style to match existing code
* Fix mistakes returning win32 err for HRESULT, and leaking memory
* Fix mux_mp.inf to payload muxvlan.sys
* Edit to sln and vcxproj files to edit how build directories are made
* Edit vcxproj files to package correct files. Edit Target name for muxvlan project to be mux so the same inf files can be used for both projects
* Remove comments
* Fix mux_mp.inf to payload mux.sys
* fix mistakes returning win32 err instead of HRESULT, and leaking mem
* Change comment on mux_mp.inf explaining why build 25341 is used
* Free lpszBindName before return.
Diffstat (limited to 'network')
| -rw-r--r-- | network/ndis/mux/driver/60/miniport.c | 26 | ||||
| -rw-r--r-- | network/ndis/mux/driver/60/mux_mp.inf | bin | 4028 -> 7718 bytes | |||
| -rw-r--r-- | network/ndis/mux/driver/60/muxp.inf | bin | 5044 -> 7380 bytes | |||
| -rw-r--r-- | network/ndis/mux/driver/60/novlan/mux.vcxproj | 16 | ||||
| -rw-r--r-- | network/ndis/mux/driver/60/novlan/mux.vcxproj.Filters | 8 | ||||
| -rw-r--r-- | network/ndis/mux/driver/60/vlan/muxvlan.vcxproj | 24 | ||||
| -rw-r--r-- | network/ndis/mux/driver/60/vlan/muxvlan.vcxproj.Filters | 8 | ||||
| -rw-r--r-- | network/ndis/mux/mux.sln | 33 | ||||
| -rw-r--r-- | network/ndis/mux/notifyob/adapter.cpp | 41 | ||||
| -rw-r--r-- | network/ndis/mux/notifyob/common.cpp | 22 | ||||
| -rw-r--r-- | network/ndis/mux/notifyob/dllmain.cpp | 2 | ||||
| -rw-r--r-- | network/ndis/mux/notifyob/notify.cpp | 10 | ||||
| -rw-r--r-- | network/ndis/mux/notifyob/virtual.cpp | 34 |
13 files changed, 175 insertions, 49 deletions
diff --git a/network/ndis/mux/driver/60/miniport.c b/network/ndis/mux/driver/60/miniport.c index e0c3e380..f30c4b62 100644 --- a/network/ndis/mux/driver/60/miniport.c +++ b/network/ndis/mux/driver/60/miniport.c @@ -710,25 +710,23 @@ Return Value: NDIS_STATISTICS_FLAGS_VALID_RCV_ERROR | NDIS_STATISTICS_FLAGS_VALID_XMIT_ERROR; - StatisticsInfo.ifInDiscards = pVElan->RcvCrcErrors + - pVElan->RcvAlignmentErrors + - pVElan->RcvResourceErrors + - pVElan->RcvDmaOverrunErrors + - pVElan->RcvRuntErrors; + StatisticsInfo.ifInDiscards = + (ULONG64)pVElan->RcvCrcErrors + + (ULONG64)pVElan->RcvAlignmentErrors + + (ULONG64)pVElan->RcvResourceErrors + + (ULONG64)pVElan->RcvDmaOverrunErrors + + (ULONG64)pVElan->RcvRuntErrors; #if IEEE_VLAN_SUPPORT - StatisticsInfo.ifInDiscards += (pVElan->RcvVlanIdErrors + - pVElan->RcvFormatErrors); + StatisticsInfo.ifInDiscards += ((ULONG64)pVElan->RcvVlanIdErrors + (ULONG64)pVElan->RcvFormatErrors); #endif - StatisticsInfo.ifInErrors = StatisticsInfo.ifInDiscards - - pVElan->RcvResourceErrors; + (ULONG64)pVElan->RcvResourceErrors; - - StatisticsInfo.ifOutErrors = pVElan->TxAbortExcessCollisions + - pVElan->TxDmaUnderrun + - pVElan->TxLostCRS + - pVElan->TxLateCollisions; + StatisticsInfo.ifOutErrors = (ULONG64)pVElan->TxAbortExcessCollisions + + (ULONG64)pVElan->TxDmaUnderrun + + (ULONG64)pVElan->TxLostCRS + + (ULONG64)pVElan->TxLateCollisions; pInfo = &StatisticsInfo; break; diff --git a/network/ndis/mux/driver/60/mux_mp.inf b/network/ndis/mux/driver/60/mux_mp.inf Binary files differindex a8694916..f216ac16 100644 --- a/network/ndis/mux/driver/60/mux_mp.inf +++ b/network/ndis/mux/driver/60/mux_mp.inf diff --git a/network/ndis/mux/driver/60/muxp.inf b/network/ndis/mux/driver/60/muxp.inf Binary files differindex 637b2252..f9c4c04e 100644 --- a/network/ndis/mux/driver/60/muxp.inf +++ b/network/ndis/mux/driver/60/muxp.inf diff --git a/network/ndis/mux/driver/60/novlan/mux.vcxproj b/network/ndis/mux/driver/60/novlan/mux.vcxproj index 1eac45e0..758f450f 100644 --- a/network/ndis/mux/driver/60/novlan/mux.vcxproj +++ b/network/ndis/mux/driver/60/novlan/mux.vcxproj @@ -182,6 +182,7 @@ <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'"> <Link> <AdditionalDependencies>%(AdditionalDependencies);$(DDK_LIB_PATH)\ndis.lib</AdditionalDependencies> + <CETCompat>true</CETCompat> </Link> <ResourceCompile> <AdditionalIncludeDirectories>%(AdditionalIncludeDirectories);..</AdditionalIncludeDirectories> @@ -283,8 +284,21 @@ <ResourceCompile Include="..\mux.rc" /> </ItemGroup> <ItemGroup> + <FilesToPackage Include="$(TargetPath)"> + <PackageRelativeDirectory> + </PackageRelativeDirectory> + </FilesToPackage> + <FilesToPackage Include="$(SolutionDir)notifyob\x64\Release\mux.dll" Condition="'$(Configuration)|$(Platform)'=='Release|x64'"> + <PackageRelativeDirectory> + </PackageRelativeDirectory> + </FilesToPackage> + <FilesToPackage Include="$(SolutionDir)notifyob\x64\Debug\mux.dll" Condition="'$(Configuration)|$(Platform)'=='Debug|x64'"> + <PackageRelativeDirectory> + </PackageRelativeDirectory> + </FilesToPackage> <Inf Exclude="@(Inf)" Include="*.inf" /> - <FilesToPackage Include="$(TargetPath)" Condition="'$(ConfigurationType)'=='Driver' or '$(ConfigurationType)'=='DynamicLibrary'" /> + <Inf Include="..\muxp.inf" /> + <Inf Include="..\mux_mp.inf" /> </ItemGroup> <ItemGroup> <None Exclude="@(None)" Include="*.txt;*.htm;*.html" /> diff --git a/network/ndis/mux/driver/60/novlan/mux.vcxproj.Filters b/network/ndis/mux/driver/60/novlan/mux.vcxproj.Filters index ff91d92c..fe979006 100644 --- a/network/ndis/mux/driver/60/novlan/mux.vcxproj.Filters +++ b/network/ndis/mux/driver/60/novlan/mux.vcxproj.Filters @@ -37,4 +37,12 @@ <Filter>Resource Files</Filter> </ResourceCompile> </ItemGroup> + <ItemGroup> + <Inf Include="..\muxp.inf"> + <Filter>Driver Files</Filter> + </Inf> + <Inf Include="..\mux_mp.inf"> + <Filter>Driver Files</Filter> + </Inf> + </ItemGroup> </Project>
\ No newline at end of file diff --git a/network/ndis/mux/driver/60/vlan/muxvlan.vcxproj b/network/ndis/mux/driver/60/vlan/muxvlan.vcxproj index 423e7bde..eb2ff474 100644 --- a/network/ndis/mux/driver/60/vlan/muxvlan.vcxproj +++ b/network/ndis/mux/driver/60/vlan/muxvlan.vcxproj @@ -76,16 +76,16 @@ </ImportGroup> <ItemGroup Label="WrappedTaskItems" /> <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'"> - <TargetName>muxvlan</TargetName> + <TargetName>mux</TargetName> </PropertyGroup> <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'"> - <TargetName>muxvlan</TargetName> + <TargetName>mux</TargetName> </PropertyGroup> <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'"> - <TargetName>muxvlan</TargetName> + <TargetName>mux</TargetName> </PropertyGroup> <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'"> - <TargetName>muxvlan</TargetName> + <TargetName>mux</TargetName> </PropertyGroup> <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'"> <ClCompile> @@ -194,6 +194,7 @@ <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'"> <Link> <AdditionalDependencies>%(AdditionalDependencies);$(DDK_LIB_PATH)\ndis.lib</AdditionalDependencies> + <CETCompat>true</CETCompat> </Link> <ResourceCompile> <AdditionalIncludeDirectories>%(AdditionalIncludeDirectories);..</AdditionalIncludeDirectories> @@ -295,8 +296,21 @@ <ResourceCompile Include="..\mux.rc" /> </ItemGroup> <ItemGroup> + <FilesToPackage Include="$(TargetPath)"> + <PackageRelativeDirectory> + </PackageRelativeDirectory> + </FilesToPackage> + <FilesToPackage Include="$(SolutionDir)notifyob\x64\Release\mux.dll" Condition="'$(Configuration)|$(Platform)'=='Release|x64'"> + <PackageRelativeDirectory> + </PackageRelativeDirectory> + </FilesToPackage> + <FilesToPackage Include="$(SolutionDir)notifyob\x64\Debug\mux.dll" Condition="'$(Configuration)|$(Platform)'=='Debug|x64'"> + <PackageRelativeDirectory> + </PackageRelativeDirectory> + </FilesToPackage> <Inf Exclude="@(Inf)" Include="*.inf" /> - <FilesToPackage Include="$(TargetPath)" Condition="'$(ConfigurationType)'=='Driver' or '$(ConfigurationType)'=='DynamicLibrary'" /> + <Inf Include="..\muxp.inf" /> + <Inf Include="..\mux_mp.inf" /> </ItemGroup> <ItemGroup> <None Exclude="@(None)" Include="*.txt;*.htm;*.html" /> diff --git a/network/ndis/mux/driver/60/vlan/muxvlan.vcxproj.Filters b/network/ndis/mux/driver/60/vlan/muxvlan.vcxproj.Filters index 8bd7f5bf..64862290 100644 --- a/network/ndis/mux/driver/60/vlan/muxvlan.vcxproj.Filters +++ b/network/ndis/mux/driver/60/vlan/muxvlan.vcxproj.Filters @@ -37,4 +37,12 @@ <Filter>Resource Files</Filter> </ResourceCompile> </ItemGroup> + <ItemGroup> + <Inf Include="..\mux_mp.inf"> + <Filter>Driver Files</Filter> + </Inf> + <Inf Include="..\muxp.inf"> + <Filter>Driver Files</Filter> + </Inf> + </ItemGroup> </Project>
\ No newline at end of file diff --git a/network/ndis/mux/mux.sln b/network/ndis/mux/mux.sln index 551a21b7..bf78d7a4 100644 --- a/network/ndis/mux/mux.sln +++ b/network/ndis/mux/mux.sln @@ -1,7 +1,7 @@ Microsoft Visual Studio Solution File, Format Version 12.00 -# Visual Studio 2013 -VisualStudioVersion = 12.0 +# Visual Studio Version 17 +VisualStudioVersion = 17.4.33213.308 MinimumVisualStudioVersion = 12.0 Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Vlan", "Vlan", "{DFD0A31B-8B62-4BAA-998E-161F01D1A01B}" EndProject @@ -14,41 +14,47 @@ EndProject Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Notifyob", "Notifyob", "{2CAF23FF-28F8-4D52-B6C9-B76C8BCD5F67}" EndProject Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "muxvlan", "driver\60\vlan\muxvlan.vcxproj", "{015D7470-0FC8-4597-A67E-BD9C754F0681}" + ProjectSection(ProjectDependencies) = postProject + {92E3B437-C258-47FB-8856-D3FEA56A3BCC} = {92E3B437-C258-47FB-8856-D3FEA56A3BCC} + EndProjectSection EndProject Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "mux", "driver\60\novlan\mux.vcxproj", "{B2DE2C37-B3F2-491E-94AE-402A7B4D3308}" + ProjectSection(ProjectDependencies) = postProject + {92E3B437-C258-47FB-8856-D3FEA56A3BCC} = {92E3B437-C258-47FB-8856-D3FEA56A3BCC} + EndProjectSection EndProject Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "mux", "notifyob\mux.vcxproj", "{92E3B437-C258-47FB-8856-D3FEA56A3BCC}" EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|Win32 = Debug|Win32 - Release|Win32 = Release|Win32 Debug|x64 = Debug|x64 + Release|Win32 = Release|Win32 Release|x64 = Release|x64 EndGlobalSection GlobalSection(ProjectConfigurationPlatforms) = postSolution {015D7470-0FC8-4597-A67E-BD9C754F0681}.Debug|Win32.ActiveCfg = Debug|Win32 {015D7470-0FC8-4597-A67E-BD9C754F0681}.Debug|Win32.Build.0 = Debug|Win32 - {015D7470-0FC8-4597-A67E-BD9C754F0681}.Release|Win32.ActiveCfg = Release|Win32 - {015D7470-0FC8-4597-A67E-BD9C754F0681}.Release|Win32.Build.0 = Release|Win32 {015D7470-0FC8-4597-A67E-BD9C754F0681}.Debug|x64.ActiveCfg = Debug|x64 {015D7470-0FC8-4597-A67E-BD9C754F0681}.Debug|x64.Build.0 = Debug|x64 + {015D7470-0FC8-4597-A67E-BD9C754F0681}.Release|Win32.ActiveCfg = Release|Win32 + {015D7470-0FC8-4597-A67E-BD9C754F0681}.Release|Win32.Build.0 = Release|Win32 {015D7470-0FC8-4597-A67E-BD9C754F0681}.Release|x64.ActiveCfg = Release|x64 {015D7470-0FC8-4597-A67E-BD9C754F0681}.Release|x64.Build.0 = Release|x64 {B2DE2C37-B3F2-491E-94AE-402A7B4D3308}.Debug|Win32.ActiveCfg = Debug|Win32 {B2DE2C37-B3F2-491E-94AE-402A7B4D3308}.Debug|Win32.Build.0 = Debug|Win32 - {B2DE2C37-B3F2-491E-94AE-402A7B4D3308}.Release|Win32.ActiveCfg = Release|Win32 - {B2DE2C37-B3F2-491E-94AE-402A7B4D3308}.Release|Win32.Build.0 = Release|Win32 {B2DE2C37-B3F2-491E-94AE-402A7B4D3308}.Debug|x64.ActiveCfg = Debug|x64 {B2DE2C37-B3F2-491E-94AE-402A7B4D3308}.Debug|x64.Build.0 = Debug|x64 + {B2DE2C37-B3F2-491E-94AE-402A7B4D3308}.Release|Win32.ActiveCfg = Release|Win32 + {B2DE2C37-B3F2-491E-94AE-402A7B4D3308}.Release|Win32.Build.0 = Release|Win32 {B2DE2C37-B3F2-491E-94AE-402A7B4D3308}.Release|x64.ActiveCfg = Release|x64 {B2DE2C37-B3F2-491E-94AE-402A7B4D3308}.Release|x64.Build.0 = Release|x64 {92E3B437-C258-47FB-8856-D3FEA56A3BCC}.Debug|Win32.ActiveCfg = Debug|Win32 {92E3B437-C258-47FB-8856-D3FEA56A3BCC}.Debug|Win32.Build.0 = Debug|Win32 - {92E3B437-C258-47FB-8856-D3FEA56A3BCC}.Release|Win32.ActiveCfg = Release|Win32 - {92E3B437-C258-47FB-8856-D3FEA56A3BCC}.Release|Win32.Build.0 = Release|Win32 {92E3B437-C258-47FB-8856-D3FEA56A3BCC}.Debug|x64.ActiveCfg = Debug|x64 {92E3B437-C258-47FB-8856-D3FEA56A3BCC}.Debug|x64.Build.0 = Debug|x64 + {92E3B437-C258-47FB-8856-D3FEA56A3BCC}.Release|Win32.ActiveCfg = Release|Win32 + {92E3B437-C258-47FB-8856-D3FEA56A3BCC}.Release|Win32.Build.0 = Release|Win32 {92E3B437-C258-47FB-8856-D3FEA56A3BCC}.Release|x64.ActiveCfg = Release|x64 {92E3B437-C258-47FB-8856-D3FEA56A3BCC}.Release|x64.Build.0 = Release|x64 EndGlobalSection @@ -56,11 +62,14 @@ Global HideSolutionNode = FALSE EndGlobalSection GlobalSection(NestedProjects) = preSolution - {015D7470-0FC8-4597-A67E-BD9C754F0681} = {DFD0A31B-8B62-4BAA-998E-161F01D1A01B} - {B2DE2C37-B3F2-491E-94AE-402A7B4D3308} = {2D3D13DE-5985-4A6C-8562-3E954D634F1E} - {92E3B437-C258-47FB-8856-D3FEA56A3BCC} = {2CAF23FF-28F8-4D52-B6C9-B76C8BCD5F67} {DFD0A31B-8B62-4BAA-998E-161F01D1A01B} = {BB781269-F74A-43E0-AD7D-DBD32BBF2012} {BB781269-F74A-43E0-AD7D-DBD32BBF2012} = {26B59072-BF66-4E06-83CA-3F4F95378A23} {2D3D13DE-5985-4A6C-8562-3E954D634F1E} = {BB781269-F74A-43E0-AD7D-DBD32BBF2012} + {015D7470-0FC8-4597-A67E-BD9C754F0681} = {DFD0A31B-8B62-4BAA-998E-161F01D1A01B} + {B2DE2C37-B3F2-491E-94AE-402A7B4D3308} = {2D3D13DE-5985-4A6C-8562-3E954D634F1E} + {92E3B437-C258-47FB-8856-D3FEA56A3BCC} = {2CAF23FF-28F8-4D52-B6C9-B76C8BCD5F67} + EndGlobalSection + GlobalSection(ExtensibilityGlobals) = postSolution + SolutionGuid = {D56D7C7C-8F28-4702-A8D4-D0FDB5A2756C} EndGlobalSection EndGlobal diff --git a/network/ndis/mux/notifyob/adapter.cpp b/network/ndis/mux/notifyob/adapter.cpp index ea964c7a..a208aa57 100644 --- a/network/ndis/mux/notifyob/adapter.cpp +++ b/network/ndis/mux/notifyob/adapter.cpp @@ -146,9 +146,13 @@ HRESULT CMuxPhysicalAdapter::LoadConfiguration (VOID) // device IDs of the virtual miniports are stored. // - StringFromGUID2( m_guidAdapter, + int numChars = StringFromGUID2( m_guidAdapter, szAdapterGuid, MAX_PATH+1 ); + if (numChars == 0) { + + return HRESULT_FROM_WIN32(ERROR_BUFFER_OVERFLOW); + } StringCchPrintfW ( szAdapterGuidKey, celems(szAdapterGuidKey), @@ -225,9 +229,14 @@ HRESULT CMuxPhysicalAdapter::LoadConfiguration (VOID) if ( lpMiniportGuid != NULL ) { - CLSIDFromString( lpMiniportGuid, + HRESULT hrResult = CLSIDFromString( lpMiniportGuid, &guidMiniport ); - + + if (hrResult != S_OK) { + + lResult = ERROR_INVALID_PARAMETER; + } + // // Create an instance representing the virtual miniport. // @@ -532,10 +541,16 @@ HRESULT CMuxPhysicalAdapter::ApplyRegistryChanges (ConfigAction eApplyAction) // Open/create and then close the registry key to ensure that it does exist. // - StringFromGUID2( m_guidAdapter, + int numChars = StringFromGUID2( m_guidAdapter, szAdapterGuid, MAX_PATH+1 ); + if (numChars == 0) { + + return HRESULT_FROM_WIN32(ERROR_BUFFER_OVERFLOW); + } + + lResult = RegCreateKeyExW( HKEY_LOCAL_MACHINE, c_szAdapterList, 0, @@ -786,9 +801,16 @@ HRESULT CMuxPhysicalAdapter::ApplyPnpChanges( // Notify the driver that one or more virtual miniports have been added. // - StringFromGUID2( guidMiniport, + int numChars = StringFromGUID2( guidMiniport, szMiniportGuid, MAX_PATH+1 ); + if (numChars == 0) { + + CoTaskMemFree(lpszBindName); + + return HRESULT_FROM_WIN32(ERROR_BUFFER_OVERFLOW); + } + lpDevice = AddDevicePrefix( szMiniportGuid ); if ( lpDevice ) { @@ -865,9 +887,16 @@ HRESULT CMuxPhysicalAdapter::ApplyPnpChanges( if ( eApplyAction != eActRemove ) { - StringFromGUID2( guidMiniport, + int numChars = StringFromGUID2( guidMiniport, szMiniportGuid, MAX_PATH+1 ); + if(numChars == 0) { + + CoTaskMemFree(lpszBindName); + + return HRESULT_FROM_WIN32(ERROR_BUFFER_OVERFLOW); + } + lpDevice = AddDevicePrefix( szMiniportGuid ); if ( lpDevice ) { diff --git a/network/ndis/mux/notifyob/common.cpp b/network/ndis/mux/notifyob/common.cpp index 24c7b486..5ca2ca7f 100644 --- a/network/ndis/mux/notifyob/common.cpp +++ b/network/ndis/mux/notifyob/common.cpp @@ -328,6 +328,7 @@ HRESULT HrFindInstance (INetCfg *pnc, ULONG ulCount; BOOL found; HRESULT hr; + int numChars; TraceMsg( L"-->HrFindInstance.\n" ); @@ -336,10 +337,17 @@ HRESULT HrFindInstance (INetCfg *pnc, if ( hr == S_OK ) { - StringFromGUID2( guidInstance, + numChars = StringFromGUID2( guidInstance, szGuid, MAX_PATH+1 ); + if (numChars == 0) { + + ReleaseObj(pencc); + + return HRESULT_FROM_WIN32(ERROR_BUFFER_OVERFLOW); + } + TraceMsg( L" Looking for component with InstanceGuid %s\n", szGuid ); @@ -353,10 +361,20 @@ HRESULT HrFindInstance (INetCfg *pnc, if ( hr == S_OK ) { - StringFromGUID2( guid, + numChars = StringFromGUID2( guid, szGuid, MAX_PATH+1 ); + if (numChars == 0) { + + ReleaseObj(pncc); + + ReleaseObj(pencc); + + return HRESULT_FROM_WIN32(ERROR_BUFFER_OVERFLOW); + } + + TraceMsg( L" Found component with InstanceGuid %s\n", szGuid ); diff --git a/network/ndis/mux/notifyob/dllmain.cpp b/network/ndis/mux/notifyob/dllmain.cpp index d9785cd6..636f2c8a 100644 --- a/network/ndis/mux/notifyob/dllmain.cpp +++ b/network/ndis/mux/notifyob/dllmain.cpp @@ -68,6 +68,7 @@ BOOL WINAPI DllMain (HINSTANCE hInstance, ///////////////////////////////////////////////////////////////////////////// // Used to determine whether the DLL can be unloaded by OLE +__control_entrypoint(DllExport) STDAPI DllCanUnloadNow(void) { HRESULT hr; @@ -85,6 +86,7 @@ STDAPI DllCanUnloadNow(void) ///////////////////////////////////////////////////////////////////////////// // Returns a class factory to create an object of the requested type +_Check_return_ STDAPI DllGetClassObject(_In_ REFCLSID rclsid, _In_ REFIID riid, _Outptr_ LPVOID* ppv) { TraceMsg( L"-->DllGetClassObject.\n"); diff --git a/network/ndis/mux/notifyob/notify.cpp b/network/ndis/mux/notifyob/notify.cpp index be239fcd..3d0a55ff 100644 --- a/network/ndis/mux/notifyob/notify.cpp +++ b/network/ndis/mux/notifyob/notify.cpp @@ -1041,11 +1041,8 @@ STDMETHODIMP CMuxNotify::ApplyProperties (VOID) INetLanConnectionUiInfo *pLanConnUiInfo; CMuxPhysicalAdapter *pAdapter; GUID guidAdapter; - INetCfgComponent *pncc; HRESULT hr = S_OK; - UNREFERENCED_PARAMETER(pncc); - TraceMsg(L"-->CMuxNotify INetCfgPropertyUi::ApplyProperties\n"); if ( m_pUnkContext ) { @@ -1232,9 +1229,14 @@ HRESULT CMuxNotify::HrLoadAdapterConfiguration (VOID) // Subkeys are actually a guid/bindname of the adapters. // szAdapterGuid[MAX_PATH]='\0'; - CLSIDFromString( szAdapterGuid, + HRESULT hrResult = CLSIDFromString( szAdapterGuid, &guidAdapter ); + if (hrResult != S_OK) { + + lResult = ERROR_INVALID_PARAMETER; + } + // // Create an instance representing the adapter. // diff --git a/network/ndis/mux/notifyob/virtual.cpp b/network/ndis/mux/notifyob/virtual.cpp index 5b6cde80..fd3cce0e 100644 --- a/network/ndis/mux/notifyob/virtual.cpp +++ b/network/ndis/mux/notifyob/virtual.cpp @@ -330,17 +330,22 @@ HRESULT CMuxVirtualMiniport::ApplyRegistryChanges(ConfigAction eApplyAction) WCHAR szMiniportGuid[MAX_PATH+1]; LPWSTR lpDevice; LONG lResult = 0; - + int numChars; TraceMsg( L"-->CMuxVirtualMiniport::ApplyRegistryChanges.\n" ); switch( eApplyAction ) { case eActAdd: // Virtual miniport added. - StringFromGUID2( m_guidAdapter, + numChars = StringFromGUID2( m_guidAdapter, szAdapterGuid, MAX_PATH+1 ); + if (numChars == 0) { + + return HRESULT_FROM_WIN32(ERROR_BUFFER_OVERFLOW); + } + StringCchPrintfW ( szAdapterGuidKey, celems(szAdapterGuidKey), L"%s\\%s", @@ -361,10 +366,17 @@ HRESULT CMuxVirtualMiniport::ApplyRegistryChanges(ConfigAction eApplyAction) if ( lResult == ERROR_SUCCESS ) { - StringFromGUID2( m_guidMiniport, + numChars = StringFromGUID2( m_guidMiniport, szMiniportGuid, MAX_PATH+1 ); + if (numChars == 0) { + + RegCloseKey(hkeyAdapterGuid); + + return HRESULT_FROM_WIN32(ERROR_BUFFER_OVERFLOW); + } + lpDevice = AddDevicePrefix( szMiniportGuid ); if ( lpDevice ) { @@ -411,10 +423,15 @@ HRESULT CMuxVirtualMiniport::ApplyRegistryChanges(ConfigAction eApplyAction) case eActRemove: // Virtual miniport removed. - StringFromGUID2( m_guidAdapter, + numChars = StringFromGUID2( m_guidAdapter, szAdapterGuid, MAX_PATH+1 ); + if (numChars == 0) { + + return HRESULT_FROM_WIN32(ERROR_BUFFER_OVERFLOW); + } + StringCchPrintfW( szAdapterGuidKey, celems(szAdapterGuidKey), L"%s\\%s", @@ -434,10 +451,17 @@ HRESULT CMuxVirtualMiniport::ApplyRegistryChanges(ConfigAction eApplyAction) if ( lResult == ERROR_SUCCESS ) { - StringFromGUID2( m_guidMiniport, + numChars = StringFromGUID2( m_guidMiniport, szMiniportGuid, MAX_PATH+1 ); + if (numChars == 0) { + + RegCloseKey(hkeyAdapterGuid); + + return HRESULT_FROM_WIN32(ERROR_BUFFER_OVERFLOW); + } + lpDevice = AddDevicePrefix( szMiniportGuid ); TraceMsg( L" Deleting %s at %s.\n", lpDevice, |
