fortify-headers

standalone fortify-source implementation
git clone git://git.2f30.org/fortify-headers
Log | Files | Refs | README | LICENSE

test_strncpy_static_write.c (315B)


      1 #include "common.h"
      2 
      3 #include <string.h>
      4 
      5 int main(int argc, char** argv) {
      6   char buffer[8] = {0};
      7   char src[] = {'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L'};
      8 
      9   strncpy(buffer, src, 5);
     10   puts(buffer);
     11 
     12   CHK_FAIL_START
     13   strncpy(buffer, src, 10);
     14   CHK_FAIL_END
     15 
     16   puts(buffer);
     17   return ret;
     18 }