Debian Codegraph @

testing/fulltests/unit-tests/T027read_mib_clib.c

raw
1 /*
2 * HEADER Testing read_mib()
3 *
4 * See also https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=37187.
5 * See also https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=39320.
6 */
7
8 static const char* mibs[] = {
9 "qu::=Opaque(SIZE(SI4-\n"
10 "--\n"
11 "--\n"
12 "--\n"
13 "--\n"
14 "--\n"
15 "--\n"
16 "--\n"
17 "OCTETSTRING\n"
18 "----\n"
19 "--\n"
20 "--\n"
21 "---\n"
22 "--\n"
23 "--\n"
24 "-68--------------------1844674407370954460124----DD-IIIIIIIIIII0NZe9223300000446069494I32768g-I2768g-I3gg-I4g-55I420RPRISEOONOAO:\x001\0\0---::=\0||231\0\0\0\x001=O",
25 "102H::={1365\x93""-72}1H::={1\x93""1}0H::={0\x93""0}"
26 };
27
28 char *path;
29 FILE *f;
30 int i, res;
31
32 res = asprintf(&path, "/tmp/read-mib-input-%d", getpid());
33 OKF(res >= 0, ("asprintf() returned %d", res));
34 for (i = 0; i < sizeof(mibs) / sizeof(mibs[0]); i++) {
35 f = fopen(path, "wb");
36 OKF(f != NULL, ("fopen() %s", f ? "succeeded" : "failed"));
37 res = fwrite(mibs[i], strlen(mibs[i]), 1, f);
38 OKF(res == 1, ("fwrite() %s", res == 1 ? "succeeded" : "failed"));
39 fclose(f);
40 read_mib(path);
41 unlink(path);
42 }
43 free(path);