Merge #879: Avoid passing out-of-bound pointers to 0-size memcpy
9570f674ccAvoid passing out-of-bound pointers to 0-size memcpy (Pieter Wuille) Pull request description: Doing so could be considered UB in a pedantic interpretation of the standard. Avoid it. Closes #876. ACKs for top commit: practicalswift: cr ACK9570f674cc: patch looks correct real-or-random: ACK9570f674ccTree-SHA512: f991462d72e39f14e609021b8427c2e6756009bc8cd21efca2da46ec9410250725a4fed662df20fcdcfd10a4dc59038f13e8c166362b2eadde4366586b9ca72b
This commit is contained in:
@@ -120,7 +120,7 @@ int ecdsa_signature_parse_der_lax(const secp256k1_context* ctx, secp256k1_ecdsa_
|
||||
/* Copy R value */
|
||||
if (rlen > 32) {
|
||||
overflow = 1;
|
||||
} else {
|
||||
} else if (rlen) {
|
||||
memcpy(tmpsig + 32 - rlen, input + rpos, rlen);
|
||||
}
|
||||
|
||||
@@ -132,7 +132,7 @@ int ecdsa_signature_parse_der_lax(const secp256k1_context* ctx, secp256k1_ecdsa_
|
||||
/* Copy S value */
|
||||
if (slen > 32) {
|
||||
overflow = 1;
|
||||
} else {
|
||||
} else if (slen) {
|
||||
memcpy(tmpsig + 64 - slen, input + spos, slen);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user