Skip to content

Commit

Permalink
Fix UB in Tokenizer
Browse files Browse the repository at this point in the history
  • Loading branch information
tgoyne committed May 25, 2024
1 parent 8d7f7cb commit d954085
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 1 deletion.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
* Encrypted files on Windows had a maximum size of 2GB even on x64 due to internal usage of `off_t`, which is a 32-bit type on 64-bit Windows ([PR #7698](https://github.com/realm/realm-core/pull/7698), since the introduction of encryption support on Windows in v3.0.0).
* The encryption code no longer behaves differently depending on the system page size, which should entirely eliminate a recurring source of bugs related to copying encrypted Realm files between platforms with different page sizes. One known outstanding bug was ([RNET-1141](https://github.com/realm/realm-dotnet/issues/3592)), where opening files on a system with a larger page size than the writing system would attempt to read sections of the file which had never been written to ([PR #7698](https://github.com/realm/realm-core/pull/7698)).
* There were several complicated scenarios which could result in stale reads from encrypted files in multiprocess scenarios. These would typically lead to crash, either due to an assertion failure or DecryptionFailure being thrown ([PR #7698](https://github.com/realm/realm-core/pull/7698), since v13.9.0).
* Tokenizing strings for full-text search could pass values outside the range [-1, 255] to `isspace()`, which is undefined behavior ([PR #7698](https://github.com/realm/realm-core/pull/7698), since the introduction of FTS in v13.0.0).

### Breaking changes
* None.
Expand Down
2 changes: 1 addition & 1 deletion src/realm/tokenizer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ std::pair<std::set<std::string>, std::set<std::string>> Tokenizer::get_search_to
}
};
for (; m_cur_pos != m_end_pos; m_cur_pos++) {
if (isspace(*m_cur_pos)) {
if (isspace(static_cast<unsigned char>(*m_cur_pos))) {
add_token();
}
else {
Expand Down

0 comments on commit d954085

Please sign in to comment.