Repository navigation
formatDateTimeInJodaSyntax: Fix potential memory overwrite with overlong time zones - #117925
Conversation
formatDateTimeInJodaSyntax: Fix potential memory overwrite with overlong time zones
|
Workflow [PR], commit [7cb7f70] Summary: ✅
AI ReviewSummaryThis PR fixes the 32-byte overwrite in Joda timezone formatting by throwing once the stored timezone spelling exceeds 32 bytes. I do not think the current approach is ready to merge, because it turns the memory-safety fix into a user-visible behavior regression for timezone names that Findings
Final VerdictChanges requested. LLVM Coverage ReportMeasured on commit 7cb7f70.
Changed lines: Changed C/C++ lines covered: 11/12 (91.67%) · Uncovered code |
ca4b3f2 to
7cb7f70
Compare
|
|
||
| auto str = timezone.getTimeZone(); | ||
| if (str.size() > MAX_JODA_TIMEZONE_NAME_LENGTH) | ||
| throw Exception(ErrorCodes::BAD_ARGUMENTS, "Time zone name is longer than the maximum supported length of {} bytes", MAX_JODA_TIMEZONE_NAME_LENGTH); |
There was a problem hiding this comment.
DateLUT preserves the validated timezone spelling verbatim, and upstream cctz loads it by appending that string to the zoneinfo path without collapsing repeated separators first. That means names like Etc///////////////////////////UTC are still valid timezones in the rest of ClickHouse, but this new guard makes formatDateTimeInJodaSyntax/fromUnixTimestampInJodaSyntax reject them purely because the spelling is longer than 32 bytes.
So this changes the function contract instead of just fixing the buffer sizing bug. Please reserve from the actual validated timezone string for constant/type-attached timezones, and pre-scan the timezone column (or treat z as variable-width) for non-constant arguments, rather than rejecting accepted timezone names here.
Build profile diff (arm_release)Comparing ✅ No significant changes. Binary sizes
The official master build is compiled with Compile time of recompiled translation units145 translation units recompiled, 1374 s compile time in total, 145 of them have a recent master baseline. |
… memory overwrite with overlong time zones
Backport #117925 to 26.8: `formatDateTimeInJodaSyntax`: Fix potential memory overwrite with overlong time zones
… memory overwrite with overlong time zones
Backport #117925 to 26.6: `formatDateTimeInJodaSyntax`: Fix potential memory overwrite with overlong time zones
Backport #117925 to 26.7: `formatDateTimeInJodaSyntax`: Fix potential memory overwrite with overlong time zones
Backport #117925 to 26.3: `formatDateTimeInJodaSyntax`: Fix potential memory overwrite with overlong time zones
… potential memory overwrite with overlong time zones
… potential memory overwrite with overlong time zones
OTHER: formatDateTimeInJodaSyntax with a time zone name longer than 32 characters overflows a fixed buffer. Effect in the production build a394e92: crash (any user, one SELECT) (the upstream test fails on it and passes on official 26.8.8.8; evidence/fix_ci_20260925/upstream_repro). Upstream patch unchanged, with its test(s): 05059_formatDateTime_extralong_timezone Co-Authored-By: Claude Opus 5.5 <[email protected]>
…fixes 05059_formatDateTime_extralong_timezone (ClickHouse#117925) and 04327_join_runtime_filter_json (ClickHouse#107663) join the stateless selection (97 tests); known_defects.json gets their entries (40, 0 open). Co-Authored-By: Claude Opus 5.5 <[email protected]>
Changelog category (leave one):
Changelog entry (a user-readable short description of the changes that goes into CHANGELOG.md):
Fixes a potential out-of-bounds write of function
formatDateTimeInJodaSyntaxwhen called with a time zone name longer than 32 characters.Workflow [PR]
Sync PR [sync-upstream/pr/117925]
Version info
26.9.1.681(included in26.9and later)26.8.3.31,26.7.7.25,26.6.5.46,26.3.33.4