fortify-headers

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

test_sprintf_62.c (344B)


      1 #include "common.h"
      2 
      3 #include <stdio.h>
      4 
      5 static char *offstr(char *str)
      6 {
      7 	int len = 0;
      8 
      9 	len = sprintf(str, "%s+0x%lx", "foo", (long unsigned int)0);
     10 	sprintf(str+len, " (%s+0x%lx)","bar", (long unsigned int)0);
     11 	if (len < 0)
     12 		return NULL;
     13 	return str;
     14 }
     15 
     16 int main() {
     17 	char buf[100];
     18 	char *c = offstr(buf);
     19 	printf("%s\n", c);
     20 	return 0;
     21 }