x509asn1: improve encodeOID

- return error on zero length input
- return error on OOM or doing too large output
- fix full 32-bit number support
- fix the broken handling of the first and second numbers
- support up to 32-bit minus 80 for the second number
- a field with a leading 0x80 is now considered an error, since it only
  works as padding and is then no longer the shortest possible version

Add unit tests in 1666

Bonus: removed the last argument to OID2str() as it was always set TRUE.

Closes #21003
This commit is contained in:
Daniel Stenberg 2026-03-19 09:55:46 +01:00
parent ce51fb493c
commit 673e14cd33
No known key found for this signature in database
GPG key ID: 5CC908FDB71E12C2
5 changed files with 285 additions and 30 deletions

View file

@ -222,6 +222,7 @@ test1640 test1641 test1642 test1643 \
\
test1650 test1651 test1652 test1653 test1654 test1655 test1656 test1657 \
test1658 test1659 test1660 test1661 test1662 test1663 test1664 test1665 \
test1666 \
\
test1670 test1671 \
\

20
tests/data/test1666 Normal file
View file

@ -0,0 +1,20 @@
<?xml version="1.0" encoding="US-ASCII"?>
<testcase>
<info>
<keywords>
unittest
encodeOID
x509asn1
</keywords>
</info>
# Client-side
<client>
<features>
unittest
</features>
<name>
encodeOID unit tests
</name>
</client>
</testcase>