aboutsummaryrefslogtreecommitdiff
path: root/lib/asan/tests/strncpy-overflow.cc
blob: 044f6494bfa1778968b50508a43f2d9e7cc29ffd (plain) (blame)
1
2
3
4
5
6
7
8
9
#include <string.h>
#include <stdlib.h>
int main(int argc, char **argv) {
  char *hello = (char*)malloc(6);
  strcpy(hello, "hello");
  char *short_buffer = (char*)malloc(9);
  strncpy(short_buffer, hello, 10);  // BOOM
  return short_buffer[8];
}