Last active
December 17, 2015 14:59
-
-
Save 0xabad1dea/5628766 to your computer and use it in GitHub Desktop.
A deceitful C program
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
// hello clever programmers, would you like to play a game? | |
// where's the bug? | |
// by 0xabad1dea :) | |
#include <stdio.h> | |
#include <string.h> | |
int main() { | |
char input[16] = "stringstring!!!"; | |
char output[8]; | |
//so this will leave it not terminated// | |
strncpy(output, input, 8); | |
//but this will fix it right??/ | |
output[7] = '\0'; | |
//so what happens here?// | |
printf("%s\n", output); | |
return 0; | |
} | |
// HINT: the behavior of this program depends on whether your | |
// compiler has turned ON or OFF a certain genuine ANSI C feature! | |
// also, modern stack protectors will keep this from being | |
// usefully exploitable, but that's besides the point |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
I've never actually seen trigraphs being used anywhere. interesting code sample none the less though.