0

Here is a main "problem". Code:

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

int main(int argc, char **argv){
    char buf[10];
    strcpy(buf,argv[1]);

    printf("%s",buf);

    return 0;
 }

I'm trying overflow stack like that:

gcc main.c -o runMe
./runMe "$(printf '%.sA' {1..15})"

But output is clear. No overflow. So ... what the heck???

klutt
  • 30,332
  • 17
  • 55
  • 95
Tima Chedr
  • 11
  • 2
  • I get a segfault doing that.. so I would guess it depends on your OS memory atm ? What are you exactly trying to do? – Angevil Mar 13 '21 at 20:22
  • [Undefined behaviour](https://en.cppreference.com/w/cpp/language/ub). – G.M. Mar 13 '21 at 20:22
  • What do you expect to happen when the buffer overflows? If you can be more specific about the compiler you are using, your target platform, and what you expect to achieve (i.e. hijack the return address), the community would be more willing to help. – ph3rin Mar 13 '21 at 20:23
  • 2
    I didn't cause an accident when I ran a red light yesterday. Must have been unlucky. – Weather Vane Mar 13 '21 at 20:24
  • Don't tag spam. This is C and not C++. – klutt Mar 13 '21 at 20:33

0 Answers0