Repository navigation
Fix UB in cbor_value_get_int64() with out-of-range inputs - #349
Open
thiagomacieira wants to merge 1 commit into
Open
thiagomacieira wants to merge 1 commit into
thiagomacieira wants to merge 1 commit into
Conversation
This function and `cbor_value_get_int()` are documented to "silently truncate" the values out of range and that untrusted input should be checked with their `_checked()` versions. However, it only truncated as a side-effect of UB, in the typical build. We cannot depend on that. The simplest fix is to just use unsigned arithmetic to do exactly what we were doing. The generated assembly will be exactly what we want and probably what was being generated anyway. Fixes intel#347. Signed-off-by: Thiago Macieira <thiago.macieira@intel.com>
thiagomacieira
force-pushed
the
Fix_UB_in_cbor_value_get_int64_with_out_of_range_inputs
branch
from
October 27, 2026 16:28
6bee071 to
cf7f4d0
Compare
This branch has not been deployed
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.
This function and
cbor_value_get_int()are documented to "silently truncate" the values out of range and that untrusted input should be checked with their_checked()versions. However, it only truncated as a side-effect of UB, in the typical build. We cannot depend on that.The simplest fix is to just use unsigned arithmetic to do exactly what we were doing. The generated assembly will be exactly what we want and probably what was being generated anyway.
Fixes #347.