aboutsummaryrefslogtreecommitdiff
path: root/overflow.c
diff options
context:
space:
mode:
authordev0 <matzeton@googlemail.com>2012-01-30 21:32:05 +0100
committerdev0 <matzeton@googlemail.com>2012-01-30 21:32:05 +0100
commit9871847cc1fd94274cf02c4bfb1453a7ee31c298 (patch)
tree4161b57385a5df27a66c7c72b4fd045800518196 /overflow.c
parent984bda19a6a21635d5f7ce2abf97c91cddcd0b12 (diff)
- arg support
Diffstat (limited to 'overflow.c')
-rw-r--r--overflow.c21
1 files changed, 15 insertions, 6 deletions
diff --git a/overflow.c b/overflow.c
index 64fc483..1e33b2d 100644
--- a/overflow.c
+++ b/overflow.c
@@ -10,16 +10,22 @@
#include <string.h>
#define ENV_VAR "EXPLOIT"
-#define BUFLEN 64
+#define BUFLEN 2
char buf[BUFLEN];
char *env;
int
-main()
+main(int argc, char **argv)
{
- fprintf(stderr, "buflen: %d\nenv_var: %s\n\n", BUFLEN, ENV_VAR);
- if ( (env = getenv(ENV_VAR)) )
+ fprintf(stderr, "buflen: %d\nenv_var: %s\nargs: %d\n\n", BUFLEN, ENV_VAR, (argc - 1));
+ if (argc > 1)
+ {
+ fprintf(stderr, "arg0: %s\n", argv[1]);
+
+ strcpy(buf, argv[1]);
+ }
+ else if ((env = getenv(ENV_VAR)))
{
fprintf(stderr, "env_var: "ENV_VAR"\n");
fprintf(stderr, "env: %s\n", env);
@@ -28,8 +34,11 @@ main()
}
else
{
- fprintf(stderr, "env_var: "ENV_VAR" not set, abort!\n");
+ fprintf(stderr, "neither env_var ("ENV_VAR") set or arg0 given, abort!\n");
+ return(1);
}
- return(0);
+ printf("buf: %p\n", buf);
+
+ return (0);
}