Skip to content

Commit a8a230a

Browse files
committed
Unpoison EllSwift decode for MSan
Mark the serialized compressed pubkey produced by secp256k1_ec_pubkey_serialize as initialized when building with MemorySanitizer. The EllSwift decode path previously triggered a use-of-uninitialized-value in the fuzz harness because libsecp256k1 is built without instrumentation. Test: cmake --build build --target test_sv2 --config Release Assisted-by: GitHub Copilot Assisted-by: OpenAI GPT-5-Codex
1 parent 7642532 commit a8a230a

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

src/pubkey.cpp

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,9 @@
1111
#include <secp256k1_extrakeys.h>
1212
#include <secp256k1_recovery.h>
1313
#include <secp256k1_schnorrsig.h>
14+
#ifdef MEMORY_SANITIZER
15+
#include <sanitizer/msan_interface.h>
16+
#endif
1417
#include <span.h>
1518
#include <uint256.h>
1619
#include <util/strencodings.h>
@@ -375,6 +378,9 @@ CPubKey EllSwiftPubKey::Decode() const
375378

376379
secp256k1_ec_pubkey_serialize(secp256k1_context_static, vch_bytes.data(), &sz, &pubkey, SECP256K1_EC_COMPRESSED);
377380
assert(sz == vch_bytes.size());
381+
#ifdef MEMORY_SANITIZER
382+
__msan_unpoison(vch_bytes.data(), vch_bytes.size());
383+
#endif
378384

379385
return CPubKey{vch_bytes.begin(), vch_bytes.end()};
380386
}

0 commit comments

Comments
 (0)