On Sat, 2009-05-16 at 09:39 +0200, Magnus Fromreide wrote:
> On Sat, 2009-05-09 at 21:48 +0200, Magnus Fromreide wrote:
Attached is a proposed patch.
Index: clean/agent/helpers/table.c
===================================================================
--- clean.orig/agent/helpers/table.c 2009-05-18 21:30:35.000000000 +0200
+++ clean/agent/helpers/table.c 2009-05-18 21:30:38.000000000 +0200
@@ -552,7 +552,7 @@
* try and parse current index
*/
if (parse_one_oid_index(&tmp_name, &tmp_len,
- vb, 1) != SNMPERR_SUCCESS) {
+ vb, 2) != SNMPERR_SUCCESS) {
incomplete = 1;
tmp_len = -1; /* is this necessary? Better safe than
* sorry */
Index: clean/snmplib/mib.c
===================================================================
--- clean.orig/snmplib/mib.c 2009-05-18 21:30:35.000000000 +0200
+++ clean/snmplib/mib.c 2009-05-18 21:30:38.000000000 +0200
@@ -3790,20 +3790,29 @@
}
+/*
+ * @param complete Indicates how to handle incomplete values
+ *
+ * The values of complete are as follows:
+ * 0 - Return SNMPERR_GENERR
+ * 1 - Pad result and return success
+ * 2 - Pad result and return SNMPERR_BAD_SUBID
+ */
int
parse_one_oid_index(oid ** oidStart, size_t * oidLen,
netsnmp_variable_list * data, int complete)
{
netsnmp_variable_list *var = data;
- oid tmpout[MAX_OID_LEN];
- unsigned int i;
- unsigned int uitmp = 0;
-
- oid *oidIndex = *oidStart;
+ int incomplete = 0;
+ oid *oidIndex = *oidStart;
if (var == NULL || ((*oidLen == 0) && (complete == 0)))
return SNMPERR_GENERR;
else {
+ oid tmpout[MAX_OID_LEN];
+ unsigned int i;
+ unsigned int uitmp = 0;
+
switch (var->type) {
case ASN_INTEGER:
case ASN_COUNTER:
@@ -3811,14 +3820,15 @@
case ASN_TIMETICKS:
if (*oidLen) {
snmp_set_var_value(var, (u_char *) oidIndex++,
- sizeof(long));
+ sizeof(int32_t));
--(*oidLen);
} else {
- snmp_set_var_value(var, (u_char *) oidLen, sizeof(long));
+ incomplete = 1;
+ snmp_set_var_value(var, (u_char *) oidLen, sizeof(int32_t));
}
DEBUGMSGTL(("parse_oid_indexes",
- "Parsed int(%d): %ld\n", var->type,
- *var->val.integer));
+ "Parsed int(%d): %ld%s\n", var->type,
+ *var->val.integer, incomplete ? " [INCOMPLETE]" : ""));
break;
case ASN_IPADDRESS:
@@ -3834,6 +3844,7 @@
uitmp = uitmp + (oidIndex[i] << (8*(3-i)));
}
if (4 > (int) (*oidLen)) {
+ incomplete = 1;
oidIndex += *oidLen;
(*oidLen) = 0;
} else {
@@ -3844,9 +3855,10 @@
uitmp =
snmp_set_var_value(var, (u_char *) &uitmp, 4);
DEBUGMSGTL(("parse_oid_indexes",
- "Parsed ipaddr(%d): %d.%d.%d.%d\n", var->type,
+ "Parsed ipaddr(%d): %d.%d.%d.%d%s\n", var->type,
var->val.string[0], var->val.string[1],
- var->val.string[2], var->val.string[3]));
+ var->val.string[2], var->val.string[3],
+ incomplete ? " [INCOMPLETE]" : ""));
break;
case ASN_OBJECT_ID:
@@ -3877,6 +3889,7 @@
return SNMPERR_GENERR; /* too big and illegal */
if (uitmp > *oidLen) {
+ incomplete = 1;
memcpy(tmpout, oidIndex, sizeof(oid) * (*oidLen));
memset(&tmpout[*oidLen], 0x00,
sizeof(oid) * (uitmp - *oidLen));
@@ -3894,7 +3907,8 @@
DEBUGMSGTL(("parse_oid_indexes", "Parsed oid: "));
DEBUGMSGOID(("parse_oid_indexes",
var->val.objid, var->val_len / sizeof(oid)));
- DEBUGMSG(("parse_oid_indexes", "\n"));
+ DEBUGMSG(("parse_oid_indexes",
+ "%s\n", incomplete ? " [INCOMPLETE]" : ""));
break;
case ASN_OPAQUE:
@@ -3943,6 +3957,7 @@
return SNMPERR_GENERR;
if ((size_t)uitmp > (*oidLen)) {
+ incomplete = 1;
for (i = 0; i < *oidLen; ++i)
var->val.string[i] = (u_char) * oidIndex++;
for (i = *oidLen; i < uitmp; ++i)
@@ -3956,8 +3971,8 @@
var->val.string[uitmp] = '\0';
DEBUGMSGTL(("parse_oid_indexes",
- "Parsed str(%d): %s\n", var->type,
- var->val.string));
+ "Parsed str(%d): %s%s\n", var->type,
+ var->val.string, incomplete ? " [INCOMPLETE]" : ""));
break;
default:
@@ -3967,6 +3982,10 @@
}
}
(*oidStart) = oidIndex;
+
+ if (complete == 2 && incomplete)
+ return SNMPERR_BAD_SUBID;
+
return SNMPERR_SUCCESS;
}
------------------------------------------------------------------------------
Crystal Reports - New Free Runtime and 30 Day Trial
Check out the new simplified licensing option that enables
unlimited royalty-free distribution of the report engine
for externally facing server and web deployment.
http://p.sf.net/sfu/businessobjects
_______________________________________________
Net-snmp-coders mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/net-snmp-coders