From 56f456f3e83d0555cb06175605afe8f0fa62b905 Mon Sep 17 00:00:00 2001 From: jow Date: Mon, 3 Oct 2011 09:22:46 +0000 Subject: [PATCH] [packages] mini-snmpd: fix use of uninitialized memory leading to garbage values (#10168) git-svn-id: svn://svn.openwrt.org/openwrt/packages@28358 3c298f89-4303-0410-b956-a3cf2f4a3e73 --- net/mini_snmpd/Makefile | 2 +- .../patches/102-mib_fix_uninitialized_memory.patch | 34 ++++++++++++++++++++++ .../103-mib_encode_snmp_element_oid_fix.patch | 4 +-- 3 files changed, 37 insertions(+), 3 deletions(-) create mode 100644 net/mini_snmpd/patches/102-mib_fix_uninitialized_memory.patch diff --git a/net/mini_snmpd/Makefile b/net/mini_snmpd/Makefile index a1fe691c2..ecc27177f 100644 --- a/net/mini_snmpd/Makefile +++ b/net/mini_snmpd/Makefile @@ -9,7 +9,7 @@ include $(TOPDIR)/rules.mk PKG_NAME:=mini_snmpd PKG_VERSION:=1.2b -PKG_RELEASE:=2 +PKG_RELEASE:=3 PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.gz PKG_SOURCE_URL:=http://members.aon.at/linuxfreak/linux/ diff --git a/net/mini_snmpd/patches/102-mib_fix_uninitialized_memory.patch b/net/mini_snmpd/patches/102-mib_fix_uninitialized_memory.patch new file mode 100644 index 000000000..fc8cecf2e --- /dev/null +++ b/net/mini_snmpd/patches/102-mib_fix_uninitialized_memory.patch @@ -0,0 +1,34 @@ +--- a/mib.c ++++ b/mib.c +@@ -290,6 +290,7 @@ static int mib_build_entry(const oid_t * + value->data.max_length = sizeof (int) + 2; + value->data.encoded_length = 0; + value->data.buffer = malloc(value->data.max_length); ++ memset(value->data.buffer, 0, value->data.max_length); + if (encode_snmp_element_integer(value, (int)default_value) == -1) { + return -1; + } +@@ -298,6 +299,7 @@ static int mib_build_entry(const oid_t * + value->data.max_length = strlen((const char *)default_value) + 4; + value->data.encoded_length = 0; + value->data.buffer = malloc(value->data.max_length); ++ memset(value->data.buffer, 0, value->data.max_length); + if (encode_snmp_element_string(value, (const char *)default_value) == -1) { + return -1; + } +@@ -306,6 +308,7 @@ static int mib_build_entry(const oid_t * + value->data.max_length = MAX_NR_SUBIDS * 5 + 4; + value->data.encoded_length = 0; + value->data.buffer = malloc(value->data.max_length); ++ memset(value->data.buffer, 0, value->data.max_length); + if (encode_snmp_element_oid(value, oid_aton((const char *)default_value)) == -1) { + return -1; + } +@@ -316,6 +319,7 @@ static int mib_build_entry(const oid_t * + value->data.max_length = sizeof (unsigned int) + 2; + value->data.encoded_length = 0; + value->data.buffer = malloc(value->data.max_length); ++ memset(value->data.buffer, 0, value->data.max_length); + if (encode_snmp_element_unsigned(value, type, (unsigned int)default_value) == -1) { + return -1; + } diff --git a/net/mini_snmpd/patches/103-mib_encode_snmp_element_oid_fix.patch b/net/mini_snmpd/patches/103-mib_encode_snmp_element_oid_fix.patch index be4361c85..a1f105cb4 100644 --- a/net/mini_snmpd/patches/103-mib_encode_snmp_element_oid_fix.patch +++ b/net/mini_snmpd/patches/103-mib_encode_snmp_element_oid_fix.patch @@ -10,9 +10,9 @@ buffer = value->data.buffer; length = 1; for (i = 2; i < oid_value->subid_list_length; i++) { -@@ -307,6 +310,8 @@ static int mib_build_entry(const oid_t * - value->data.encoded_length = 0; +@@ -310,6 +313,8 @@ static int mib_build_entry(const oid_t * value->data.buffer = malloc(value->data.max_length); + memset(value->data.buffer, 0, value->data.max_length); if (encode_snmp_element_oid(value, oid_aton((const char *)default_value)) == -1) { + lprintf(LOG_ERR, "could not create MIB entry '%s.%d.%d': invalid oid '%s'\n", + oid_ntoa(prefix), column, row, (char *)default_value); -- 2.11.0