diff mbox series

[ovs-dev,2/2] odp-util: Fix fuzz runtime error of invalid dont_send value

Message ID 1545871943-21751-2-git-send-email-pkusunyifeng@gmail.com
State Accepted
Headers show
Series [ovs-dev,1/2] odp-util: Fix a bug in parse_odp_push_nsh_action | expand

Commit Message

Yifeng Sun Dec. 27, 2018, 12:52 a.m. UTC
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 <pkusunyifeng@gmail.com>
---
 lib/odp-util.c | 4 ++--
 lib/odp-util.h | 4 ++--
 2 files changed, 4 insertions(+), 4 deletions(-)

Comments

Ben Pfaff Dec. 27, 2018, 7:12 p.m. UTC | #1
On Wed, Dec 26, 2018 at 04:52:23PM -0800, Yifeng Sun wrote:
> 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 <pkusunyifeng@gmail.com>

Applied, thanks.
diff mbox series

Patch

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;