[ripd] bugs #261, #262: Fix RIPv1 info-leak and unauthenticated route updates
2006-05-04 Paul Jakma <paul.jakma@sun.com>
* (general) Fixes for bugs #261 and 262. Thanks to
Konstantin V. Gavrilenko <kos@arhont.com> for the problem
reports, testing of a series of proposed patches and comment
on the proposed changes in behaviour.
* rip_interface.c: (ip_rip_authentication_mode_cmd) Parse all
of the command before making any changes to configured state.
* ripd.c: (rip_read) RIP version control should be absolute and
always apply, fixes bug #261 by allowing RIPv1 to be disabled.
Fix bug #262: If authentication is enabled, then
unauthenticated packets should not be accepted. We do however
make an exception for RIPv1 REQUEST packets, to which we will
reply as RIPv1 can now be disabled fully, to allow ripd to
still provide routing /information/ to simple devices.
diff --git a/ripd/rip_interface.c b/ripd/rip_interface.c
index 0bc5a31..a5b12db 100644
--- a/ripd/rip_interface.c
+++ b/ripd/rip_interface.c
@@ -1558,6 +1558,7 @@
{
struct interface *ifp;
struct rip_interface *ri;
+ int auth_type;
ifp = (struct interface *)vty->index;
ri = ifp->info;
@@ -1569,9 +1570,9 @@
}
if (strncmp ("md5", argv[0], strlen (argv[0])) == 0)
- ri->auth_type = RIP_AUTH_MD5;
+ auth_type = RIP_AUTH_MD5;
else if (strncmp ("text", argv[0], strlen (argv[0])) == 0)
- ri->auth_type = RIP_AUTH_SIMPLE_PASSWORD;
+ auth_type = RIP_AUTH_SIMPLE_PASSWORD;
else
{
vty_out (vty, "mode should be md5 or text%s", VTY_NEWLINE);
@@ -1579,13 +1580,16 @@
}
if (argc == 1)
- return CMD_SUCCESS;
+ {
+ ri->auth_type = auth_type;
+ return CMD_SUCCESS;
+ }
- if ( (argc == 2) && (ri->auth_type != RIP_AUTH_MD5) )
+ if ( (argc == 2) && (auth_type != RIP_AUTH_MD5) )
{
vty_out (vty, "auth length argument only valid for md5%s", VTY_NEWLINE);
return CMD_WARNING;
-}
+ }
if (strncmp ("r", argv[1], 1) == 0)
ri->md5_auth_len = RIP_AUTH_MD5_SIZE;
@@ -1593,7 +1597,9 @@
ri->md5_auth_len = RIP_AUTH_MD5_COMPAT_SIZE;
else
return CMD_WARNING;
-
+
+ ri->auth_type = auth_type;
+
return CMD_SUCCESS;
}