Kills some live mutants on interpreter.cpp found by https://bitcoincore.space. They are:
<details> <summary><a href="https://bitcoincore.space/src/script/interpreter.cpp#5168">interpreter.cpp#5168</a>: <code>IsCompressedOrUncompressedPubKey</code>: pubkey with neither compressed nor uncompressed prefix returns <code>true</code></summary>
diff --git a/src/script/interpreter.cpp b/src/script/interpreter.cpp
index 98b16eca6b..a9dd379a3d 100644
--- a/src/script/interpreter.cpp
+++ b/src/script/interpreter.cpp
@@ -81,7 +81,7 @@ bool static IsCompressedOrUncompressedPubKey(const valtype &vchPubKey) {
// Non-canonical public key: invalid length for uncompressed key
return false;
}
- } else if (vchPubKey[0] == 0x02 || vchPubKey[0] == 0x03) {
+ } else if (1==1) {
if (vchPubKey.size() != CPubKey::COMPRESSED_SIZE) {
// Non-canonical public key: invalid length for compressed key
return false;
</details>
<details> <summary><a href="https://bitcoincore.space/src/script/interpreter.cpp#5191">interpreter.cpp#5191</a>: <code>IsValidSignatureEncoding</code>: 73-byte upper bound returns <code>true</code></summary>
diff --git a/src/script/interpreter.cpp b/src/script/interpreter.cpp
index 98b16eca6b..58d275b139 100644
--- a/src/script/interpreter.cpp
+++ b/src/script/interpreter.cpp
@@ -130,7 +130,7 @@ bool static IsValidSignatureEncoding(const std::vector<unsigned char> &sig) {
// Minimum and maximum size constraints.
if (sig.size() < 9) return false;
- if (sig.size() > 73) return false;
+
// A signature is of type 0x30 (compound).
if (sig[0] != 0x30) return false;
</details>
<details> <summary><a href="https://bitcoincore.space/src/script/interpreter.cpp#5200">interpreter.cpp#5200</a>: <code>IsValidSignatureEncoding</code>: total-length byte check returns <code>true</code></summary>
diff --git a/src/script/interpreter.cpp b/src/script/interpreter.cpp
index 98b16eca6b..b2d3e0677f 100644
--- a/src/script/interpreter.cpp
+++ b/src/script/interpreter.cpp
@@ -136,7 +136,7 @@ bool static IsValidSignatureEncoding(const std::vector<unsigned char> &sig) {
if (sig[0] != 0x30) return false;
// Make sure the length covers the entire signature.
- if (sig[1] != sig.size() - 3) return false;
+
// Extract the length of the R element.
unsigned int lenR = sig[3];
</details>
<details> <summary><a href="https://bitcoincore.space/src/script/interpreter.cpp#5232">interpreter.cpp#5232</a>: <code>IsValidSignatureEncoding</code>: null R byte check <code>lenR > 1</code> -> <code>lenR >=1</code></summary>
diff --git a/src/script/interpreter.cpp b/src/script/interpreter.cpp
index 98b16eca6b..0170ffe487 100644
--- a/src/script/interpreter.cpp
+++ b/src/script/interpreter.cpp
@@ -162,7 +162,7 @@ bool static IsValidSignatureEncoding(const std::vector<unsigned char> &sig) {
// Null bytes at the start of R are not allowed, unless R would
// otherwise be interpreted as a negative number.
- if (lenR > 1 && (sig[4] == 0x00) && !(sig[5] & 0x80)) return false;
+ if (lenR >= 1 && (sig[4] == 0x00) && !(sig[5] & 0x80)) return false;
// Check whether the S element is an integer.
if (sig[lenR + 4] != 0x02) return false;
</details>
<details> <summary><a href="https://bitcoincore.space/src/script/interpreter.cpp#5259">interpreter.cpp#5259</a>: <code>IsValidSignatureEncoding</code>: null S byte check <code>lenS > 1</code> -> <code>lenS >= 1</code></summary>
diff --git a/src/script/interpreter.cpp b/src/script/interpreter.cpp
index 98b16eca6b..e85e8dc85b 100644
--- a/src/script/interpreter.cpp
+++ b/src/script/interpreter.cpp
@@ -175,7 +175,7 @@ bool static IsValidSignatureEncoding(const std::vector<unsigned char> &sig) {
// Null bytes at the start of S are not allowed, unless S would otherwise be
// interpreted as a negative number.
- if (lenS > 1 && (sig[lenR + 6] == 0x00) && !(sig[lenR + 7] & 0x80)) return false;
+ if (lenS >= 1 && (sig[lenR + 6] == 0x00) && !(sig[lenR + 7] & 0x80)) return false;
return true;
}
</details>
<details> <summary><a href="https://bitcoincore.space/src/script/interpreter.cpp#5186">interpreter.cpp#5186</a>: <code>IsValidSignatureEncoding</code>: 9-byte lower bound returns <code>true</code></summary>
diff --git a/src/script/interpreter.cpp b/src/script/interpreter.cpp
index 98b16eca6b..52f31306e8 100644
--- a/src/script/interpreter.cpp
+++ b/src/script/interpreter.cpp
@@ -129,7 +129,7 @@ bool static IsValidSignatureEncoding(const std::vector<unsigned char> &sig) {
// signature)
// Minimum and maximum size constraints.
- if (sig.size() < 9) return false;
+
if (sig.size() > 73) return false;
// A signature is of type 0x30 (compound).
</details>
The first affects policy only, the next four affect consensus, and the last covers the lower bound and lets ASan catch UB: a 3-byte signature reaches the sig[3] read that the sig.size() < 9 guard protects.
Recommend reviewing per commit.