Skip to content

Instantly share code, notes, and snippets.

@jmcph4
Last active January 14, 2018 07:48
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jmcph4/95c3220ae04e9dea3ece19b0cb4285d0 to your computer and use it in GitHub Desktop.
Save jmcph4/95c3220ae04e9dea3ece19b0cb4285d0 to your computer and use it in GitHub Desktop.
Simple toy program in C that greets the user with their desired name (fuzzing target)
#include <stdio.h>
#include <stdlib.h>
#define N 16 /* buffer size */
int main(void) {
char name[N]; /* buffer */
/* prompt user for name */
printf("What's your name? ");
scanf("%s", name);
printf("Hi there, %s!\n", name); /* greet the user */
return EXIT_SUCCESS;
}
@jmcph4
Copy link
Author

jmcph4 commented Jan 14, 2018

Note that, in the initial commit, line 11 passed a pointer to name. Compiling with gcc name.c -Wall -Wextra -Wshadow -pedantic -std=c11 -g3 -o name produced the following warning:

name.c: In function 'main`:
name.c:11:13: warning: format '%s` expects argument of type 'char *`, but argument 2 has type 'char (*)[16]` [-Wformat=]
    scanf("%s", &name);
            ^

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment