ovn: Fix extra token detection.
authorJoe Stringer <joestringer@nicira.com>
Tue, 14 Jul 2015 01:19:03 +0000 (18:19 -0700)
committerJoe Stringer <joestringer@nicira.com>
Fri, 17 Jul 2015 17:25:21 +0000 (10:25 -0700)
commit8b34ccdadfbbf6c20dcec1068368029a29afc40a
treeb7ce666f8711e486905815addab0db806911cf6e
parent2bb0bea82711750311974c291e98bec6fc0e077f
ovn: Fix extra token detection.

This code attempts to first check whether another error was detected for
the string it is parsing, then if it's not at the end of the tokens,
report an error. However, 'errorp' is always a valid pointer to a
'char *', so the first check in this statement always evaluates false.

Furthermore, this undefined behaviour may be optimised out by modern
compilers due to the prior dereference in expr_parse(). Fix this to
check the actual value of *errorp. Also add a test to check this case.

Found by MIT STACK undefined behaviour checker.

Signed-off-by: Joe Stringer <joestringer@nicira.com>
Acked-by: Ben Pfaff <blp@nicira.com>
ovn/lib/expr.c
tests/ovn.at