Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

BA2026 is reported as NotApplicable for native PE binaries compiled with /sdl switch #971

Open
phildevaney opened this issue Nov 6, 2023 · 0 comments

Comments

@phildevaney
Copy link

phildevaney commented Nov 6, 2023

Rule BA2026 is being reported as NotApplicable with no additional message for all our native binaries, even though they are compiled with /sdl switch set to true:

D:\Other\Experiments\SdlChecksTest\Release\SdlChecksTest.dll: notapplicable BA2026: [eol]

I debugged EnableMicrosoftCompilerSdlSwitch.EnableMicrosoftCompilerSdlSwitch and found the sdlEnabled value read from the debug section is not 0 or 1, hence the switch goes through the default case and executes the Log line after the switch. I copied the code that reads the value to a test app that prints the value for all the binaries in a folder - for 135 binaries in our Release\x86 folder there were 44 unique values for sdlEnabled with no apparent pattern, though most are < 255.

I can reproduce the issue with a brand new Visual Studio project created from the C++/Dynamic Link Library project template with all compiler settings unchanged from their defaults in the template (including /sdl set to true). In that case the value of sdlEnabled is 2.

This is with Visual Studio 2022 17.7.6 with v143 toolset (CL.exe version 19.37.32825). The issue regardless of whether the binary is compiled for Debug, Release, x86 or x64.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant