Last active
January 4, 2016 02:39
-
-
Save thesp0nge/8556620 to your computer and use it in GitHub Desktop.
Is a functional bug a security issue?
This file contains hidden or 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 <stdio.h> | |
| #include <stdlib.h> | |
| void do_something_with_it(char *c) { | |
| strncpy(c, "antani", 4095); | |
| return; | |
| } | |
| int main(int argc, char **argv) { | |
| // my specs would require I process 1000 entries, instead I introduce a bug processing just 999 | |
| for (int i=1; i<1000; i++) { | |
| c = malloc(4096*sizeof(char); | |
| do_something_with_it(c); | |
| free(c); | |
| } | |
| // as variant, you can consider to mispell the for cycle the other side, missing the <= sign. | |
| for (int i=0; i<999; i++) { | |
| c = malloc(4096*sizeof(char); | |
| do_something_with_it(c); | |
| free(c); | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment