fortify-headers

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

test_vsnprintf_dynamic.c (576B)


      1 #include "common.h"
      2 
      3 #include <stdarg.h>
      4 #include <unistd.h>
      5 
      6 char buffer[8] = {0};
      7 
      8 int msg_valid(int n, const char * format, ... ) {
      9   va_list args;
     10   va_start (args, format);
     11   vsnprintf(buffer, n, format, args);
     12   va_end (args);
     13   return 0;
     14 }
     15 
     16 int msg(int n, const char * format, ... ) {
     17   va_list args;
     18   va_start (args, format);
     19   CHK_FAIL_START
     20   vsnprintf(buffer, n, format, args);
     21   CHK_FAIL_END
     22   va_end (args);
     23   return ret;
     24 }
     25 
     26 int main(int argc, char** argv) {
     27   msg_valid(sizeof(buffer), "%s", "1234567890ABCDEF");
     28   return msg(argc, "%s", "1234567890ABCDEF");
     29 }