Skip to content

Instantly share code, notes, and snippets.

@thestinger
Created April 20, 2019 02:43
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save thestinger/9636e9f6d6fd26b2975840b14c9dc77e to your computer and use it in GitHub Desktop.
Save thestinger/9636e9f6d6fd26b2975840b14c9dc77e to your computer and use it in GitHub Desktop.
#include <stdarg.h>
#include <stdio.h>
void foo(unsigned n, ...) {
va_list args;
va_start(args, n);
for (unsigned i = 0; i < n; i++) {
printf("%d\n", va_arg(args, int));
}
va_end(args);
}
int main(void) {
void (*bar)(unsigned, int, int) = (void *)foo;
bar(2, 5, 10);
return 0;
}
% clang foo.c -o foo -fsanitize=cfi-icall -fno-sanitize-trap=cfi-icall -fsanitize-recover=cfi-icall -flto
% ./foo
foo.c:15:5: runtime error: control flow integrity check for type 'void (unsigned int, int, int)' failed during indirect function call
(/home/strcat/foo+0x2a690): note: foo defined here
5
10
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment