Skip to content

Commit 5e9a4d7

Browse files
Merge #990: Add comment on length checks when parsing ECDSA sigs
e02f313 Add comment on length checks when parsing ECDSA sigs (Tim Ruffing) Pull request description: I claim the check can be removed but I don't want to touch this stable and well-tested code. On the way, we fix grammar in another comment. ACKs for top commit: sipa: ACK e02f313 RandyMcMillan: ACK e02f313 Tree-SHA512: f82691a8f5db82a1e9683e52ce8e952ebd56b476a2817c5a876ce4638254b7b4ac93175318fb59598ed5532f33433951d75afea03724ef4419c3e1bd12ca8c20
2 parents 4197d66 + e02f313 commit 5e9a4d7

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

src/ecdsa_impl.h

+4-3
Original file line numberDiff line numberDiff line change
@@ -66,8 +66,7 @@ static int secp256k1_der_read_len(size_t *len, const unsigned char **sigp, const
6666
}
6767
if (lenleft > sizeof(size_t)) {
6868
/* The resulting length would exceed the range of a size_t, so
69-
* certainly longer than the passed array size.
70-
*/
69+
* it is certainly longer than the passed array size. */
7170
return 0;
7271
}
7372
while (lenleft > 0) {
@@ -76,7 +75,9 @@ static int secp256k1_der_read_len(size_t *len, const unsigned char **sigp, const
7675
lenleft--;
7776
}
7877
if (*len > (size_t)(sigend - *sigp)) {
79-
/* Result exceeds the length of the passed array. */
78+
/* Result exceeds the length of the passed array.
79+
(Checking this is the responsibility of the caller but it
80+
can't hurt do it here, too.) */
8081
return 0;
8182
}
8283
if (*len < 128) {

0 commit comments

Comments
 (0)