The existing tests only serialize into oversized buffers or one that is far too small, so the boundary case where the output buffer is exactly the required size was untested. Check that this succeeds with identical output, and that one byte less fails while reporting the required size.
Kills the following mutant (https://secp256k1.space/src/ecdsa_impl.h#1141):
diff --git a/src/ecdsa_impl.h b/src/ecdsa_impl.h
index 5963877..499fe03 100644
--- a/src/ecdsa_impl.h
+++ b/src/ecdsa_impl.h
@@ -176,7 +176,7 @@ static int secp256k1_ecdsa_sig_serialize(unsigned char *sig, size_t *size, const
secp256k1_scalar_get_b32(&s[1], as);
while (lenR > 1 && rp[0] == 0 && rp[1] < 0x80) { lenR--; rp++; }
while (lenS > 1 && sp[0] == 0 && sp[1] < 0x80) { lenS--; sp++; }
- if (*size < 6+lenS+lenR) {
+ if (*size <= 6+lenS+lenR) {
*size = 6 + lenS + lenR;
return 0;
}