Debian Codegraph @

testing/fulltests/unit-tests/T104agentx_parse_cagentlib.c

raw
1 /* HEADER oss-fuzz bug 14502 */
2 /*
3 * Verify whether agentx_parse() does not access any memory outside its
4 * bounds for a particular invalid AgentX input. See also
5 * https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=14502.
6 */
7
8 netsnmp_session session;
9 netsnmp_pdu pdu;
10 int rc;
11 static u_char data[] = {
12 0x20, 0x08, 0x20, 0x20, 0x20, 0x20, 0xff, 0x20,
13 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
14 0x14, 0x00, 0x00, 0x00, 0x44, 0x00, 0x20, 0x20,
15 0x00, 0x20, 0x20, 0xff, 0xff, 0xff, 0xff, 0xff,
16 0xff, 0x20, 0x20, 0x20, 0x20, 0x20, 0xff, 0x20,
17 };
18 static const size_t data_length = sizeof(data);
19
20 memset(&session, 0, sizeof(session));
21 session.version = AGENTX_VERSION_1;
22
23 memset(&pdu, 0, sizeof(pdu));
24
25 rc = agentx_parse(&session, &pdu, data, data_length);
26
27 fprintf(stderr, "rc = %d\n", rc);
28 fflush(stderr);
29
30 OKF(rc != 0, ("Parsing of AgentX data failed"));
31
32 netsnmp_cleanup_session(&session);