fortify-headers

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

test_swab_negative.c (341B)


      1 #include "common.h"
      2 
      3 #include <unistd.h>
      4 
      5 int main(int argc, char** argv) {
      6   char src[8] = "ABCDEFG";
      7   char dst[8] = {0};
      8 
      9   /* Positive case: normal swab works */
     10   swab(src, dst, 6);
     11   puts(dst);
     12 
     13   /* Negative n: POSIX says swab does nothing, must NOT trap */
     14   swab(src, dst, -1);
     15   swab(src, dst, -100);
     16 
     17   puts(dst);
     18   return ret;
     19 }