Skip to content

cookies: Fix potential NULL pointer deref with PSL - #6731

Closed
danielgustafsson wants to merge 1 commit into
curl:masterfrom
danielgustafsson:dg-cookie-psl-null-deref
Closed

cookies: Fix potential NULL pointer deref with PSL#6731
danielgustafsson wants to merge 1 commit into
curl:masterfrom
danielgustafsson:dg-cookie-psl-null-deref

Conversation

@danielgustafsson

Copy link
Copy Markdown
Member

Curl_cookie_init can be called with data being NULL, and this can in turn be passed to Curl_cookie_add, meaning that both functions must be careful to only use data where it's checked for being a NULL pointer. The libpsl support code does however dereference data without checking, so if we are indeed having an unset data pointer we cannot PSL check the cookiedomain.

This is currently not a reachable dereference, as the only caller with a NULL data isn't passing a file to initialize cookies from, but since the API has this contract let's ensure we hold it.

Curl_cookie_init can be called with data being NULL, and this can in turn
be passed to Curl_cookie_add, meaning that both functions must be careful
to only use data where it's checked for being a NULL pointer.  The libpsl
support code does however dereference data without checking, so if we are
indeed having an unset data pointer we cannot PSL check the cookiedomain.

This is currently not a reachable dereference, as the only caller with a
NULL data isn't passing a file to initialize cookies from, but since the
API has this contract let's ensure we hold it.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Development

Successfully merging this pull request may close these issues.

2 participants