File: sigaction.cc

package info (click to toggle)
llvm-toolchain-6.0 1%3A6.0.1-10
  • links: PTS, VCS
  • area: main
  • in suites: buster
  • size: 598,080 kB
  • sloc: cpp: 3,046,253; ansic: 595,057; asm: 271,965; python: 128,926; objc: 106,554; sh: 21,906; lisp: 10,191; pascal: 6,094; ml: 5,544; perl: 5,265; makefile: 2,227; cs: 2,027; xml: 686; php: 212; csh: 117
file content (47 lines) | stat: -rw-r--r-- 1,218 bytes parent folder | download | duplicates (44)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
// RUN: %clangxx_msan -std=c++11 -O0 -g %s -o %t
// RUN: %run %t __
// RUN: not %run %t A_ 2>&1 | FileCheck %s
// RUN: not %run %t AH 2>&1 | FileCheck %s
// RUN: not %run %t B_ 2>&1 | FileCheck %s
// RUN: not %run %t BH 2>&1 | FileCheck %s
// RUN: not %run %t C_ 2>&1 | FileCheck %s
// RUN: not %run %t CH 2>&1 | FileCheck %s

#include <assert.h>
#include <signal.h>
#include <string.h>
#include <sys/time.h>
#include <unistd.h>

#include <sanitizer/msan_interface.h>

void handler(int) {}
void action(int, siginfo_t *, void *) {}

int main(int argc, char **argv) {
  char T = argv[1][0];
  char H = argv[1][1];
  struct sigaction sa;
  memset(&sa, 0, sizeof(sa));
  if (H == 'H') {
    sa.sa_handler = handler;
  } else {
    sa.sa_sigaction = action;
    sa.sa_flags = SA_SIGINFO;
  }

  if (T == 'A') {
    if (H == 'H')
      __msan_poison(&sa.sa_handler, sizeof(sa.sa_handler));
    else
      __msan_poison(&sa.sa_sigaction, sizeof(sa.sa_sigaction));
  }
  if (T == 'B')
    __msan_poison(&sa.sa_flags, sizeof(sa.sa_flags));
  if (T == 'C')
    __msan_poison(&sa.sa_mask, sizeof(sa.sa_mask));
  // CHECK: use-of-uninitialized-value
  int res = sigaction(SIGUSR1, &sa, nullptr);
  assert(res == 0);
  return 0;
}