Opened 5 years ago

Closed 5 years ago

Last modified 5 years ago

#13036 closed defect (fixed)

Uninitialised Variable & NULL Pointer Dereference Warnings in Clang

Reported by: teor Owned by:
Priority: Medium Milestone: Tor: 0.2.5.x-final
Component: Core Tor/Tor Version: Tor: 0.2.5.5-alpha
Severity: Keywords: 025-backport tor-relay
Cc: nickm Actual Points:
Parent ID: Points:
Reviewer: Sponsor:

Description

clang and clang --analyze produces around 10 uninitialised variable and NULL pointer dereference warnings when compiling tor from git source on OS X.

Some of these warnings may be incorrect, but I've checked the context of the warnings, and the logic that ensures each variable is valid isn't obvious to me (or clang). But I might be missing something.

The attached patches resolve these warnings by initialising the variables, and / or asserting valid values before variables are read.

These warnings occur in the git source of tor 0.2.6.0?-alpha around 1 September 2014
e.g. commit 67c0ad54263be7fb742a8d499f97f5908f9ec970

Child Tickets

Attachments (2)

uninit-variables.patch (3.9 KB) - added by teor 5 years ago.
Patch Initialise and Check Variables Before Use
null-dereference.patch (885 bytes) - added by teor 5 years ago.
Patch Assert Not NULL Based on Warnings

Download all attachments as: .zip

Change History (7)

Changed 5 years ago by teor

Attachment: uninit-variables.patch added

Patch Initialise and Check Variables Before Use

Changed 5 years ago by teor

Attachment: null-dereference.patch added

Patch Assert Not NULL Based on Warnings

comment:1 Changed 5 years ago by nickm

Keywords: 025-backport tor-relay added
Milestone: Tor: 0.2.6.x-final

comment:2 Changed 5 years ago by nickm

Status: newneeds_review

comment:3 Changed 5 years ago by nickm

These are all false positives, but it won't actually hurt to merge them. I'll apply them to 0.2.5 and later. (I've picked 0.2.5 so we can get better clang analyzer results for the 0.2.5 series.)

comment:4 Changed 5 years ago by nickm

Milestone: Tor: 0.2.6.x-finalTor: 0.2.5.x-final
Resolution: fixed
Status: needs_reviewclosed

Merged; thanks!

comment:5 Changed 5 years ago by teor

Thanks, Nick.

Note: See TracTickets for help on using tickets.