|
|
91f3ae |
From 4589352dac3ae111c7621298cf231742209efd9b Mon Sep 17 00:00:00 2001
|
|
|
91f3ae |
From: Bill Fenner <fenner@gmail.com>
|
|
|
91f3ae |
Date: Fri, 25 Nov 2022 08:41:24 -0800
|
|
|
91f3ae |
Subject: [PATCH 1/3] snmp_agent: disallow SET with NULL varbind
|
|
|
91f3ae |
|
|
|
91f3ae |
---
|
|
|
91f3ae |
agent/snmp_agent.c | 32 ++++++++++++++++++++++++++++++++
|
|
|
91f3ae |
1 file changed, 32 insertions(+)
|
|
|
91f3ae |
|
|
|
91f3ae |
diff --git a/agent/snmp_agent.c b/agent/snmp_agent.c
|
|
|
91f3ae |
index 867d0c166f..3f678fe2df 100644
|
|
|
91f3ae |
--- a/agent/snmp_agent.c
|
|
|
91f3ae |
+++ b/agent/snmp_agent.c
|
|
|
91f3ae |
@@ -3719,12 +3719,44 @@ netsnmp_handle_request(netsnmp_agent_session *asp, int status)
|
|
|
91f3ae |
return 1;
|
|
|
91f3ae |
}
|
|
|
91f3ae |
|
|
|
91f3ae |
+static int
|
|
|
91f3ae |
+check_set_pdu_for_null_varbind(netsnmp_agent_session *asp)
|
|
|
91f3ae |
+{
|
|
|
91f3ae |
+ int i;
|
|
|
91f3ae |
+ netsnmp_variable_list *v = NULL;
|
|
|
91f3ae |
+
|
|
|
91f3ae |
+ for (i = 1, v = asp->pdu->variables; v != NULL; i++, v = v->next_variable) {
|
|
|
91f3ae |
+ if (v->type == ASN_NULL) {
|
|
|
91f3ae |
+ /*
|
|
|
91f3ae |
+ * Protect SET implementations that do not protect themselves
|
|
|
91f3ae |
+ * against wrong type.
|
|
|
91f3ae |
+ */
|
|
|
91f3ae |
+ DEBUGMSGTL(("snmp_agent", "disallowing SET with NULL var for varbind %d\n", i));
|
|
|
91f3ae |
+ asp->index = i;
|
|
|
91f3ae |
+ return SNMP_ERR_WRONGTYPE;
|
|
|
91f3ae |
+ }
|
|
|
91f3ae |
+ }
|
|
|
91f3ae |
+ return SNMP_ERR_NOERROR;
|
|
|
91f3ae |
+}
|
|
|
91f3ae |
+
|
|
|
91f3ae |
int
|
|
|
91f3ae |
handle_pdu(netsnmp_agent_session *asp)
|
|
|
91f3ae |
{
|
|
|
91f3ae |
int status, inclusives = 0;
|
|
|
91f3ae |
netsnmp_variable_list *v = NULL;
|
|
|
91f3ae |
|
|
|
91f3ae |
+#ifndef NETSNMP_NO_WRITE_SUPPORT
|
|
|
91f3ae |
+ /*
|
|
|
91f3ae |
+ * Check for ASN_NULL in SET request
|
|
|
91f3ae |
+ */
|
|
|
91f3ae |
+ if (asp->pdu->command == SNMP_MSG_SET) {
|
|
|
91f3ae |
+ status = check_set_pdu_for_null_varbind(asp);
|
|
|
91f3ae |
+ if (status != SNMP_ERR_NOERROR) {
|
|
|
91f3ae |
+ return status;
|
|
|
91f3ae |
+ }
|
|
|
91f3ae |
+ }
|
|
|
91f3ae |
+#endif /* NETSNMP_NO_WRITE_SUPPORT */
|
|
|
91f3ae |
+
|
|
|
91f3ae |
/*
|
|
|
91f3ae |
* for illegal requests, mark all nodes as ASN_NULL
|
|
|
91f3ae |
*/
|
|
|
91f3ae |
|
|
|
91f3ae |
From 7f4ac4051cc7fec6a5944661923acb95cec359c7 Mon Sep 17 00:00:00 2001
|
|
|
91f3ae |
From: Bill Fenner <fenner@gmail.com>
|
|
|
91f3ae |
Date: Fri, 25 Nov 2022 08:41:46 -0800
|
|
|
91f3ae |
Subject: [PATCH 2/3] apps: snmpset: allow SET with NULL varbind for testing
|
|
|
91f3ae |
|
|
|
91f3ae |
---
|
|
|
91f3ae |
apps/snmpset.c | 1 +
|
|
|
91f3ae |
1 file changed, 1 insertion(+)
|
|
|
91f3ae |
|
|
|
91f3ae |
diff --git a/apps/snmpset.c b/apps/snmpset.c
|
|
|
91f3ae |
index 48e14bd513..d542713e1b 100644
|
|
|
91f3ae |
--- a/apps/snmpset.c
|
|
|
91f3ae |
+++ b/apps/snmpset.c
|
|
|
91f3ae |
@@ -182,6 +182,7 @@ main(int argc, char *argv[])
|
|
|
91f3ae |
case 'x':
|
|
|
91f3ae |
case 'd':
|
|
|
91f3ae |
case 'b':
|
|
|
91f3ae |
+ case 'n': /* undocumented */
|
|
|
91f3ae |
#ifdef NETSNMP_WITH_OPAQUE_SPECIAL_TYPES
|
|
|
91f3ae |
case 'I':
|
|
|
91f3ae |
case 'U':
|
|
|
91f3ae |
|
|
|
91f3ae |
From 15f9d7f7e5b90c9b419832ed8e6413feb6570d83 Mon Sep 17 00:00:00 2001
|
|
|
91f3ae |
From: Bill Fenner <fenner@gmail.com>
|
|
|
91f3ae |
Date: Fri, 25 Nov 2022 10:23:32 -0800
|
|
|
91f3ae |
Subject: [PATCH 3/3] Add test for NULL varbind set
|
|
|
91f3ae |
|
|
|
91f3ae |
---
|
|
|
91f3ae |
.../default/T0142snmpv2csetnull_simple | 31 +++++++++++++++++++
|
|
|
91f3ae |
1 file changed, 31 insertions(+)
|
|
|
91f3ae |
create mode 100644 testing/fulltests/default/T0142snmpv2csetnull_simple
|
|
|
91f3ae |
|
|
|
91f3ae |
diff --git a/testing/fulltests/default/T0142snmpv2csetnull_simple b/testing/fulltests/default/T0142snmpv2csetnull_simple
|
|
|
91f3ae |
new file mode 100644
|
|
|
91f3ae |
index 0000000000..0f1b8f386b
|
|
|
91f3ae |
--- /dev/null
|
|
|
91f3ae |
+++ b/testing/fulltests/default/T0142snmpv2csetnull_simple
|
|
|
91f3ae |
@@ -0,0 +1,31 @@
|
|
|
91f3ae |
+#!/bin/sh
|
|
|
91f3ae |
+
|
|
|
91f3ae |
+. ../support/simple_eval_tools.sh
|
|
|
91f3ae |
+
|
|
|
91f3ae |
+HEADER SNMPv2c set of system.sysContact.0 with NULL varbind
|
|
|
91f3ae |
+
|
|
|
91f3ae |
+SKIPIF NETSNMP_DISABLE_SET_SUPPORT
|
|
|
91f3ae |
+SKIPIF NETSNMP_NO_WRITE_SUPPORT
|
|
|
91f3ae |
+SKIPIF NETSNMP_DISABLE_SNMPV2C
|
|
|
91f3ae |
+SKIPIFNOT USING_MIBII_SYSTEM_MIB_MODULE
|
|
|
91f3ae |
+
|
|
|
91f3ae |
+#
|
|
|
91f3ae |
+# Begin test
|
|
|
91f3ae |
+#
|
|
|
91f3ae |
+
|
|
|
91f3ae |
+# standard V2C configuration: testcomunnity
|
|
|
91f3ae |
+snmp_write_access='all'
|
|
|
91f3ae |
+. ./Sv2cconfig
|
|
|
91f3ae |
+STARTAGENT
|
|
|
91f3ae |
+
|
|
|
91f3ae |
+CAPTURE "snmpget -On $SNMP_FLAGS -c testcommunity -v 2c $SNMP_TRANSPORT_SPEC:$SNMP_TEST_DEST$SNMP_SNMPD_PORT .1.3.6.1.2.1.1.4.0"
|
|
|
91f3ae |
+
|
|
|
91f3ae |
+CHECK ".1.3.6.1.2.1.1.4.0 = STRING:"
|
|
|
91f3ae |
+
|
|
|
91f3ae |
+CAPTURE "snmpset -On $SNMP_FLAGS -c testcommunity -v 2c $SNMP_TRANSPORT_SPEC:$SNMP_TEST_DEST$SNMP_SNMPD_PORT .1.3.6.1.2.1.1.4.0 n x"
|
|
|
91f3ae |
+
|
|
|
91f3ae |
+CHECK "Reason: wrongType"
|
|
|
91f3ae |
+
|
|
|
91f3ae |
+STOPAGENT
|
|
|
91f3ae |
+
|
|
|
91f3ae |
+FINISHED
|
|
|
91f3ae |
|