Skip to content

Commit 4c2a90c

Browse files
committed
Fix GetLength return value check in ASN1_INTEGER functions
Change GetLength() return check from > 0 to >= 0 in wolfSSL_ASN1_INTEGER_get_length and wolfSSL_ASN1_INTEGER_get0_data. GetLength returns the decoded length (≥ 0) on success and negative error codes on failure, so checking > 0 incorrectly excluded zero-length values, making the DER-stripping logic dead code.
1 parent b36a9ca commit 4c2a90c

1 file changed

Lines changed: 2 additions & 2 deletions

File tree

src/ssl_asn1.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1016,7 +1016,7 @@ int wolfSSL_ASN1_INTEGER_get_length(const WOLFSSL_ASN1_INTEGER* ai)
10161016
if (ai->data[0] == ASN_INTEGER) {
10171017
word32 idx = 1;
10181018
int len = 0;
1019-
if (GetLength(ai->data, &idx, &len, (word32)ai->length) > 0 &&
1019+
if (GetLength(ai->data, &idx, &len, (word32)ai->length) >= 0 &&
10201020
idx + (word32)len == (word32)ai->length) {
10211021
return len;
10221022
}
@@ -1043,7 +1043,7 @@ const unsigned char* wolfSSL_ASN1_INTEGER_get0_data(const WOLFSSL_ASN1_INTEGER*
10431043
if (ai->data[0] == ASN_INTEGER) {
10441044
word32 idx = 1;
10451045
int len = 0;
1046-
if (GetLength(ai->data, &idx, &len, (word32)ai->length) > 0 &&
1046+
if (GetLength(ai->data, &idx, &len, (word32)ai->length) >= 0 &&
10471047
idx + (word32)len == (word32)ai->length) {
10481048
return ai->data + idx;
10491049
}

0 commit comments

Comments
 (0)