Skip to content

Commit

Permalink
odp-util: Fix parsing corner case for encap_nsh() actions.
Browse files Browse the repository at this point in the history
When nothing matched, the code would loop forever.

Found with libfuzzer.

Reported-by: Bhargava Shastry <[email protected]>
Signed-off-by: Ben Pfaff <[email protected]>
Acked-by: Jan Scheurich <[email protected]>
  • Loading branch information
blp committed Dec 1, 2017
1 parent 59b1e02 commit 0884990
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 0 deletions.
3 changes: 3 additions & 0 deletions lib/odp-util.c
Original file line number Diff line number Diff line change
Expand Up @@ -1870,6 +1870,9 @@ parse_odp_encap_nsh_action(const char *s, struct ofpbuf *actions)
}
continue;
}

ret = -EINVAL;
goto out;
}
out:
if (ret < 0) {
Expand Down
8 changes: 8 additions & 0 deletions tests/odp.at
Original file line number Diff line number Diff line change
Expand Up @@ -362,3 +362,11 @@ AT_CHECK_UNQUOTED([ovstest test-odp parse-actions < actions.txt], [0],
[`cat actions.txt`
])
AT_CLEANUP

AT_SETUP([OVS datapath actions parsing and formatting - invalid forms])
dnl This caused a hang in older versions.
AT_CHECK([echo 'encap_nsh@:{@' | ovstest test-odp parse-actions
], [0], [dnl
odp_actions_from_string: error
])
AT_CLEANUP

0 comments on commit 0884990

Please sign in to comment.