summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--ChangeLog3
-rw-r--r--daemon/config.c36
2 files changed, 26 insertions, 13 deletions
diff --git a/ChangeLog b/ChangeLog
index 0cc8f88..14aaad8 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,7 +1,8 @@
0.9 ?????
- Support failover between multiple agents.
- Support table queries by looking up table indexes.
- - Major refactoring of internals.
+ - Major refactoring of internals.
+ - Warn and ignore MIBs that we don't recognize.
0.8 [2007-07-16]
- Fix assertion when reallocating SNMP request memory
diff --git a/daemon/config.c b/daemon/config.c
index 55ee597..fcc4379 100644
--- a/daemon/config.c
+++ b/daemon/config.c
@@ -215,17 +215,20 @@ parse_query (rb_item *item, char *query, config_ctx *ctx)
if (query && *query)
log_warnx ("%s: only using first query argument in snmp URI", ctx->confname);
- item->has_query = 1;
-
/* And parse the query OID */
- if (mib_parse (name, &(item->query_oid)) == -1)
- errx (2, "%s: invalid MIB: %s", ctx->confname, name);
- if (item->query_oid.len >= ASN_MAXOIDLEN)
- errx (2, "request OID is too long");
+ if (mib_parse (name, &(item->query_oid)) == -1) {
+ log_warnx ("%s: ignorning invalid MIB: %s", ctx->confname, name);
+ return;
+ }
+ if (item->query_oid.len >= ASN_MAXOIDLEN) {
+ log_warnx ("%s: ignoring OID that is too long: %s", ctx->confname, name);
+ return;
+ }
log_debug ("parsed MIB into oid: %s -> %s", name,
asn_oid2str (&item->query_oid));
+ item->has_query = 1;
item->query_match = value;
memset (&item->query_last, 0, sizeof (item->query_last));
item->query_matched = 0;
@@ -257,6 +260,21 @@ parse_item (const char *field, char *uri, config_ctx *ctx)
/* Make a new item */
item = (rb_item*)xcalloc (sizeof (*item));
+
+ /* And parse the main field OID */
+ if (mib_parse (path, &(item->field_oid)) == -1) {
+ log_warnx ("%s: ignorning invalid MIB: %s", ctx->confname, path);
+ free (item);
+ return NULL;
+ }
+
+ if (item->field_oid.len >= ASN_MAXOIDLEN) {
+ log_warnx ("%s: ignoring OID that is too long: %s", ctx->confname, path);
+ free (item);
+ return NULL;
+ }
+
+ /* Setup the basics */
item->field = field;
item->community = user ? user : "public";
item->version = version;
@@ -268,12 +286,6 @@ parse_item (const char *field, char *uri, config_ctx *ctx)
parse_hosts (item, host, ctx);
parse_query (item, query, ctx);
- /* And parse the main field OID */
- if (mib_parse (path, &(item->field_oid)) == -1)
- errx (2, "%s: invalid MIB: %s", ctx->confname, path);
- if (item->field_oid.len >= ASN_MAXOIDLEN)
- errx (2, "request OID is too long");
-
log_debug ("parsed MIB into oid: %s -> %s", path,
asn_oid2str (&item->field_oid));