[packages] mini-snmpd: fix a segfault when passing an invalid oid to the -V option...
[openwrt/svn-archive/archive.git] / net / mini_snmpd / patches / 103-mib_encode_snmp_element_oid_fix.patch
1 --- a/mib.c
2 +++ b/mib.c
3 @@ -120,6 +120,9 @@ static int encode_snmp_element_oid(value
4 int length;
5 int i;
6
7 + if (oid_value == NULL) {
8 + return -1;
9 + }
10 buffer = value->data.buffer;
11 length = 1;
12 for (i = 2; i < oid_value->subid_list_length; i++) {
13 @@ -293,6 +296,8 @@ static int mib_build_entry(const oid_t *
14 value->data.encoded_length = 0;
15 value->data.buffer = malloc(value->data.max_length);
16 if (encode_snmp_element_oid(value, oid_aton((const char *)default_value)) == -1) {
17 + lprintf(LOG_ERR, "could not create MIB entry '%s.%d.%d': invalid oid '%s'\n",
18 + oid_ntoa(prefix), column, row, (char *)default_value);
19 return -1;
20 }
21 break;