Skip to content

Commit e02f313

Browse files
Add comment on length checks when parsing ECDSA sigs
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.
1 parent 920a0e5 commit e02f313

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
@@ -79,8 +79,7 @@ static int secp256k1_der_read_len(size_t *len, const unsigned char **sigp, const
7979
}
8080
if (lenleft > sizeof(size_t)) {
8181
/* The resulting length would exceed the range of a size_t, so
82-
* certainly longer than the passed array size.
83-
*/
82+
* it is certainly longer than the passed array size. */
8483
return 0;
8584
}
8685
while (lenleft > 0) {
@@ -89,7 +88,9 @@ static int secp256k1_der_read_len(size_t *len, const unsigned char **sigp, const
8988
lenleft--;
9089
}
9190
if (*len > (size_t)(sigend - *sigp)) {
92-
/* Result exceeds the length of the passed array. */
91+
/* Result exceeds the length of the passed array.
92+
(Checking this is the responsibility of the caller but it
93+
can't hurt do it here, too.) */
9394
return 0;
9495
}
9596
if (*len < 128) {

0 commit comments

Comments
 (0)