|
|
9a6c41 |
commit 7f4a7b891332899cea26e95be0337aae01648742
|
|
|
9a6c41 |
Author: Jan Safranek <jsafranek@users.sourceforge.net>
|
|
|
9a6c41 |
Date: Thu Jul 31 13:46:49 2014 +0200
|
|
|
9a6c41 |
|
|
|
9a6c41 |
Added checks for printing variables with wrong types.
|
|
|
9a6c41 |
|
|
|
9a6c41 |
When -OQ command line argument is used, variable formatter preffers the type
|
|
|
9a6c41 |
of the varible parsed from a MIB file instead of checking type of the variable
|
|
|
9a6c41 |
as parsed from SNMP message.
|
|
|
9a6c41 |
|
|
|
9a6c41 |
This can lead to crashes when incoming packets contains a variable with
|
|
|
9a6c41 |
NULL type, while the MIB says the variable should be non-NULL, like Integer.
|
|
|
9a6c41 |
The formatter then tries to interpret the NULL (from packet) as Integer (from
|
|
|
9a6c41 |
MIB file).
|
|
|
9a6c41 |
|
|
|
9a6c41 |
diff --git a/snmplib/mib.c b/snmplib/mib.c
|
|
|
9a6c41 |
index 9d3ca41..c6e0010 100644
|
|
|
9a6c41 |
--- a/snmplib/mib.c
|
|
|
9a6c41 |
+++ b/snmplib/mib.c
|
|
|
9a6c41 |
@@ -439,17 +439,16 @@ sprint_realloc_octet_string(u_char ** buf, size_t * buf_len,
|
|
|
9a6c41 |
u_char *cp;
|
|
|
9a6c41 |
int output_format, cnt;
|
|
|
9a6c41 |
|
|
|
9a6c41 |
- if ((var->type != ASN_OCTET_STR) &&
|
|
|
9a6c41 |
- (!netsnmp_ds_get_boolean(NETSNMP_DS_LIBRARY_ID, NETSNMP_DS_LIB_QUICKE_PRINT))) {
|
|
|
9a6c41 |
- const char str[] = "Wrong Type (should be OCTET STRING): ";
|
|
|
9a6c41 |
- if (snmp_cstrcat
|
|
|
9a6c41 |
- (buf, buf_len, out_len, allow_realloc, str)) {
|
|
|
9a6c41 |
- return sprint_realloc_by_type(buf, buf_len, out_len,
|
|
|
9a6c41 |
+ if (var->type != ASN_OCTET_STR) {
|
|
|
9a6c41 |
+ if (!netsnmp_ds_get_boolean(
|
|
|
9a6c41 |
+ NETSNMP_DS_LIBRARY_ID, NETSNMP_DS_LIB_QUICKE_PRINT)) {
|
|
|
9a6c41 |
+ const char str[] = "Wrong Type (should be OCTET STRING): ";
|
|
|
9a6c41 |
+ if (!snmp_cstrcat(buf, buf_len, out_len, allow_realloc, str))
|
|
|
9a6c41 |
+ return 0;
|
|
|
9a6c41 |
+ }
|
|
|
9a6c41 |
+ return sprint_realloc_by_type(buf, buf_len, out_len,
|
|
|
9a6c41 |
allow_realloc, var, NULL, NULL,
|
|
|
9a6c41 |
NULL);
|
|
|
9a6c41 |
- } else {
|
|
|
9a6c41 |
- return 0;
|
|
|
9a6c41 |
- }
|
|
|
9a6c41 |
}
|
|
|
9a6c41 |
|
|
|
9a6c41 |
|
|
|
9a6c41 |
@@ -702,16 +701,16 @@ sprint_realloc_float(u_char ** buf, size_t * buf_len,
|
|
|
9a6c41 |
const struct enum_list *enums,
|
|
|
9a6c41 |
const char *hint, const char *units)
|
|
|
9a6c41 |
{
|
|
|
9a6c41 |
- if ((var->type != ASN_OPAQUE_FLOAT) &&
|
|
|
9a6c41 |
- (!netsnmp_ds_get_boolean(NETSNMP_DS_LIBRARY_ID, NETSNMP_DS_LIB_QUICKE_PRINT))) {
|
|
|
9a6c41 |
- if (snmp_cstrcat(buf, buf_len, out_len, allow_realloc,
|
|
|
9a6c41 |
- "Wrong Type (should be Float): ")) {
|
|
|
9a6c41 |
- return sprint_realloc_by_type(buf, buf_len, out_len,
|
|
|
9a6c41 |
+ if (var->type != ASN_OPAQUE_FLOAT) {
|
|
|
9a6c41 |
+ if (!netsnmp_ds_get_boolean(
|
|
|
9a6c41 |
+ NETSNMP_DS_LIBRARY_ID, NETSNMP_DS_LIB_QUICKE_PRINT)) {
|
|
|
9a6c41 |
+ u_char str[] = "Wrong Type (should be Float): ";
|
|
|
9a6c41 |
+ if (!snmp_strcat(buf, buf_len, out_len, allow_realloc, str))
|
|
|
9a6c41 |
+ return 0;
|
|
|
9a6c41 |
+ }
|
|
|
9a6c41 |
+ return sprint_realloc_by_type(buf, buf_len, out_len,
|
|
|
9a6c41 |
allow_realloc, var, NULL, NULL,
|
|
|
9a6c41 |
NULL);
|
|
|
9a6c41 |
- } else {
|
|
|
9a6c41 |
- return 0;
|
|
|
9a6c41 |
- }
|
|
|
9a6c41 |
}
|
|
|
9a6c41 |
|
|
|
9a6c41 |
if (!netsnmp_ds_get_boolean(NETSNMP_DS_LIBRARY_ID, NETSNMP_DS_LIB_QUICK_PRINT)) {
|
|
|
9a6c41 |
@@ -772,17 +771,16 @@ sprint_realloc_double(u_char ** buf, size_t * buf_len,
|
|
|
9a6c41 |
const struct enum_list *enums,
|
|
|
9a6c41 |
const char *hint, const char *units)
|
|
|
9a6c41 |
{
|
|
|
9a6c41 |
- if ((var->type != ASN_OPAQUE_DOUBLE) &&
|
|
|
9a6c41 |
- (!netsnmp_ds_get_boolean(NETSNMP_DS_LIBRARY_ID, NETSNMP_DS_LIB_QUICKE_PRINT))) {
|
|
|
9a6c41 |
- if (snmp_cstrcat
|
|
|
9a6c41 |
- (buf, buf_len, out_len, allow_realloc,
|
|
|
9a6c41 |
- "Wrong Type (should be Double): ")) {
|
|
|
9a6c41 |
- return sprint_realloc_by_type(buf, buf_len, out_len,
|
|
|
9a6c41 |
+ if (var->type != ASN_OPAQUE_DOUBLE) {
|
|
|
9a6c41 |
+ if (!netsnmp_ds_get_boolean(
|
|
|
9a6c41 |
+ NETSNMP_DS_LIBRARY_ID, NETSNMP_DS_LIB_QUICKE_PRINT)) {
|
|
|
9a6c41 |
+ u_char str[] = "Wrong Type (should be Double): ";
|
|
|
9a6c41 |
+ if (!snmp_strcat(buf, buf_len, out_len, allow_realloc, str))
|
|
|
9a6c41 |
+ return 0;
|
|
|
9a6c41 |
+ }
|
|
|
9a6c41 |
+ return sprint_realloc_by_type(buf, buf_len, out_len,
|
|
|
9a6c41 |
allow_realloc, var, NULL, NULL,
|
|
|
9a6c41 |
NULL);
|
|
|
9a6c41 |
- } else {
|
|
|
9a6c41 |
- return 0;
|
|
|
9a6c41 |
- }
|
|
|
9a6c41 |
}
|
|
|
9a6c41 |
|
|
|
9a6c41 |
if (!netsnmp_ds_get_boolean(NETSNMP_DS_LIBRARY_ID, NETSNMP_DS_LIB_QUICK_PRINT)) {
|
|
|
9a6c41 |
@@ -847,20 +845,21 @@ sprint_realloc_counter64(u_char ** buf, size_t * buf_len, size_t * out_len,
|
|
|
9a6c41 |
{
|
|
|
9a6c41 |
char a64buf[I64CHARSZ + 1];
|
|
|
9a6c41 |
|
|
|
9a6c41 |
- if ((var->type != ASN_COUNTER64
|
|
|
9a6c41 |
+ if (var->type != ASN_COUNTER64
|
|
|
9a6c41 |
#ifdef NETSNMP_WITH_OPAQUE_SPECIAL_TYPES
|
|
|
9a6c41 |
&& var->type != ASN_OPAQUE_COUNTER64
|
|
|
9a6c41 |
&& var->type != ASN_OPAQUE_I64 && var->type != ASN_OPAQUE_U64
|
|
|
9a6c41 |
#endif
|
|
|
9a6c41 |
- ) && (!netsnmp_ds_get_boolean(NETSNMP_DS_LIBRARY_ID, NETSNMP_DS_LIB_QUICKE_PRINT))) {
|
|
|
9a6c41 |
- if (snmp_cstrcat(buf, buf_len, out_len, allow_realloc,
|
|
|
9a6c41 |
- "Wrong Type (should be Counter64): ")) {
|
|
|
9a6c41 |
- return sprint_realloc_by_type(buf, buf_len, out_len,
|
|
|
9a6c41 |
+ ) {
|
|
|
9a6c41 |
+ if (!netsnmp_ds_get_boolean(
|
|
|
9a6c41 |
+ NETSNMP_DS_LIBRARY_ID, NETSNMP_DS_LIB_QUICKE_PRINT)) {
|
|
|
9a6c41 |
+ u_char str[] = "Wrong Type (should be Counter64): ";
|
|
|
9a6c41 |
+ if (!snmp_strcat(buf, buf_len, out_len, allow_realloc, str))
|
|
|
9a6c41 |
+ return 0;
|
|
|
9a6c41 |
+ }
|
|
|
9a6c41 |
+ return sprint_realloc_by_type(buf, buf_len, out_len,
|
|
|
9a6c41 |
allow_realloc, var, NULL, NULL,
|
|
|
9a6c41 |
NULL);
|
|
|
9a6c41 |
- } else {
|
|
|
9a6c41 |
- return 0;
|
|
|
9a6c41 |
- }
|
|
|
9a6c41 |
}
|
|
|
9a6c41 |
|
|
|
9a6c41 |
if (!netsnmp_ds_get_boolean(NETSNMP_DS_LIBRARY_ID, NETSNMP_DS_LIB_QUICK_PRINT)) {
|
|
|
9a6c41 |
@@ -948,23 +947,25 @@ sprint_realloc_opaque(u_char ** buf, size_t * buf_len,
|
|
|
9a6c41 |
const struct enum_list *enums,
|
|
|
9a6c41 |
const char *hint, const char *units)
|
|
|
9a6c41 |
{
|
|
|
9a6c41 |
- if ((var->type != ASN_OPAQUE
|
|
|
9a6c41 |
+ if (var->type != ASN_OPAQUE
|
|
|
9a6c41 |
#ifdef NETSNMP_WITH_OPAQUE_SPECIAL_TYPES
|
|
|
9a6c41 |
&& var->type != ASN_OPAQUE_COUNTER64
|
|
|
9a6c41 |
&& var->type != ASN_OPAQUE_U64
|
|
|
9a6c41 |
&& var->type != ASN_OPAQUE_I64
|
|
|
9a6c41 |
&& var->type != ASN_OPAQUE_FLOAT && var->type != ASN_OPAQUE_DOUBLE
|
|
|
9a6c41 |
#endif /* NETSNMP_WITH_OPAQUE_SPECIAL_TYPES */
|
|
|
9a6c41 |
- ) && (!netsnmp_ds_get_boolean(NETSNMP_DS_LIBRARY_ID, NETSNMP_DS_LIB_QUICKE_PRINT))) {
|
|
|
9a6c41 |
- if (snmp_cstrcat(buf, buf_len, out_len, allow_realloc,
|
|
|
9a6c41 |
- "Wrong Type (should be Opaque): ")) {
|
|
|
9a6c41 |
- return sprint_realloc_by_type(buf, buf_len, out_len,
|
|
|
9a6c41 |
+ ) {
|
|
|
9a6c41 |
+ if (!netsnmp_ds_get_boolean(
|
|
|
9a6c41 |
+ NETSNMP_DS_LIBRARY_ID, NETSNMP_DS_LIB_QUICKE_PRINT)) {
|
|
|
9a6c41 |
+ u_char str[] = "Wrong Type (should be Opaque): ";
|
|
|
9a6c41 |
+ if (!snmp_strcat(buf, buf_len, out_len, allow_realloc, str))
|
|
|
9a6c41 |
+ return 0;
|
|
|
9a6c41 |
+ }
|
|
|
9a6c41 |
+ return sprint_realloc_by_type(buf, buf_len, out_len,
|
|
|
9a6c41 |
allow_realloc, var, NULL, NULL,
|
|
|
9a6c41 |
NULL);
|
|
|
9a6c41 |
- } else {
|
|
|
9a6c41 |
- return 0;
|
|
|
9a6c41 |
- }
|
|
|
9a6c41 |
}
|
|
|
9a6c41 |
+
|
|
|
9a6c41 |
#ifdef NETSNMP_WITH_OPAQUE_SPECIAL_TYPES
|
|
|
9a6c41 |
switch (var->type) {
|
|
|
9a6c41 |
case ASN_OPAQUE_COUNTER64:
|
|
|
9a6c41 |
@@ -1040,17 +1041,16 @@ sprint_realloc_object_identifier(u_char ** buf, size_t * buf_len,
|
|
|
9a6c41 |
{
|
|
|
9a6c41 |
int buf_overflow = 0;
|
|
|
9a6c41 |
|
|
|
9a6c41 |
- if ((var->type != ASN_OBJECT_ID) &&
|
|
|
9a6c41 |
- (!netsnmp_ds_get_boolean(NETSNMP_DS_LIBRARY_ID, NETSNMP_DS_LIB_QUICKE_PRINT))) {
|
|
|
9a6c41 |
- u_char str[] =
|
|
|
9a6c41 |
- "Wrong Type (should be OBJECT IDENTIFIER): ";
|
|
|
9a6c41 |
- if (snmp_strcat(buf, buf_len, out_len, allow_realloc, str)) {
|
|
|
9a6c41 |
- return sprint_realloc_by_type(buf, buf_len, out_len,
|
|
|
9a6c41 |
+ if (var->type != ASN_OBJECT_ID) {
|
|
|
9a6c41 |
+ if (!netsnmp_ds_get_boolean(
|
|
|
9a6c41 |
+ NETSNMP_DS_LIBRARY_ID, NETSNMP_DS_LIB_QUICKE_PRINT)) {
|
|
|
9a6c41 |
+ u_char str[] = "Wrong Type (should be OBJECT IDENTIFIER): ";
|
|
|
9a6c41 |
+ if (!snmp_strcat(buf, buf_len, out_len, allow_realloc, str))
|
|
|
9a6c41 |
+ return 0;
|
|
|
9a6c41 |
+ }
|
|
|
9a6c41 |
+ return sprint_realloc_by_type(buf, buf_len, out_len,
|
|
|
9a6c41 |
allow_realloc, var, NULL, NULL,
|
|
|
9a6c41 |
NULL);
|
|
|
9a6c41 |
- } else {
|
|
|
9a6c41 |
- return 0;
|
|
|
9a6c41 |
- }
|
|
|
9a6c41 |
}
|
|
|
9a6c41 |
|
|
|
9a6c41 |
if (!netsnmp_ds_get_boolean(NETSNMP_DS_LIBRARY_ID, NETSNMP_DS_LIB_QUICK_PRINT)) {
|
|
|
9a6c41 |
@@ -1110,16 +1110,16 @@ sprint_realloc_timeticks(u_char ** buf, size_t * buf_len, size_t * out_len,
|
|
|
9a6c41 |
{
|
|
|
9a6c41 |
char timebuf[40];
|
|
|
9a6c41 |
|
|
|
9a6c41 |
- if ((var->type != ASN_TIMETICKS) &&
|
|
|
9a6c41 |
- (!netsnmp_ds_get_boolean(NETSNMP_DS_LIBRARY_ID, NETSNMP_DS_LIB_QUICKE_PRINT))) {
|
|
|
9a6c41 |
- u_char str[] = "Wrong Type (should be Timeticks): ";
|
|
|
9a6c41 |
- if (snmp_strcat(buf, buf_len, out_len, allow_realloc, str)) {
|
|
|
9a6c41 |
- return sprint_realloc_by_type(buf, buf_len, out_len,
|
|
|
9a6c41 |
+ if (var->type != ASN_TIMETICKS) {
|
|
|
9a6c41 |
+ if (!netsnmp_ds_get_boolean(
|
|
|
9a6c41 |
+ NETSNMP_DS_LIBRARY_ID, NETSNMP_DS_LIB_QUICKE_PRINT)) {
|
|
|
9a6c41 |
+ u_char str[] = "Wrong Type (should be Timeticks): ";
|
|
|
9a6c41 |
+ if (!snmp_strcat(buf, buf_len, out_len, allow_realloc, str))
|
|
|
9a6c41 |
+ return 0;
|
|
|
9a6c41 |
+ }
|
|
|
9a6c41 |
+ return sprint_realloc_by_type(buf, buf_len, out_len,
|
|
|
9a6c41 |
allow_realloc, var, NULL, NULL,
|
|
|
9a6c41 |
NULL);
|
|
|
9a6c41 |
- } else {
|
|
|
9a6c41 |
- return 0;
|
|
|
9a6c41 |
- }
|
|
|
9a6c41 |
}
|
|
|
9a6c41 |
|
|
|
9a6c41 |
if (netsnmp_ds_get_boolean(NETSNMP_DS_LIBRARY_ID, NETSNMP_DS_LIB_NUMERIC_TIMETICKS)) {
|
|
|
9a6c41 |
@@ -1277,17 +1277,18 @@ sprint_realloc_integer(u_char ** buf, size_t * buf_len, size_t * out_len,
|
|
|
9a6c41 |
{
|
|
|
9a6c41 |
char *enum_string = NULL;
|
|
|
9a6c41 |
|
|
|
9a6c41 |
- if ((var->type != ASN_INTEGER) &&
|
|
|
9a6c41 |
- (!netsnmp_ds_get_boolean(NETSNMP_DS_LIBRARY_ID, NETSNMP_DS_LIB_QUICKE_PRINT))) {
|
|
|
9a6c41 |
- u_char str[] = "Wrong Type (should be INTEGER): ";
|
|
|
9a6c41 |
- if (snmp_strcat(buf, buf_len, out_len, allow_realloc, str)) {
|
|
|
9a6c41 |
- return sprint_realloc_by_type(buf, buf_len, out_len,
|
|
|
9a6c41 |
+ if (var->type != ASN_INTEGER) {
|
|
|
9a6c41 |
+ if (!netsnmp_ds_get_boolean(
|
|
|
9a6c41 |
+ NETSNMP_DS_LIBRARY_ID, NETSNMP_DS_LIB_QUICKE_PRINT)) {
|
|
|
9a6c41 |
+ u_char str[] = "Wrong Type (should be INTEGER): ";
|
|
|
9a6c41 |
+ if (!snmp_strcat(buf, buf_len, out_len, allow_realloc, str))
|
|
|
9a6c41 |
+ return 0;
|
|
|
9a6c41 |
+ }
|
|
|
9a6c41 |
+ return sprint_realloc_by_type(buf, buf_len, out_len,
|
|
|
9a6c41 |
allow_realloc, var, NULL, NULL,
|
|
|
9a6c41 |
NULL);
|
|
|
9a6c41 |
- } else {
|
|
|
9a6c41 |
- return 0;
|
|
|
9a6c41 |
- }
|
|
|
9a6c41 |
}
|
|
|
9a6c41 |
+
|
|
|
9a6c41 |
for (; enums; enums = enums->next) {
|
|
|
9a6c41 |
if (enums->value == *var->val.integer) {
|
|
|
9a6c41 |
enum_string = enums->label;
|
|
|
9a6c41 |
@@ -1380,16 +1381,16 @@ sprint_realloc_uinteger(u_char ** buf, size_t * buf_len, size_t * out_len,
|
|
|
9a6c41 |
{
|
|
|
9a6c41 |
char *enum_string = NULL;
|
|
|
9a6c41 |
|
|
|
9a6c41 |
- if ((var->type != ASN_UINTEGER) &&
|
|
|
9a6c41 |
- (!netsnmp_ds_get_boolean(NETSNMP_DS_LIBRARY_ID, NETSNMP_DS_LIB_QUICKE_PRINT))) {
|
|
|
9a6c41 |
- u_char str[] = "Wrong Type (should be UInteger32): ";
|
|
|
9a6c41 |
- if (snmp_strcat(buf, buf_len, out_len, allow_realloc, str)) {
|
|
|
9a6c41 |
- return sprint_realloc_by_type(buf, buf_len, out_len,
|
|
|
9a6c41 |
+ if (var->type != ASN_UINTEGER) {
|
|
|
9a6c41 |
+ if (!netsnmp_ds_get_boolean(
|
|
|
9a6c41 |
+ NETSNMP_DS_LIBRARY_ID, NETSNMP_DS_LIB_QUICKE_PRINT)) {
|
|
|
9a6c41 |
+ u_char str[] = "Wrong Type (should be UInteger32): ";
|
|
|
9a6c41 |
+ if (!snmp_strcat(buf, buf_len, out_len, allow_realloc, str))
|
|
|
9a6c41 |
+ return 0;
|
|
|
9a6c41 |
+ }
|
|
|
9a6c41 |
+ return sprint_realloc_by_type(buf, buf_len, out_len,
|
|
|
9a6c41 |
allow_realloc, var, NULL, NULL,
|
|
|
9a6c41 |
NULL);
|
|
|
9a6c41 |
- } else {
|
|
|
9a6c41 |
- return 0;
|
|
|
9a6c41 |
- }
|
|
|
9a6c41 |
}
|
|
|
9a6c41 |
|
|
|
9a6c41 |
for (; enums; enums = enums->next) {
|
|
|
9a6c41 |
@@ -1477,17 +1478,16 @@ sprint_realloc_gauge(u_char ** buf, size_t * buf_len, size_t * out_len,
|
|
|
9a6c41 |
{
|
|
|
9a6c41 |
char tmp[32];
|
|
|
9a6c41 |
|
|
|
9a6c41 |
- if ((var->type != ASN_GAUGE) &&
|
|
|
9a6c41 |
- (!netsnmp_ds_get_boolean(NETSNMP_DS_LIBRARY_ID, NETSNMP_DS_LIB_QUICKE_PRINT))) {
|
|
|
9a6c41 |
- u_char str[] =
|
|
|
9a6c41 |
- "Wrong Type (should be Gauge32 or Unsigned32): ";
|
|
|
9a6c41 |
- if (snmp_strcat(buf, buf_len, out_len, allow_realloc, str)) {
|
|
|
9a6c41 |
- return sprint_realloc_by_type(buf, buf_len, out_len,
|
|
|
9a6c41 |
+ if (var->type != ASN_GAUGE) {
|
|
|
9a6c41 |
+ if (!netsnmp_ds_get_boolean(
|
|
|
9a6c41 |
+ NETSNMP_DS_LIBRARY_ID, NETSNMP_DS_LIB_QUICKE_PRINT)) {
|
|
|
9a6c41 |
+ u_char str[] = "Wrong Type (should be Gauge32 or Unsigned32): ";
|
|
|
9a6c41 |
+ if (!snmp_strcat(buf, buf_len, out_len, allow_realloc, str))
|
|
|
9a6c41 |
+ return 0;
|
|
|
9a6c41 |
+ }
|
|
|
9a6c41 |
+ return sprint_realloc_by_type(buf, buf_len, out_len,
|
|
|
9a6c41 |
allow_realloc, var, NULL, NULL,
|
|
|
9a6c41 |
NULL);
|
|
|
9a6c41 |
- } else {
|
|
|
9a6c41 |
- return 0;
|
|
|
9a6c41 |
- }
|
|
|
9a6c41 |
}
|
|
|
9a6c41 |
|
|
|
9a6c41 |
if (!netsnmp_ds_get_boolean(NETSNMP_DS_LIBRARY_ID, NETSNMP_DS_LIB_QUICK_PRINT)) {
|
|
|
9a6c41 |
@@ -1550,16 +1550,16 @@ sprint_realloc_counter(u_char ** buf, size_t * buf_len, size_t * out_len,
|
|
|
9a6c41 |
{
|
|
|
9a6c41 |
char tmp[32];
|
|
|
9a6c41 |
|
|
|
9a6c41 |
- if ((var->type != ASN_COUNTER) &&
|
|
|
9a6c41 |
- (!netsnmp_ds_get_boolean(NETSNMP_DS_LIBRARY_ID, NETSNMP_DS_LIB_QUICKE_PRINT))) {
|
|
|
9a6c41 |
- u_char str[] = "Wrong Type (should be Counter32): ";
|
|
|
9a6c41 |
- if (snmp_strcat(buf, buf_len, out_len, allow_realloc, str)) {
|
|
|
9a6c41 |
- return sprint_realloc_by_type(buf, buf_len, out_len,
|
|
|
9a6c41 |
+ if (var->type != ASN_COUNTER) {
|
|
|
9a6c41 |
+ if (!netsnmp_ds_get_boolean(
|
|
|
9a6c41 |
+ NETSNMP_DS_LIBRARY_ID, NETSNMP_DS_LIB_QUICKE_PRINT)) {
|
|
|
9a6c41 |
+ u_char str[] = "Wrong Type (should be Counter32): ";
|
|
|
9a6c41 |
+ if (!snmp_strcat(buf, buf_len, out_len, allow_realloc, str))
|
|
|
9a6c41 |
+ return 0;
|
|
|
9a6c41 |
+ }
|
|
|
9a6c41 |
+ return sprint_realloc_by_type(buf, buf_len, out_len,
|
|
|
9a6c41 |
allow_realloc, var, NULL, NULL,
|
|
|
9a6c41 |
NULL);
|
|
|
9a6c41 |
- } else {
|
|
|
9a6c41 |
- return 0;
|
|
|
9a6c41 |
- }
|
|
|
9a6c41 |
}
|
|
|
9a6c41 |
|
|
|
9a6c41 |
if (!netsnmp_ds_get_boolean(NETSNMP_DS_LIBRARY_ID, NETSNMP_DS_LIB_QUICK_PRINT)) {
|
|
|
9a6c41 |
@@ -1613,16 +1613,16 @@ sprint_realloc_networkaddress(u_char ** buf, size_t * buf_len,
|
|
|
9a6c41 |
{
|
|
|
9a6c41 |
size_t i;
|
|
|
9a6c41 |
|
|
|
9a6c41 |
- if ((var->type != ASN_IPADDRESS) &&
|
|
|
9a6c41 |
- (!netsnmp_ds_get_boolean(NETSNMP_DS_LIBRARY_ID, NETSNMP_DS_LIB_QUICKE_PRINT))) {
|
|
|
9a6c41 |
- u_char str[] = "Wrong Type (should be NetworkAddress): ";
|
|
|
9a6c41 |
- if (snmp_strcat(buf, buf_len, out_len, allow_realloc, str)) {
|
|
|
9a6c41 |
- return sprint_realloc_by_type(buf, buf_len, out_len,
|
|
|
9a6c41 |
+ if (var->type != ASN_IPADDRESS) {
|
|
|
9a6c41 |
+ if (!netsnmp_ds_get_boolean(
|
|
|
9a6c41 |
+ NETSNMP_DS_LIBRARY_ID, NETSNMP_DS_LIB_QUICKE_PRINT)) {
|
|
|
9a6c41 |
+ u_char str[] = "Wrong Type (should be NetworkAddress): ";
|
|
|
9a6c41 |
+ if (!snmp_strcat(buf, buf_len, out_len, allow_realloc, str))
|
|
|
9a6c41 |
+ return 0;
|
|
|
9a6c41 |
+ }
|
|
|
9a6c41 |
+ return sprint_realloc_by_type(buf, buf_len, out_len,
|
|
|
9a6c41 |
allow_realloc, var, NULL, NULL,
|
|
|
9a6c41 |
NULL);
|
|
|
9a6c41 |
- } else {
|
|
|
9a6c41 |
- return 0;
|
|
|
9a6c41 |
- }
|
|
|
9a6c41 |
}
|
|
|
9a6c41 |
|
|
|
9a6c41 |
if (!netsnmp_ds_get_boolean(NETSNMP_DS_LIBRARY_ID, NETSNMP_DS_LIB_QUICK_PRINT)) {
|
|
|
9a6c41 |
@@ -1679,16 +1679,16 @@ sprint_realloc_ipaddress(u_char ** buf, size_t * buf_len, size_t * out_len,
|
|
|
9a6c41 |
{
|
|
|
9a6c41 |
u_char *ip = var->val.string;
|
|
|
9a6c41 |
|
|
|
9a6c41 |
- if ((var->type != ASN_IPADDRESS) &&
|
|
|
9a6c41 |
- (!netsnmp_ds_get_boolean(NETSNMP_DS_LIBRARY_ID, NETSNMP_DS_LIB_QUICKE_PRINT))) {
|
|
|
9a6c41 |
- u_char str[] = "Wrong Type (should be IpAddress): ";
|
|
|
9a6c41 |
- if (snmp_strcat(buf, buf_len, out_len, allow_realloc, str)) {
|
|
|
9a6c41 |
- return sprint_realloc_by_type(buf, buf_len, out_len,
|
|
|
9a6c41 |
+ if (var->type != ASN_IPADDRESS) {
|
|
|
9a6c41 |
+ if (!netsnmp_ds_get_boolean(
|
|
|
9a6c41 |
+ NETSNMP_DS_LIBRARY_ID, NETSNMP_DS_LIB_QUICKE_PRINT)) {
|
|
|
9a6c41 |
+ u_char str[] = "Wrong Type (should be IpAddress): ";
|
|
|
9a6c41 |
+ if (!snmp_strcat(buf, buf_len, out_len, allow_realloc, str))
|
|
|
9a6c41 |
+ return 0;
|
|
|
9a6c41 |
+ }
|
|
|
9a6c41 |
+ return sprint_realloc_by_type(buf, buf_len, out_len,
|
|
|
9a6c41 |
allow_realloc, var, NULL, NULL,
|
|
|
9a6c41 |
NULL);
|
|
|
9a6c41 |
- } else {
|
|
|
9a6c41 |
- return 0;
|
|
|
9a6c41 |
- }
|
|
|
9a6c41 |
}
|
|
|
9a6c41 |
|
|
|
9a6c41 |
if (!netsnmp_ds_get_boolean(NETSNMP_DS_LIBRARY_ID, NETSNMP_DS_LIB_QUICK_PRINT)) {
|
|
|
9a6c41 |
@@ -1737,20 +1737,20 @@ sprint_realloc_null(u_char ** buf, size_t * buf_len, size_t * out_len,
|
|
|
9a6c41 |
const struct enum_list *enums,
|
|
|
9a6c41 |
const char *hint, const char *units)
|
|
|
9a6c41 |
{
|
|
|
9a6c41 |
- if ((var->type != ASN_NULL) &&
|
|
|
9a6c41 |
- (!netsnmp_ds_get_boolean(NETSNMP_DS_LIBRARY_ID, NETSNMP_DS_LIB_QUICKE_PRINT))) {
|
|
|
9a6c41 |
- u_char str[] = "Wrong Type (should be NULL): ";
|
|
|
9a6c41 |
- if (snmp_strcat(buf, buf_len, out_len, allow_realloc, str)) {
|
|
|
9a6c41 |
- return sprint_realloc_by_type(buf, buf_len, out_len,
|
|
|
9a6c41 |
+ if (var->type != ASN_NULL) {
|
|
|
9a6c41 |
+ if (!netsnmp_ds_get_boolean(
|
|
|
9a6c41 |
+ NETSNMP_DS_LIBRARY_ID, NETSNMP_DS_LIB_QUICKE_PRINT)) {
|
|
|
9a6c41 |
+ u_char str[] = "Wrong Type (should be NULL): ";
|
|
|
9a6c41 |
+ if (!snmp_strcat(buf, buf_len, out_len, allow_realloc, str))
|
|
|
9a6c41 |
+ return 0;
|
|
|
9a6c41 |
+ }
|
|
|
9a6c41 |
+ return sprint_realloc_by_type(buf, buf_len, out_len,
|
|
|
9a6c41 |
allow_realloc, var, NULL, NULL,
|
|
|
9a6c41 |
NULL);
|
|
|
9a6c41 |
- } else {
|
|
|
9a6c41 |
- return 0;
|
|
|
9a6c41 |
- }
|
|
|
9a6c41 |
- } else {
|
|
|
9a6c41 |
- u_char str[] = "NULL";
|
|
|
9a6c41 |
- return snmp_strcat(buf, buf_len, out_len, allow_realloc, str);
|
|
|
9a6c41 |
}
|
|
|
9a6c41 |
+
|
|
|
9a6c41 |
+ u_char str[] = "NULL";
|
|
|
9a6c41 |
+ return snmp_strcat(buf, buf_len, out_len, allow_realloc, str);
|
|
|
9a6c41 |
}
|
|
|
9a6c41 |
|
|
|
9a6c41 |
|
|
|
9a6c41 |
@@ -1785,16 +1785,16 @@ sprint_realloc_bitstring(u_char ** buf, size_t * buf_len, size_t * out_len,
|
|
|
9a6c41 |
u_char *cp;
|
|
|
9a6c41 |
char *enum_string;
|
|
|
9a6c41 |
|
|
|
9a6c41 |
- if ((var->type != ASN_BIT_STR && var->type != ASN_OCTET_STR) &&
|
|
|
9a6c41 |
- (!netsnmp_ds_get_boolean(NETSNMP_DS_LIBRARY_ID, NETSNMP_DS_LIB_QUICKE_PRINT))) {
|
|
|
9a6c41 |
- u_char str[] = "Wrong Type (should be BITS): ";
|
|
|
9a6c41 |
- if (snmp_strcat(buf, buf_len, out_len, allow_realloc, str)) {
|
|
|
9a6c41 |
- return sprint_realloc_by_type(buf, buf_len, out_len,
|
|
|
9a6c41 |
+ if (var->type != ASN_BIT_STR && var->type != ASN_OCTET_STR) {
|
|
|
9a6c41 |
+ if (!netsnmp_ds_get_boolean(
|
|
|
9a6c41 |
+ NETSNMP_DS_LIBRARY_ID, NETSNMP_DS_LIB_QUICKE_PRINT)) {
|
|
|
9a6c41 |
+ u_char str[] = "Wrong Type (should be BITS): ";
|
|
|
9a6c41 |
+ if (!snmp_strcat(buf, buf_len, out_len, allow_realloc, str))
|
|
|
9a6c41 |
+ return 0;
|
|
|
9a6c41 |
+ }
|
|
|
9a6c41 |
+ return sprint_realloc_by_type(buf, buf_len, out_len,
|
|
|
9a6c41 |
allow_realloc, var, NULL, NULL,
|
|
|
9a6c41 |
NULL);
|
|
|
9a6c41 |
- } else {
|
|
|
9a6c41 |
- return 0;
|
|
|
9a6c41 |
- }
|
|
|
9a6c41 |
}
|
|
|
9a6c41 |
|
|
|
9a6c41 |
if (netsnmp_ds_get_boolean(NETSNMP_DS_LIBRARY_ID, NETSNMP_DS_LIB_QUICK_PRINT)) {
|
|
|
9a6c41 |
@@ -1869,16 +1869,16 @@ sprint_realloc_nsapaddress(u_char ** buf, size_t * buf_len,
|
|
|
9a6c41 |
const struct enum_list *enums, const char *hint,
|
|
|
9a6c41 |
const char *units)
|
|
|
9a6c41 |
{
|
|
|
9a6c41 |
- if ((var->type != ASN_NSAP) &&
|
|
|
9a6c41 |
- (!netsnmp_ds_get_boolean(NETSNMP_DS_LIBRARY_ID, NETSNMP_DS_LIB_QUICKE_PRINT))) {
|
|
|
9a6c41 |
- u_char str[] = "Wrong Type (should be NsapAddress): ";
|
|
|
9a6c41 |
- if (snmp_strcat(buf, buf_len, out_len, allow_realloc, str)) {
|
|
|
9a6c41 |
- return sprint_realloc_by_type(buf, buf_len, out_len,
|
|
|
9a6c41 |
+ if (var->type != ASN_NSAP) {
|
|
|
9a6c41 |
+ if (!netsnmp_ds_get_boolean(
|
|
|
9a6c41 |
+ NETSNMP_DS_LIBRARY_ID, NETSNMP_DS_LIB_QUICKE_PRINT)) {
|
|
|
9a6c41 |
+ u_char str[] = "Wrong Type (should be NsapAddress): ";
|
|
|
9a6c41 |
+ if (!snmp_strcat(buf, buf_len, out_len, allow_realloc, str))
|
|
|
9a6c41 |
+ return 0;
|
|
|
9a6c41 |
+ }
|
|
|
9a6c41 |
+ return sprint_realloc_by_type(buf, buf_len, out_len,
|
|
|
9a6c41 |
allow_realloc, var, NULL, NULL,
|
|
|
9a6c41 |
NULL);
|
|
|
9a6c41 |
- } else {
|
|
|
9a6c41 |
- return 0;
|
|
|
9a6c41 |
- }
|
|
|
9a6c41 |
}
|
|
|
9a6c41 |
|
|
|
9a6c41 |
if (!netsnmp_ds_get_boolean(NETSNMP_DS_LIBRARY_ID, NETSNMP_DS_LIB_QUICK_PRINT)) {
|
|
|
9a6c41 |
|
|
|
9a6c41 |
commit 3da0c378b5cb1bbf35d05a6212a483abda84a201
|
|
|
9a6c41 |
Author: Niels Baggesen <nba@users.sourceforge.net>
|
|
|
9a6c41 |
Date: Mon Sep 1 08:59:04 2014 +0200
|
|
|
9a6c41 |
|
|
|
9a6c41 |
Fix commit 7f4a7b891332899cea26e95be0337aae01648742: dont mix code and declarations.
|
|
|
9a6c41 |
|
|
|
9a6c41 |
diff --git a/snmplib/mib.c b/snmplib/mib.c
|
|
|
9a6c41 |
index c6e0010..7dcf3d0 100644
|
|
|
9a6c41 |
--- a/snmplib/mib.c
|
|
|
9a6c41 |
+++ b/snmplib/mib.c
|
|
|
9a6c41 |
@@ -1737,6 +1737,8 @@ sprint_realloc_null(u_char ** buf, size_t * buf_len, size_t * out_len,
|
|
|
9a6c41 |
const struct enum_list *enums,
|
|
|
9a6c41 |
const char *hint, const char *units)
|
|
|
9a6c41 |
{
|
|
|
9a6c41 |
+ u_char str[] = "NULL";
|
|
|
9a6c41 |
+
|
|
|
9a6c41 |
if (var->type != ASN_NULL) {
|
|
|
9a6c41 |
if (!netsnmp_ds_get_boolean(
|
|
|
9a6c41 |
NETSNMP_DS_LIBRARY_ID, NETSNMP_DS_LIB_QUICKE_PRINT)) {
|
|
|
9a6c41 |
@@ -1749,7 +1751,6 @@ sprint_realloc_null(u_char ** buf, size_t * buf_len, size_t * out_len,
|
|
|
9a6c41 |
NULL);
|
|
|
9a6c41 |
}
|
|
|
9a6c41 |
|
|
|
9a6c41 |
- u_char str[] = "NULL";
|
|
|
9a6c41 |
return snmp_strcat(buf, buf_len, out_len, allow_realloc, str);
|
|
|
9a6c41 |
}
|
|
|
9a6c41 |
|