Repository navigation
range-check uint16_t in the Any string to number fallback - #1242
Open
aysha-afrah26 wants to merge 1 commit into
Open
aysha-afrah26 wants to merge 1 commit into
aysha-afrah26 wants to merge 1 commit into
Conversation
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.
Any::stringToNumberin safe_any.hpp has a fallback for standard libraries that don't define__cpp_lib_to_chars, which includes Apple libc++ and so the macOS builds. In that branchuint16_twas special-cased toreturn std::stoul(str), so theunsigned longresult was narrowed touint16_timplicitly with no range check, andstoulalso accepts a leading minus sign. On macOSAny(std::string("70000")).cast<uint16_t>()returns 4464,"65536"returns 0 and"-1"returns 65535, andBlackboard::get<uint16_t>on a string entry (a value from XML, a script, orImportBlackboardFromJSON) silently returns the same wrapped numbers. Thestd::from_charsbranch used on Linux and Windows rejects all three, and every other integral type in the fallback already goes through the range-checkedconvert<T>(). I noticed it while comparing the two branches after the locale fix in #1218 and confirmed it with a small test on macOS (Apple clang 21). Removing the special case letsuint16_ttake the samestol+convert<T>()path as the other integral types, so out-of-range and negative strings now fail the cast instead of wrapping, and valid values are unchanged. It's a header-only change with no API or ABI impact, and the newAny.StringToUint16IsRangeCheckedtest fails on macOS before the change and passes after (full ctest is green).