Skip to content

Segfault in encodeDN #13684

@Trzik

Description

@Trzik

I did this

The issue happens when curl tries to parse this structure, specifically the OID 1.2.840.113549.1.9.2 - unstructuredName

The segfault (nullptr dereference) happens on this line:

for(p3 = str; ISUPPER(*p3); p3++)

The issue comes from OID2str when searchOID is invoked. OIDtable is searched, entry 1.2.840.113549.1.9.2 is not found and the function returns NULL. However, the result stays CURLE_OK so the calling code assumes the dynbuf is perfectly valid when it is in fact still in unallocated state.

For the record, the issue started occurring with commit 623c3a8 since version 8.6.0.

I'm also attaching a patch that may be helpful.
x509asn1.patch

I expected the following

Not a crash

curl/libcurl version

curl 8.6.0

operating system

Windows 10 (x64, 22631)

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions