This is an archive of the discontinued LLVM Phabricator instance.

[clang-tidy] Check for sigaction in cert-sig30-c.
Needs ReviewPublic

Authored by balazske on Sep 23 2020, 2:43 AM.

Details

Summary

The checker recognizes handlers assigned to members of a
"struct sigaction" variable. If a function is assigned to
these members it is assumable that the function is used as signal handler
(function 'sigaction' is called with it).
Without this simplification the check is possible only in path-sensitive way.

Diff Detail

Event Timeline

balazske created this revision.Sep 23 2020, 2:43 AM
Herald added a project: Restricted Project. · View Herald TranscriptSep 23 2020, 2:43 AM
balazske requested review of this revision.Sep 23 2020, 2:43 AM
Eugene.Zelenko added a project: Restricted Project.
aaron.ballman added inline comments.Sep 25 2020, 6:11 AM
clang-tools-extra/clang-tidy/cert/SignalHandlerCheck.cpp
91

You should be checking for the fully-qualified name so that this doesn't trip it up:

namespace awesome {
struct sigaction {
  const char *terrible = "haha";
};
}
92

I'd like to see a test case that this works properly with references in C++ (in addition to pointers).

clang-tools-extra/test/clang-tidy/checkers/cert-sig30-c.cpp
152

I'd like to see a test case that shows this works if the sigaction object is within another structure. e.g.,

struct foo {
  struct sigaction act;
};

void test(void) {
  struct foo f;
  f.act.sa_handler = handler_sigaction5;
}
MTC added a subscriber: MTC.Aug 16 2021, 7:18 PM