Sign Up
Log In
Log In
or
Sign Up
Places
All Projects
Status Monitor
Collapse sidebar
home:lafenghu
net-snmp
net-snmp-5.7.1-more-robust-handling-of-agentx-e...
Overview
Repositories
Revisions
Requests
Users
Attributes
Meta
File net-snmp-5.7.1-more-robust-handling-of-agentx-errors.patch of Package net-snmp
commit 2a17b37430c1852998c3588e547d7eb61c06da71 Author: Dave Shield <D.T.Shield@liverpool.ac.uk> Date: Tue Dec 27 21:45:38 2011 +0000 CHANGES: agentx: PATCHES: 3445440: More robust handling of AgentX errors Patch provided by Bill Fenner Index: net-snmp-5.7.1/agent/mibgroup/agentx/subagent.c =================================================================== --- net-snmp-5.7.1.orig/agent/mibgroup/agentx/subagent.c +++ net-snmp-5.7.1/agent/mibgroup/agentx/subagent.c @@ -243,6 +243,24 @@ free_set_vars(netsnmp_session * ss, nets } #endif /* !NETSNMP_NO_WRITE_SUPPORT */ +static void +send_agentx_error(netsnmp_session *session, netsnmp_pdu *pdu, int errstat, int errindex) +{ + pdu = snmp_clone_pdu(pdu); + pdu->command = AGENTX_MSG_RESPONSE; + pdu->version = session->version; + pdu->errstat = errstat; + pdu->errindex = errindex; + snmp_free_varbind(pdu->variables); + pdu->variables = NULL; + + DEBUGMSGTL(("agentx/subagent", "Sending AgentX response error stat %d idx %d\n", + errstat, errindex)); + if (!snmp_send(session, pdu)) { + snmp_free_pdu(pdu); + } +} + int handle_agentx_packet(int operation, netsnmp_session * session, int reqid, netsnmp_pdu *pdu, void *magic) @@ -327,6 +345,7 @@ handle_agentx_packet(int operation, nets (ns_subagent_magic *) calloc(1, sizeof(ns_subagent_magic)); if (smagic == NULL) { DEBUGMSGTL(("agentx/subagent", "couldn't malloc() smagic\n")); + /* would like to send_agentx_error(), but it needs memory too */ return 1; } smagic->original_command = pdu->command; @@ -391,6 +410,7 @@ handle_agentx_packet(int operation, nets if (asi == NULL) { SNMP_FREE(smagic); snmp_log(LOG_WARNING, "save_set_vars() failed\n"); + send_agentx_error(session, pdu, AGENTX_ERR_PARSE_FAILED, 0); return 1; } asi->mode = pdu->command = SNMP_MSG_INTERNAL_SET_RESERVE1; @@ -404,6 +424,7 @@ handle_agentx_packet(int operation, nets if (asi == NULL) { SNMP_FREE(smagic); snmp_log(LOG_WARNING, "restore_set_vars() failed\n"); + send_agentx_error(session, pdu, AGENTX_ERR_PROCESSING_ERROR, 0); return 1; } if (asi->mode != SNMP_MSG_INTERNAL_SET_RESERVE2) { @@ -411,6 +432,7 @@ handle_agentx_packet(int operation, nets snmp_log(LOG_WARNING, "dropping bad AgentX request (wrong mode %d)\n", asi->mode); + send_agentx_error(session, pdu, AGENTX_ERR_PROCESSING_ERROR, 0); return 1; } asi->mode = pdu->command = SNMP_MSG_INTERNAL_SET_ACTION; @@ -424,6 +446,7 @@ handle_agentx_packet(int operation, nets if (asi == NULL) { SNMP_FREE(smagic); snmp_log(LOG_WARNING, "restore_set_vars() failed\n"); + send_agentx_error(session, pdu, AGENTX_ERR_PROCESSING_ERROR, 0); return 1; } if (asi->mode == SNMP_MSG_INTERNAL_SET_RESERVE1 ||
Locations
Projects
Search
Status Monitor
Help
OpenBuildService.org
Documentation
API Documentation
Code of Conduct
Contact
Support
@OBShq
Terms
openSUSE Build Service is sponsored by
The Open Build Service is an
openSUSE project
.
Sign Up
Log In
Places
Places
All Projects
Status Monitor