Skip to content

GitLab

  • Menu
Projects Groups Snippets
  • Help
    • Help
    • Support
    • Community forum
    • Submit feedback
    • Contribute to GitLab
  • Sign in
  • Tor Tor
  • Project information
    • Project information
    • Activity
    • Labels
    • Members
  • Repository
    • Repository
    • Files
    • Commits
    • Branches
    • Tags
    • Contributors
    • Graph
    • Compare
  • Issues 823
    • Issues 823
    • List
    • Boards
    • Service Desk
    • Milestones
  • Merge requests 33
    • Merge requests 33
  • CI/CD
    • CI/CD
    • Pipelines
    • Jobs
    • Schedules
  • Deployments
    • Deployments
    • Environments
    • Releases
  • Monitor
    • Monitor
    • Incidents
  • Analytics
    • Analytics
    • Value stream
    • CI/CD
    • Repository
  • Activity
  • Graph
  • Create a new issue
  • Jobs
  • Commits
  • Issue Boards
Collapse sidebar
  • The Tor Project
  • Core
  • TorTor
  • Issues
  • #13157
Closed
Open
Created Sep 14, 2014 by teor@teor

[patch] Clang Analyzer: Spurious Warnings 2

After legacy/trac#13036 (moved) was committed, clang --analyze continued to produce 2 existing NULL pointer dereference warnings; and 1 new uninitialised variable warning. I am compiling tor from git source on OS X.

== 01-in6-addr32-not-null.patch

The NULL pointer warnings on the return value of tor_addr_to_in6_addr32() are incorrect. But clang can't work this out itself due to limited analysis depth. To teach the analyser that the return value is safe to dereference, I applied tor_assert to the return value. This assert can optionally be wrapped in:

#if !defined(__clang_analyzer__) || PARANOIA

or similar, if performance is an issue in this code. The assertion silences the spurious warning.

== 02-dirserv-init-msg.patch

At this point in the code, msg has been set to a string constant. But the tor code checks that msg is not NULL, and the redundant NULL check confuses the analyser:

      log_info(LD_DIRSERV, "Router %s is now rejected: %s",
               description, msg?msg:"");

To avoid this spurious warning, the patch initialises msg to NULL.

== clang --analyze clean!

Once these patches are applied, tor is clang --analyze clean, except for dead stores. (Which I trust the optimiser to remove in most cases.)

== git version

These warnings occur in the git source of tor 0.2.6.?-alpha around 14 September 2014 e.g. commit d6b2a170

To upload designs, you'll need to enable LFS and have an admin enable hashed storage. More information
Assignee
Assign to
Time tracking