summaryrefslogtreecommitdiffstats
path: root/usr.sbin/bsnmpd
diff options
context:
space:
mode:
authorsyrinx <syrinx@FreeBSD.org>2006-12-09 20:58:26 +0000
committersyrinx <syrinx@FreeBSD.org>2006-12-09 20:58:26 +0000
commita7250df1fb8c1804c31ff9d28e758a4e6f05c5a7 (patch)
tree38850d39924121a7a822ede2208a47aaf4351138 /usr.sbin/bsnmpd
parent0e28b7e9fc7bbc9e326d94e48d0e1c7bd2358f99 (diff)
downloadFreeBSD-src-a7250df1fb8c1804c31ff9d28e758a4e6f05c5a7.zip
FreeBSD-src-a7250df1fb8c1804c31ff9d28e758a4e6f05c5a7.tar.gz
Instead of explicitly initializing variables to avoid compiler warnings,
add a default case to handle the situation when the variables are not initialized. Furthermore, abort() if the snmp agent passes an invalid option to the bridge module. As the option (SET, GET, GETNEXT, COMMIT, ROLLBACK) is determined by the snmp agent based on the operation requested by user, this behaviour is unlikely to be abused as a source for a DoS, but if ever hit will likely reveal a problem in the snmp agent or bridge module. Approved by: bz (mentor)
Diffstat (limited to 'usr.sbin/bsnmpd')
-rw-r--r--usr.sbin/bsnmpd/modules/snmp_bridge/bridge_addrs.c7
-rw-r--r--usr.sbin/bsnmpd/modules/snmp_bridge/bridge_if.c23
-rw-r--r--usr.sbin/bsnmpd/modules/snmp_bridge/bridge_port.c28
3 files changed, 42 insertions, 16 deletions
diff --git a/usr.sbin/bsnmpd/modules/snmp_bridge/bridge_addrs.c b/usr.sbin/bsnmpd/modules/snmp_bridge/bridge_addrs.c
index fdb0fa3..0563ceb 100644
--- a/usr.sbin/bsnmpd/modules/snmp_bridge/bridge_addrs.c
+++ b/usr.sbin/bsnmpd/modules/snmp_bridge/bridge_addrs.c
@@ -408,7 +408,6 @@ op_dot1d_tp_fdb(struct snmp_context *c __unused, struct snmp_value *val,
bridge_update_addrs(bif) <= 0)
return (SNMP_ERR_NOSUCHNAME);
- te = NULL; /* Make the compiler happy. */
switch (op) {
case SNMP_OP_GET:
if ((te = bridge_addrs_get(&val->var, sub, bif)) == NULL)
@@ -426,6 +425,7 @@ op_dot1d_tp_fdb(struct snmp_context *c __unused, struct snmp_value *val,
case SNMP_OP_ROLLBACK:
case SNMP_OP_COMMIT:
+ default:
abort();
}
@@ -548,7 +548,7 @@ op_begemot_tp_fdb(struct snmp_context *c __unused, struct snmp_value *val,
uint sub, uint iidx __unused, enum snmp_op op)
{
int ret;
- struct tp_entry *te = NULL;
+ struct tp_entry *te;
if (time(NULL) - address_list_age > bridge_get_data_maxage())
bridge_update_all_addrs();
@@ -572,7 +572,8 @@ op_begemot_tp_fdb(struct snmp_context *c __unused, struct snmp_value *val,
case SNMP_OP_ROLLBACK:
case SNMP_OP_COMMIT:
- return (SNMP_ERR_NOERROR);
+ default:
+ abort();
}
ret = SNMP_ERR_NOERROR;
diff --git a/usr.sbin/bsnmpd/modules/snmp_bridge/bridge_if.c b/usr.sbin/bsnmpd/modules/snmp_bridge/bridge_if.c
index 2805d85..0798012 100644
--- a/usr.sbin/bsnmpd/modules/snmp_bridge/bridge_if.c
+++ b/usr.sbin/bsnmpd/modules/snmp_bridge/bridge_if.c
@@ -1096,7 +1096,7 @@ op_begemot_base_bridge(struct snmp_context *ctx, struct snmp_value *val,
uint sub, uint iidx __unused, enum snmp_op op)
{
int ret;
- struct bridge_if *bif = NULL;
+ struct bridge_if *bif;
if (time(NULL) - bridge_list_age > bridge_get_data_maxage())
bridge_update_all_ifs();
@@ -1127,8 +1127,12 @@ op_begemot_base_bridge(struct snmp_context *ctx, struct snmp_value *val,
case SNMP_OP_ROLLBACK:
return (bridge_rollback_if_status(ctx, val, sub));
+
case SNMP_OP_COMMIT:
return (bridge_commit_if_status(val, sub));
+
+ default:
+ abort();
}
ret = SNMP_ERR_NOERROR;
@@ -1161,8 +1165,8 @@ int
op_begemot_stp(struct snmp_context *ctx, struct snmp_value *val,
uint sub, uint iidx __unused, enum snmp_op op)
{
- int ret = SNMP_ERR_NOERROR; /* Make the compiler happy. */
- struct bridge_if *bif = NULL;
+ int ret;
+ struct bridge_if *bif;
if (time(NULL) - bridge_list_age > bridge_get_data_maxage())
bridge_update_all_ifs();
@@ -1225,6 +1229,9 @@ op_begemot_stp(struct snmp_context *ctx, struct snmp_value *val,
case LEAF_begemotBridgeStpHoldTime:
case LEAF_begemotBridgeStpForwardDelay:
return (SNMP_ERR_NOT_WRITEABLE);
+
+ default:
+ return (SNMP_ERR_NOSUCHNAME);
}
if (ret == 0)
@@ -1266,8 +1273,13 @@ op_begemot_stp(struct snmp_context *ctx, struct snmp_value *val,
case SNMP_OP_COMMIT:
return (SNMP_ERR_NOERROR);
+
+ default:
+ abort();
}
+ ret = SNMP_ERR_NOERROR;
+
switch (val->var.subs[sub - 1]) {
case LEAF_begemotBridgeStpProtocolSpecification:
val->v.integer = bif->prot_spec;
@@ -1342,7 +1354,7 @@ int
op_begemot_tp(struct snmp_context *ctx, struct snmp_value *val,
uint sub, uint iidx __unused, enum snmp_op op)
{
- struct bridge_if *bif = NULL;
+ struct bridge_if *bif;
if (time(NULL) - bridge_list_age > bridge_get_data_maxage())
bridge_update_all_ifs();
@@ -1398,6 +1410,9 @@ op_begemot_tp(struct snmp_context *ctx, struct snmp_value *val,
case SNMP_OP_COMMIT:
return (SNMP_ERR_NOERROR);
+
+ default:
+ abort();
}
switch (val->var.subs[sub - 1]) {
diff --git a/usr.sbin/bsnmpd/modules/snmp_bridge/bridge_port.c b/usr.sbin/bsnmpd/modules/snmp_bridge/bridge_port.c
index 44ea959..9600a1e 100644
--- a/usr.sbin/bsnmpd/modules/snmp_bridge/bridge_port.c
+++ b/usr.sbin/bsnmpd/modules/snmp_bridge/bridge_port.c
@@ -353,7 +353,6 @@ op_dot1d_base_port(struct snmp_context *c __unused, struct snmp_value *val,
bridge_update_memif(bif) <= 0)
return (SNMP_ERR_NOSUCHNAME);
- bp = NULL; /* Make the compiler happy. */
switch (op) {
case SNMP_OP_GET:
if (val->var.len - sub != 1)
@@ -382,6 +381,7 @@ op_dot1d_base_port(struct snmp_context *c __unused, struct snmp_value *val,
case SNMP_OP_ROLLBACK:
case SNMP_OP_COMMIT:
+ default:
abort();
}
@@ -421,8 +421,6 @@ op_dot1d_stp_port(struct snmp_context *ctx, struct snmp_value *val,
bridge_update_memif(bif) <= 0)
return (SNMP_ERR_NOSUCHNAME);
- bp = NULL; /* Make the compiler happy. */
-
switch (op) {
case SNMP_OP_GET:
if (val->var.len - sub != 1)
@@ -508,6 +506,9 @@ op_dot1d_stp_port(struct snmp_context *ctx, struct snmp_value *val,
case SNMP_OP_COMMIT:
return (SNMP_ERR_NOERROR);
+
+ default:
+ abort();
}
ret = SNMP_ERR_NOERROR;
@@ -564,7 +565,6 @@ op_dot1d_stp_ext_port(struct snmp_context *ctx, struct snmp_value *val,
bridge_update_memif(bif) <= 0)
return (SNMP_ERR_NOSUCHNAME);
- bp = NULL; /* Make the compiler happy. */
switch (op) {
case SNMP_OP_GET:
if (val->var.len - sub != 1)
@@ -648,6 +648,9 @@ op_dot1d_stp_ext_port(struct snmp_context *ctx, struct snmp_value *val,
case SNMP_OP_COMMIT:
return (SNMP_ERR_NOERROR);
+
+ default:
+ abort();
}
switch (val->var.subs[sub - 1]) {
@@ -688,7 +691,6 @@ op_dot1d_tp_port(struct snmp_context *c __unused, struct snmp_value *val,
bridge_update_memif(bif) <= 0)
return (SNMP_ERR_NOSUCHNAME);
- bp = NULL; /* Make the compiler happy. */
switch (op) {
case SNMP_OP_GET:
if (val->var.len - sub != 1)
@@ -717,6 +719,7 @@ op_dot1d_tp_port(struct snmp_context *c __unused, struct snmp_value *val,
case SNMP_OP_ROLLBACK:
case SNMP_OP_COMMIT:
+ default:
abort();
}
@@ -1122,7 +1125,7 @@ op_begemot_stp_port(struct snmp_context *ctx, struct snmp_value *val,
uint sub, uint iidx __unused, enum snmp_op op)
{
int ret;
- struct bridge_port *bp = NULL;
+ struct bridge_port *bp;
const char *b_name;
if (time(NULL) - ports_list_age > bridge_get_data_maxage())
@@ -1201,6 +1204,9 @@ op_begemot_stp_port(struct snmp_context *ctx, struct snmp_value *val,
case SNMP_OP_COMMIT:
return (SNMP_ERR_NOERROR);
+
+ default:
+ abort();
}
ret = SNMP_ERR_NOERROR;
@@ -1245,7 +1251,7 @@ op_begemot_stp_ext_port(struct snmp_context *ctx, struct snmp_value *val,
uint sub, uint iidx __unused, enum snmp_op op)
{
int ret;
- struct bridge_port *bp = NULL;
+ struct bridge_port *bp;
const char *b_name;
if (time(NULL) - ports_list_age > bridge_get_data_maxage())
@@ -1322,6 +1328,9 @@ op_begemot_stp_ext_port(struct snmp_context *ctx, struct snmp_value *val,
case SNMP_OP_COMMIT:
return (SNMP_ERR_NOERROR);
+
+ default:
+ abort();
}
switch (val->var.subs[sub - 1]) {
@@ -1352,7 +1361,7 @@ int
op_begemot_tp_port(struct snmp_context *c __unused, struct snmp_value *val,
uint sub, uint iidx __unused, enum snmp_op op)
{
- struct bridge_port *bp = NULL;
+ struct bridge_port *bp;
if (time(NULL) - ports_list_age > bridge_get_data_maxage())
bridge_update_all_ports();
@@ -1374,7 +1383,8 @@ op_begemot_tp_port(struct snmp_context *c __unused, struct snmp_value *val,
case SNMP_OP_ROLLBACK:
case SNMP_OP_COMMIT:
- return (SNMP_ERR_NOERROR);
+ default:
+ abort();
}
switch (val->var.subs[sub - 1]) {
OpenPOWER on IntegriCloud