fortify-headers

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

test_stpncpy_overwrite_over.c (306B)


      1 #include "common.h"
      2 
      3 #include <string.h>
      4 
      5 int main(int argc, char** argv) {
      6   char buffer[9] = {'A', 'A', 'A', 'A', 'B', 'B', 'B', 'B', '\0'};
      7   puts(buffer);
      8 
      9   stpncpy(buffer, buffer+5, 2);
     10   puts(buffer);
     11 
     12   CHK_FAIL_START
     13   stpncpy(buffer+1, buffer, 5);
     14   CHK_FAIL_END
     15 
     16   puts(buffer);
     17   return ret;
     18 }