diff mbox

[ovs-dev] ofp-util: return BAD TYPE for consistency at ofputil_decode_group_mod()

Message ID 1450803751-22000-1-git-send-email-fbl@redhat.com
State Accepted
Headers show

Commit Message

Flavio Leitner Dec. 22, 2015, 5:02 p.m. UTC
Code earlier in this function validated that gm->type is valid, so
the default case at the end of the function would be impossible, but
since the code can change or perhaps get copied, return the correct
error to keep consistency and avoid reintroducing the bug fixed by
commit 09d4b951636b ("ofp-util: Reject bad group type and command
with error instead of abort.")

Signed-off-by: Flavio Leitner <fbl@redhat.com>
---
 lib/ofp-util.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

Comments

Ben Pfaff Dec. 23, 2015, 12:49 a.m. UTC | #1
On Tue, Dec 22, 2015 at 03:02:31PM -0200, Flavio Leitner wrote:
> Code earlier in this function validated that gm->type is valid, so
> the default case at the end of the function would be impossible, but
> since the code can change or perhaps get copied, return the correct
> error to keep consistency and avoid reintroducing the bug fixed by
> commit 09d4b951636b ("ofp-util: Reject bad group type and command
> with error instead of abort.")
> 
> Signed-off-by: Flavio Leitner <fbl@redhat.com>

Thanks, applied to master.
diff mbox

Patch

diff --git a/lib/ofp-util.c b/lib/ofp-util.c
index d7e9ccc..126b555 100644
--- a/lib/ofp-util.c
+++ b/lib/ofp-util.c
@@ -8880,7 +8880,9 @@  ofputil_decode_group_mod(const struct ofp_header *oh,
             }
             break;
         default:
-            OVS_NOT_REACHED();
+            /* Returning BAD TYPE to be consistent
+             * though gm->type has been checked already. */
+            return OFPERR_OFPGMFC_BAD_TYPE;
         }
     }