VPP-638: 'set interface ipsec key garbage' causes infinite loop 44/5144/2
authorBilly McFall <bmcfall@redhat.com>
Wed, 15 Feb 2017 14:03:06 +0000 (09:03 -0500)
committerFlorin Coras <florin.coras@gmail.com>
Thu, 16 Feb 2017 08:21:54 +0000 (08:21 +0000)
commit205e934ee7530dac475be14d9054183625171ccc
tree35c22ccfa46a11211e76366d2b7407f3cd0098ed
parent613c79f8c9fd99439e10141ba4e1fe0d463fc8a3
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>
src/vppinfra/unformat.c