fortify-headers

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

test_fread_overwrite_static.c (288B)


      1 #include "common.h"
      2 
      3 #include <assert.h>
      4 #include <stdio.h>
      5 
      6 int main(int argc, char** argv) {
      7   char buffer[12] = {0};
      8 
      9   assert((sizeof(buffer) - 2) * 10 > sizeof(buffer));
     10 
     11   CHK_FAIL_START
     12   fread(buffer, sizeof(buffer) - 2, 10, NULL);
     13   CHK_FAIL_END
     14 
     15   puts(buffer);
     16   return ret;
     17 }