Skip to content

Widen tls upper bound to allow tls 2.4.x#77

Closed
jappeace-sloth wants to merge 4 commits intowinterland1989:masterfrom
jappeace-sloth:widen-tls-bound
Closed

Widen tls upper bound to allow tls 2.4.x#77
jappeace-sloth wants to merge 4 commits intowinterland1989:masterfrom
jappeace-sloth:widen-tls-bound

Conversation

@jappeace-sloth
Copy link
Copy Markdown

Summary

  • Add ^>=2.4.0 to tls dependency bounds to allow tls 2.4.x
  • Patch bump version 1.2.2 → 1.2.3
  • Update ChangeLog.md

Test plan

  • Verify cabal build succeeds with tls 2.4.x
  • CI passes

🤖 Generated with Claude Code

jappeace-sloth and others added 4 commits March 25, 2026 11:08
Replace unsafeDrop, unsafeTail, and unsafeIndex with safe bounded
alternatives in text protocol parsers (MySQLValue.hs), add a
precision >= scale guard for NEWDECIMAL in BinLogValue.hs, and add
bounds checking to eventHeaderLen in BinLogEvent.hs.

The unsafe operations caused undefined behavior (reading garbage memory,
segfaults) when receiving malformed data from the MySQL wire protocol.
The safe alternatives are also O(1) — the only cost is a single integer
comparison per call.

Changes:
- MySQLValue.hs: Add guards before B.tail/B.drop in dateParser,
  timeParser, timestamp/datetime, and time field parsers
- BinLogValue.hs: Guard precision >= scale in NEWDECIMAL to prevent
  Word8 underflow causing out-of-bounds sizeTable access
- BinLogEvent.hs: Bounds check in eventHeaderLen to handle unknown
  event types (negative index) gracefully by returning 0
- Add test/BoundsCheck.hs with 8 regression tests covering all
  fixed code paths

Prompt: Implement plan to fix unsafe bounds in mysql-haskell (TDD)

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
The old timestamp/datetime tests used "abc" and "" as inputs.
readDecimal returns Nothing on non-numeric input, which short-circuits
via Maybe's Applicative instance before unsafeDrop is ever forced
(lazy evaluation). These tests passed even without the fix.

Replace with inputs where dateParser succeeds but the string is too
short for the subsequent unsafeDrop 11:
- "2024-01-01" (10 bytes) — dateParser succeeds, unsafeDrop 11 is UB
- "2024-01-01 1" (12 bytes) — dateParser succeeds, unsafeDrop 11
  gives "1", timeParser reads hour, then unsafeTail on "" is UB

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Add ^>=2.4.0 to tls dependency bounds.
Bump version 1.2.2 -> 1.2.3.

Prompt: repair bounds for these packages, make it tls <2.5.0, do a patch bump and update the changelog

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant