bolt8

Encrypted and authenticated transport, per BOLT #8.
git clone git://git.ppad.tech/bolt8.git
Log | Files | Refs | README | LICENSE

commit 73edeb4503c449cfdafd7a0817ce686b297960a8
parent 4af1d8ed7eac2b14b8d4ada83183237f1625ac11
Author: Jared Tobin <jared@jtobin.io>
Date:   Sun, 25 Jan 2026 09:43:27 +0400

test: add bounds check to flip_byte helper

Guard against out-of-bounds index to give a clear error message
rather than crashing on BS.index. Addresses review finding from
REVIEW-ebf75f4.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>

Diffstat:
Mtest/Main.hs | 10++++++----
1 file changed, 6 insertions(+), 4 deletions(-)

diff --git a/test/Main.hs b/test/Main.hs @@ -489,10 +489,12 @@ test_decrypt_short_packet = do -- flip one byte in a bytestring at given index flip_byte :: Int -> BS.ByteString -> BS.ByteString -flip_byte i bs = - let (pre, post) = BS.splitAt i bs - b = BS.index post 0 - in pre <> BS.cons (b `xor` 0xff) (BS.drop 1 post) +flip_byte i bs + | i < 0 || i >= BS.length bs = error "flip_byte: index out of bounds" + | otherwise = + let (pre, post) = BS.splitAt i bs + b = BS.index post 0 + in pre <> BS.cons (b `xor` 0xff) (BS.drop 1 post) -- utilities -----------------------------------------------------------------