GCC Code Coverage Report
Directory: ../src/ Exec Total Coverage
File: /home/node-core-coverage/node-core-coverage/workdir/node/out/../src/node_revert.cc Lines: 0 12 0.0 %
Date: 2016-12-16 Branches: 0 0 0.0 %

Line Branch Exec Source
1
#include "node_revert.h"
2
#include <stdio.h>
3
#include <string.h>
4
5
namespace node {
6
7
unsigned int reverted = 0;
8
9
const char* RevertMessage(const unsigned int cve) {
10
#define V(code, label, msg) case REVERT_ ## code: return label ": " msg;
11
  switch (cve) {
12
    REVERSIONS(V)
13
    default:
14
      return "Unknown";
15
  }
16
#undef V
17
}
18
19
void Revert(const unsigned int cve) {
20
  reverted |= 1 << cve;
21
  printf("SECURITY WARNING: Reverting %s\n", RevertMessage(cve));
22
}
23
24
void Revert(const char* cve) {
25
#define V(code, label, _)                                                     \
26
  do {                                                                        \
27
    if (strcmp(cve, label) == 0) {                                            \
28
      Revert(static_cast<unsigned int>(REVERT_ ## code));                     \
29
      return;                                                                 \
30
    }                                                                         \
31
  } while (0);
32
  REVERSIONS(V)
33
#undef V
34
  printf("Error: Attempt to revert an unknown CVE [%s]\n", cve);
35
  exit(12);
36
}
37
38
bool IsReverted(const unsigned int cve) {
39
  return reverted & (1 << cve);
40
}
41
42
bool IsReverted(const char * cve) {
43
#define V(code, label, _)                                                     \
44
  do {                                                                        \
45
    if (strcmp(cve, label) == 0)                                              \
46
      return IsReverted(static_cast<unsigned int>(REVERT_ ## code));          \
47
  } while (0);
48
  REVERSIONS(V)
49
  return false;
50
#undef V
51
}
52
53
}  // namespace node