-
Notifications
You must be signed in to change notification settings - Fork 2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix casting in TLVReader::Get to be safe.
Casts of out-of-range values to signed integer types are not defined by the C or C++ standards, but this code was expecting them to act as a cast to the corresponding-sized unsigned integer type, then the "undoing" of a signed-to-unsigned cast. We instead introduce a CastToSigned() function that explicitly and safely undoes a signed-to-unsigned cast and use that in TLVReader::Get to eliminate the implementation-defined behavior dependence.
- Loading branch information
1 parent
8a532d6
commit befc11c
Showing
2 changed files
with
40 additions
and
7 deletions.
There are no files selected for viewing
This file contains 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
This file contains 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