Opened 2 months ago

Last modified 4 days ago

#31147 needs_review defect

Check tor_vasprintf for error return values.

Reported by: paldium Owned by:
Priority: Low Milestone: Tor: 0.4.2.x-final
Component: Core Tor/Tor Version: Tor:
Severity: Normal Keywords: 035-backport 040-backport 041-backport 042-can
Cc: Actual Points:
Parent ID: Points:
Reviewer: Sponsor:


In case of error, a negative value will be returned or NULL written into
first supplied argument.

This patch uses both cases to comply with style in the specific files.

A tor_vasprintf error in process_vprintf would lead to a NULL dereference
later on in buf_add, because the return value -1 casted to size_t would
pass an assertion check inside of buf_add.

On the other hand, common systems will fail on such an operation, so it
is not a huge difference to a simple assertion. Yet it is better to
properly fail instead of relying on such behaviour on all systems.

Child Tickets

Attachments (1)

0001-Check-tor_vasprintf-for-error-return-values.patch (2.5 KB) - added by paldium 2 months ago.

Download all attachments as: .zip

Change History (6)

comment:1 Changed 2 months ago by nickm

Keywords: 035-backport 040-backport 041-backport added
Milestone: Tor: 0.4.2.x-final
Status: newneeds_review

comment:2 Changed 2 months ago by dgoulet

Reviewer: mikeperry

comment:3 Changed 2 weeks ago by nickm

Type: enhancementdefect

Calling this "defect" rather than "enhancement" since the problem is not checking the return value.

comment:4 Changed 6 days ago by teor

Reviewer: mikeperry

Mike is not doing reviews this month, please re-assign.

comment:5 Changed 4 days ago by nickm

Keywords: 042-can added
Note: See TracTickets for help on using tickets.