[ovs-dev] ofctl_parse_target: Avoid passing invalid ofputil_protocol to ofputil_protocol_to_ofp_version

Message ID 1541623337-16025-2-git-send-email-pkusunyifeng@gmail.com
State Accepted
Headers show
Series
  • [ovs-dev] ofctl_parse_target: Avoid passing invalid ofputil_protocol to ofputil_protocol_to_ofp_version
Related show

Commit Message

Yifeng Sun Nov. 7, 2018, 8:42 p.m.
In this test, the involved ovs functions expect valid ofputil_protocol
values. Therefore, if usable_protocols is invalid, we should return.
Otherwise, ovs will abort.

Reported-at: https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=11165
Signed-off-by: Yifeng Sun <pkusunyifeng@gmail.com>
---
 tests/oss-fuzz/ofctl_parse_target.c | 1 +
 1 file changed, 1 insertion(+)

Patch

diff --git a/tests/oss-fuzz/ofctl_parse_target.c b/tests/oss-fuzz/ofctl_parse_target.c
index fbd91bdd3e81..db86c7da1ab3 100644
--- a/tests/oss-fuzz/ofctl_parse_target.c
+++ b/tests/oss-fuzz/ofctl_parse_target.c
@@ -22,6 +22,7 @@  ofctl_parse_flows__(struct ofputil_flow_mod *fms, size_t n_fms,
 
     if (!(usable_protocols & OFPUTIL_P_ANY)) {
         printf("no usable protocol\n");
+        return;
     }
     for (i = 0; i < sizeof(enum ofputil_protocol) * CHAR_BIT; i++) {
         protocol = 1u << i;