summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorIgor Mikhailov (imichail) <imichail@cisco.com>2016-09-25 15:11:53 -0700
committerJohn Lo <loj@cisco.com>2016-09-26 21:50:10 +0000
commitab3e42b08db051eca5c4516e80ae6c428615a8f9 (patch)
tree60aa18bc1f5afb8f36a8e50a7dbdb0b3e441580d
parent271ad32d25bbc4e6ebc7aa113f04610112819f34 (diff)
Fix for potential use of uninitialized variables
The code allowed for the command 'set interface unnumbered' to be processed without specifying any parameters, thus the set logic of the command would have been using uninitialized variables 'unnumbered_sw_if_index' and 'inherit_from_sw_if_index'. Change-Id: I4de14fa1096527c5c48f74304db379f9953760a8 Signed-off-by: Igor Mikhailov (imichail) <imichail@cisco.com>
-rw-r--r--vnet/vnet/interface_cli.c36
1 files changed, 13 insertions, 23 deletions
diff --git a/vnet/vnet/interface_cli.c b/vnet/vnet/interface_cli.c
index 477716d4b97..f7d42a722d5 100644
--- a/vnet/vnet/interface_cli.c
+++ b/vnet/vnet/interface_cli.c
@@ -815,27 +815,17 @@ set_unnumbered (vlib_main_t * vm,
int is_set = 0;
int is_del = 0;
- while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
- {
-
- if (unformat (input, "%U use %U",
- unformat_vnet_sw_interface, vnm, &unnumbered_sw_if_index,
- unformat_vnet_sw_interface, vnm,
- &inherit_from_sw_if_index))
- is_set = 1;
- else if (unformat (input, "del %U",
- unformat_vnet_sw_interface,
- vnm, &unnumbered_sw_if_index))
- is_del = 1;
- else
- {
- if (is_set || is_del)
- break;
- else
- return clib_error_return
- (0, "parse error '%U'", format_unformat_error, input);
- }
- }
+ if (unformat (input, "%U use %U",
+ unformat_vnet_sw_interface, vnm, &unnumbered_sw_if_index,
+ unformat_vnet_sw_interface, vnm, &inherit_from_sw_if_index))
+ is_set = 1;
+ else if (unformat (input, "del %U",
+ unformat_vnet_sw_interface, vnm,
+ &unnumbered_sw_if_index))
+ is_del = 1;
+ else
+ return clib_error_return (0, "parse error '%U'",
+ format_unformat_error, input);
si = vnet_get_sw_interface (vnm, unnumbered_sw_if_index);
if (is_del)
@@ -843,7 +833,7 @@ set_unnumbered (vlib_main_t * vm,
si->flags &= ~(VNET_SW_INTERFACE_FLAG_UNNUMBERED);
si->unnumbered_sw_if_index = (u32) ~ 0;
}
- else
+ else if (is_set)
{
si->flags |= VNET_SW_INTERFACE_FLAG_UNNUMBERED;
si->unnumbered_sw_if_index = inherit_from_sw_if_index;
@@ -855,7 +845,7 @@ set_unnumbered (vlib_main_t * vm,
/* *INDENT-OFF* */
VLIB_CLI_COMMAND (set_unnumbered_command, static) = {
.path = "set interface unnumbered",
- .short_help = "set interface unnumbered [<intfc> use <intfc>][del <intfc>]",
+ .short_help = "set interface unnumbered [<intfc> use <intfc> | del <intfc>]",
.function = set_unnumbered,
};
/* *INDENT-ON* */