Created
April 20, 2019 02:43
-
-
Save thestinger/9636e9f6d6fd26b2975840b14c9dc77e to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#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; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
% 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