Пример #1
0
int main(void) {
  int i = 1;
  dfsan_label i_label = dfsan_create_label("i", 0);
  dfsan_set_label(i_label, &i, sizeof(i));

  int j = 2;
  dfsan_label j_label = dfsan_create_label("j", 0);
  dfsan_set_label(j_label, &j, sizeof(j));

  int k = 3;
  dfsan_label k_label = dfsan_create_label("k", 0);
  dfsan_set_label(k_label, &k, sizeof(k));

  dfsan_label ij_label = dfsan_get_label(i + j);
  assert(dfsan_has_label(ij_label, i_label));
  assert(dfsan_has_label(ij_label, j_label));
  assert(!dfsan_has_label(ij_label, k_label));

  dfsan_label ijk_label = dfsan_get_label(i + j + k);
  assert(dfsan_has_label(ijk_label, i_label));
  assert(dfsan_has_label(ijk_label, j_label));
  assert(dfsan_has_label(ijk_label, k_label));

  return 0;
}
Пример #2
0
void dfrtl_add_input_label(void* addr, size_t size) {
    if (globalInputLabel == 0) {
        printf("WindowRtl: Created global input label\n");
        globalInputLabel = dfsan_create_label("input", 0);
    }
    dfsan_set_label(globalInputLabel, addr, size);
    printf("WindowRtl: Tainted %p size %zd\n", addr, size);
}
Пример #3
0
int main(void) {
  int i = 1;
  dfsan_label i_label = dfsan_create_label("i", 0);
  dfsan_set_label(i_label, &i, sizeof(i));

  dfsan_label ij_label = dfsan_get_label(f(i));
  assert(dfsan_has_label(ij_label, i_label));
  assert(dfsan_has_label_with_desc(ij_label, "j"));

  return 0;
}
Пример #4
0
int main(void) {
  int i = 1;
  dfsan_label i_label = dfsan_create_label("i", 0);
  dfsan_set_label(i_label, &i, sizeof(i));

  // CHECK: WARNING: DataFlowSanitizer: call to uninstrumented function f
  // CHECK-NOT: WARNING: DataFlowSanitizer: saw nonzero label
  // CHECK-NONZERO: WARNING: DataFlowSanitizer: saw nonzero label
  f(i);

  return 0;
}
Пример #5
0
int f(int x) {
  int j = 2;
  dfsan_label j_label = dfsan_create_label("j", 0);
  dfsan_set_label(j_label, &j, sizeof(j));
  return x + j;
}