title: GCC how to detect stack buffer overflow
body: <p>Since there is an option <code>-fstack-protector-strong</code> in gcc to detect stack smashing. However, it can not always detect stack buffer overflow. For the first function func, when I input a 10 char more string, the program does not always crash. My question is where there is a way to detect stack buffer overflow.</p>
  
  <pre><code>void func()
  {
      char array[10];
      gets(array);
  }
  
  void func2()
  {
      char buffer[10];
      int n = sprintf(buffer, "%s", "abcdefghpapeas");
      printf("aaaa [%d], [%s]\n", n, buffer);
  }
  
  int main ()
  {
     func();
     func2();
  }
  </code></pre>