unistd: Improve fortify with clang
[glibc.git] / stdio-common / bug12.c
blob1ba296deb43c0e41b687e950860b5dab45e72da6
1 #include <stdio.h>
2 #include <string.h>
4 #include <support/xstdio.h>
6 char x[4096], z[4096], b[21], m[4096 * 4];
8 int
9 main (void)
11 FILE *f = tmpfile ();
12 int i, failed = 0;
14 memset (x, 'x', 4096);
15 memset (z, 'z', 4096);
16 b[20] = 0;
18 for (i = 0; i <= 5; i++)
20 fwrite (x, 4096, 1, f);
21 fwrite (z, 4096, 1, f);
23 rewind (f);
25 xfread (m, 4096 * 4 - 10, 1, f);
26 xfread (b, 20, 1, f);
27 printf ("got %s (should be %s)\n", b, "zzzzzzzzzzxxxxxxxxxx");
28 if (strcmp (b, "zzzzzzzzzzxxxxxxxxxx"))
29 failed = 1;
31 fseek (f, -40, SEEK_CUR);
32 xfread (b, 20, 1, f);
33 printf ("got %s (should be %s)\n", b, "zzzzzzzzzzzzzzzzzzzz");
34 if (strcmp (b, "zzzzzzzzzzzzzzzzzzzz"))
35 failed = 1;
37 xfread (b, 20, 1, f);
38 printf ("got %s (should be %s)\n", b, "zzzzzzzzzzxxxxxxxxxx");
39 if (strcmp (b, "zzzzzzzzzzxxxxxxxxxx"))
40 failed = 1;
42 xfread (b, 20, 1, f);
43 printf ("got %s (should be %s)\n", b, "xxxxxxxxxxxxxxxxxxxx");
44 if (strcmp (b, "xxxxxxxxxxxxxxxxxxxx"))
45 failed = 1;
47 return failed;