Oss-fuzz complains that (struct user_action_cookie)->controller->dont_send
has invalid vlue, like below:
runtime error: load of value 26, which is not a valid value for type 'bool'

>From this piece of code "cookie.controller.dont_send ? 1 : 0", it looks
like that we want to tolerate values than 0 and 1.

Thus, this patch changes the types of dont_send and continuation from bool
to uint8_t in order to make oss-fuzz happy.

Reported-at: https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=11330
Signed-off-by: Yifeng Sun <pkusunyif...@gmail.com>
---
 lib/odp-util.c | 4 ++--
 lib/odp-util.h | 4 ++--
 2 files changed, 4 insertions(+), 4 deletions(-)

diff --git a/lib/odp-util.c b/lib/odp-util.c
index af855873690c..75c411f36800 100644
--- a/lib/odp-util.c
+++ b/lib/odp-util.c
@@ -496,8 +496,8 @@ format_odp_userspace_action(struct ds *ds, const struct 
nlattr *attr,
                               ",controller_id=%"PRIu16
                               ",max_len=%"PRIu16,
                               cookie.controller.reason,
-                              cookie.controller.dont_send ? 1 : 0,
-                              cookie.controller.continuation ? 1 : 0,
+                              !!cookie.controller.dont_send,
+                              !!cookie.controller.continuation,
                               cookie.controller.recirc_id,
                               ntohll(get_32aligned_be64(
                                          &cookie.controller.rule_cookie)),
diff --git a/lib/odp-util.h b/lib/odp-util.h
index 6e684f8e6d8b..aa8e6efe3750 100644
--- a/lib/odp-util.h
+++ b/lib/odp-util.h
@@ -339,8 +339,8 @@ struct user_action_cookie {
 
         struct {
             /* USER_ACTION_COOKIE_CONTROLLER. */
-            bool dont_send;         /* Don't send the packet to controller. */
-            bool continuation;      /* Send packet-in as a continuation. */
+            uint8_t dont_send;      /* Don't send the packet to controller. */
+            uint8_t continuation;   /* Send packet-in as a continuation. */
             uint16_t reason;
             uint32_t recirc_id;
             ovs_32aligned_be64 rule_cookie;
-- 
2.7.4

_______________________________________________
dev mailing list
d...@openvswitch.org
https://mail.openvswitch.org/mailman/listinfo/ovs-dev

Reply via email to