format string 3
This commit is contained in:
31
format_string_3/format-string-3.c
Normal file
31
format_string_3/format-string-3.c
Normal file
@@ -0,0 +1,31 @@
|
||||
#include <stdio.h>
|
||||
|
||||
#define MAX_STRINGS 32
|
||||
|
||||
char *normal_string = "/bin/sh";
|
||||
|
||||
void setup() {
|
||||
setvbuf(stdin, NULL, _IONBF, 0);
|
||||
setvbuf(stdout, NULL, _IONBF, 0);
|
||||
setvbuf(stderr, NULL, _IONBF, 0);
|
||||
}
|
||||
|
||||
void hello() {
|
||||
puts("Howdy gamers!");
|
||||
printf("Okay I'll be nice. Here's the address of setvbuf in libc: %p\n", &setvbuf);
|
||||
}
|
||||
|
||||
int main() {
|
||||
char *all_strings[MAX_STRINGS] = {NULL};
|
||||
char buf[1024] = {'\0'};
|
||||
|
||||
setup();
|
||||
hello();
|
||||
|
||||
fgets(buf, 1024, stdin);
|
||||
printf(buf);
|
||||
|
||||
puts(normal_string);
|
||||
|
||||
return 0;
|
||||
}
|
||||
Reference in New Issue
Block a user