Skip to content

Commit 5c30a53

Browse files
committed
improve pk_oid_num_to_str()
* allow `OID` to be `NULL` until you want to write it ... * make sure we don't overflow the `int i` Signed-off-by: Steffen Jaeckel <s@jaeckel.eu>
1 parent 1052703 commit 5c30a53

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

src/pk/asn1/oid/pk_oid_str.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ int pk_oid_num_to_str(const unsigned long *oid, unsigned long oidlen, char *OID,
4949
char tmp[256] = { 0 };
5050

5151
LTC_ARGCHK(oid != NULL);
52-
LTC_ARGCHK(OID != NULL);
52+
LTC_ARGCHK(oidlen < INT_MAX);
5353
LTC_ARGCHK(outlen != NULL);
5454

5555
for (i = oidlen - 1, k = 0; i >= 0; i--) {
@@ -74,6 +74,7 @@ int pk_oid_num_to_str(const unsigned long *oid, unsigned long oidlen, char *OID,
7474
*outlen = k + 1;
7575
return CRYPT_BUFFER_OVERFLOW;
7676
}
77+
LTC_ARGCHK(OID != NULL);
7778
for (j = 0; j < k; j++) OID[j] = tmp[k - j - 1];
7879
OID[k] = '\0';
7980
*outlen = k; /* the length without terminating NUL byte */

0 commit comments

Comments
 (0)