I'm trying to learn Buffer Overflow Here is the vulnerable code

#include <stdio.h>
#include <string.h>

int main(int argc, char const *argv[])
    char buffer[64];

    if(argc < 2){
        printf("The number of argument is incorrect\n");
        return 1;
    strcpy(buffer, argv[0]);
    return 0;

The problem is that when I try to run the code in Immunity Debugger, I don't see AAAAAAA in the source in the stack pane I see the path to my test.exe. Later, I don't see 0x41s ....obviously

What is happening ?

enter image description here

  • argv[0] is the path to the executable AAAAAA is argument andtherfor it is argv[1] look at your code you are copying wrong argument
    – blabb
    Dec 30, 2020 at 18:33
  • @blabb How di you spot that so quickly. Thank you. That's obviously the issue
    – leila
    Dec 31, 2020 at 9:48
  • @blabb Go ahead and make that into an answer; comments are not a place to answer. Dec 31, 2020 at 23:47
  • @blabb I don't mid accepting your answer instead of Igor's since you were the one actualy helping me solving the issue. It's up to you
    – leila
    Jan 5, 2021 at 8:18
  • @leila Thanks let it be
    – blabb
    Jan 5, 2021 at 13:39

1 Answer 1


To get the program’s argument, you need to check argv[1] instead of argv[0]. From cppreference:

The parameters of the two-parameter form of the main function allow arbitrary multibyte character strings to be passed from the execution environment (these are typically known as command line arguments), the pointers argv[1].. argv[argc-1] point at the first characters in each of these strings. argv[0] is the pointer to the initial character of a null-terminated multibyte string that represents the name used to invoke the program itself (or an empty string "" if this is not supported by the execution environment).

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.