From 8cf10ba890d25228e37406bf2e68212aed7d2166 Mon Sep 17 00:00:00 2001 From: Max Lv Date: Wed, 14 Oct 2026 21:10:49 +0800 Subject: [PATCH] Do not memcpy from an empty span in the stream decoder An empty read before the IV arrived passed a null source to memcpy, which UBSan reports (and the ASan CI job turns into a failure). --- src/crypto/stream.cpp | 4 +++- tests/test_crypto_stream_cpp.cpp | 3 +++ 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/src/crypto/stream.cpp b/src/crypto/stream.cpp index b8dd8db2..fb92c8a3 100644 --- a/src/crypto/stream.cpp +++ b/src/crypto/stream.cpp @@ -217,7 +217,9 @@ Result StreamTcpDecryptor::decrypt(std::span(), out); + SS_CHECK(none && none->consumed == 0 && none->produced == 0 && !first.iv_received()); // The IV alone is enough to register it. auto step = first.decrypt(std::span(wire.data(), key.spec.iv_len), out); SS_CHECK(step && step->produced == 0 && first.iv_received());