Fix invalid isspace call detected by PREfast - #1925
Merged
Merged
Conversation
D:\vcpkg\toolsrc\include\catch2\catch.hpp(11285): warning C6330: 'char' passed as _Param_(1) when 'unsigned char' is required in call to 'isspace'. D:\vcpkg\toolsrc\include\catch2\catch.hpp(11288): warning C6330: 'char' passed as _Param_(1) when 'unsigned char' is required in call to 'isspace'. ISO/IEC 9899:2011: "7.4 Character handling <ctype.h>"/1 [...] In all cases the argument is an int, the value of which shall be representable as an unsigned char or shall equal the value of the macro EOF. If the argument has any other value, the behavior is undefined. This means if isspace was passed a character like ñ it could corrupt memory without the static_cast to treat it as a positive value after integral promotion (and C libraries commonly use the int index supplied as a key into a table which result in out of bounds access if the resulting int is negative).
BillyONeal
added a commit
to BillyONeal/vcpkg
that referenced
this pull request
May 12, 2020
CMakeLists.txt: Turn on /analyze when development warnings are on. catch.hpp: See submitted upstream: catchorg/Catch2#1925 downloads.cpp: PREfast can't see that check_exit is noreturn when f == nullptr. files.cpp: PREfast detected this bogus both sides of the && testing the same thing. strings.cpp: Same as the catch issue, isspace needs to be given unsigned. system.process.cpp: suppress ownership transfer warning about process_info, and make ProcessInfo ensure handles are closed. build.cpp: PREfast still doesn't understand check_exit commands.integrate.cpp: More bad <ctype.h> calls.
Codecov Report
@@ Coverage Diff @@
## master #1925 +/- ##
=======================================
Coverage 88.60% 88.60%
=======================================
Files 138 138
Lines 5606 5606
=======================================
Hits 4967 4967
Misses 639 639 |
Member
|
uuuuuugh |
BillyONeal
added a commit
to BillyONeal/vcpkg
that referenced
this pull request
May 14, 2020
CMakeLists.txt: Turn on /analyze when development warnings are on. catch.hpp: See submitted upstream: catchorg/Catch2#1925 downloads.cpp: PREfast can't see that check_exit is noreturn when f == nullptr. files.cpp: PREfast detected this bogus both sides of the && testing the same thing. strings.cpp: Same as the catch issue, isspace needs to be given unsigned. system.process.cpp: suppress ownership transfer warning about process_info, and make ProcessInfo ensure handles are closed. build.cpp: PREfast still doesn't understand check_exit commands.integrate.cpp: More bad <ctype.h> calls.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
ISO/IEC 9899:2011:
"7.4 Character handling <ctype.h>"/1
[...] In all cases the argument is an int, the value of which shall be
representable as an unsigned char or shall equal the value of the macro
EOF. If the argument has any other value, the behavior is undefined.
This means if isspace was passed a character like ñ it could corrupt
memory without the static_cast to treat it as a positive value after
integral promotion (and C libraries commonly use the int index supplied
as a key into a table which result in out of bounds access if the
resulting int is negative).