aboutsummaryrefslogtreecommitdiffstats
path: root/src/vppinfra/unformat.c
diff options
context:
space:
mode:
authorBilly McFall <bmcfall@redhat.com>2017-02-15 09:03:06 -0500
committerFlorin Coras <florin.coras@gmail.com>2017-02-16 08:21:54 +0000
commit205e934ee7530dac475be14d9054183625171ccc (patch)
tree35c22ccfa46a11211e76366d2b7407f3cd0098ed /src/vppinfra/unformat.c
parent613c79f8c9fd99439e10141ba4e1fe0d463fc8a3 (diff)
VPP-638: 'set interface ipsec key garbage' causes infinite loop
In the CLI parsing of 'set interface ipsec key garbage', the token 'garbage' enters the processing code for the <key>. This enters unformat_hex_string(..) which looks through the input for 0-9,a-f and drops out if a non-hex digit is encountered. The problem is that it returns 1, indicating that input has been processed, but in this case, no characters have been removed from the input string. This causes the calling function to go to the top of the loop and process the next token, which is now the same token and gets stuck in an infinite loop. Updated unformat_hex_string(..) to return 0 if no characters were processed. This funcitons is used in multiple CLI Commands, but most have token that preceeds the hex string. Since the token is stripped, the CLI command is able to avoid an infinte loop. Change-Id: Ib54f04f23c4d3563ec57a2450982d3648cedec0e Signed-off-by: Billy McFall <bmcfall@redhat.com>
Diffstat (limited to 'src/vppinfra/unformat.c')
-rw-r--r--src/vppinfra/unformat.c5
1 files changed, 5 insertions, 0 deletions
diff --git a/src/vppinfra/unformat.c b/src/vppinfra/unformat.c
index 7c636ccce89..f626f05e355 100644
--- a/src/vppinfra/unformat.c
+++ b/src/vppinfra/unformat.c
@@ -306,6 +306,11 @@ unformat_hex_string (unformat_input_t * input, va_list * va)
vec_free (s);
return 0;
}
+ /* Make sure something was processed. */
+ else if (s == 0)
+ {
+ return 0;
+ }
*hexstring_return = s;
return 1;