void testTaintSystemCall3() { char buffern2[156]; int numt; char addr[128]; scanf("%s %d", addr, &numt); __builtin_snprintf(buffern2, numt, "/bin/mail %s < /tmp/email", "abcd"); system(buffern2); // expected-warning {{Untrusted data is passed to a system call}} }
void testTaintSystemCall2() { // Test that snpintf transfers taint. char buffern[156]; char addr[128]; scanf("%s", addr); __builtin_snprintf(buffern, 10, "/bin/mail %s < /tmp/email", addr); system(buffern); // expected-warning {{Untrusted data is passed to a system call}} }
int f1 (const char *s) { int n = __builtin_snprintf (buf, 64, "%.*s%08x", 1, s, 1); ASSERT (7 < n && n < 10); ASSERT_MAYBE (8 == n); ASSERT_MAYBE (9 == n); return n; }
int f2 (const char *s) { int n = __builtin_snprintf (0, 0, "%.*s", 2, s); ASSERT (0 <= n && n <= 2); ASSERT_MAYBE (0 == n); ASSERT_MAYBE (1 == n); ASSERT_MAYBE (2 == n); return n; }