Created
February 4, 2020 23:08
-
-
Save sklam/4ec23be55f128e929f0ed2357b239b17 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
/* | |
Compile this with: | |
$ clang -O3 do_no_evil.c && ./a.out | |
Reference http://blog.llvm.org/2011/05/what-every-c-programmer-should-know_14.html | |
*/ | |
#include <stdio.h> | |
#include <stdlib.h> | |
static void (*WhatToDo)() = 0; | |
static void EvilThings() { | |
printf("Do Evil\n"); | |
} | |
void DoNotDoThis() { | |
WhatToDo = EvilThings; | |
printf("Do Not Do This!\n"); | |
// Fail Safe exit | |
exit(1); // Don't do this ever | |
} | |
void DoSomething() { | |
WhatToDo(); | |
} | |
int main() { | |
DoSomething(); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment