From effe821e25bed4da2499a3b19deff3a61973988f Mon Sep 17 00:00:00 2001 From: Donald Sharp Date: Sun, 15 Jan 2017 18:45:09 -0500 Subject: ospfd: Fix some more virtual-link crashes This commit fixes 2 virtual link cli crashes. Signed-off-by: Donald Sharp --- ospfd/ospf_vty.c | 25 ++++++++++++++++--------- 1 file changed, 16 insertions(+), 9 deletions(-) (limited to 'ospfd/ospf_vty.c') diff --git a/ospfd/ospf_vty.c b/ospfd/ospf_vty.c index fb24e0572..874294ded 100644 --- a/ospfd/ospf_vty.c +++ b/ospfd/ospf_vty.c @@ -1104,15 +1104,22 @@ DEFUN (ospf_area_vlink, case 'm': /* message-digest-key */ i++; - vl_config.crypto_key_id = strtol (argv[i]->arg, NULL, 10); - if (vl_config.crypto_key_id < 0) - return CMD_WARNING; - i++; - memset(md5_key, 0, OSPF_AUTH_MD5_SIZE+1); - strncpy (md5_key, argv[i]->arg, OSPF_AUTH_MD5_SIZE); - vl_config.md5_key = md5_key; + if (i < argc) + { + vl_config.crypto_key_id = strtol (argv[i]->arg, NULL, 10); + if (vl_config.crypto_key_id < 0) + return CMD_WARNING; + i++; + if (i < argc) + { + memset(md5_key, 0, OSPF_AUTH_MD5_SIZE+1); + strncpy (md5_key, argv[i]->arg, OSPF_AUTH_MD5_SIZE); + vl_config.md5_key = md5_key; + } + } + else + vl_config.md5_key = NULL; break; - } } @@ -1238,7 +1245,7 @@ DEFUN (no_ospf_area_vlink, /* If we are down here, we are reseting parameters */ /* Deal with other parameters */ - for (i=6; argc; i++) + for (i=6; i < argc; i++) { /* vty_out (vty, "argv[%d] - %s%s", i, argv[i], VTY_NEWLINE); */ -- cgit v1.2.3