From 908995c56feeac6dc8dda3865a1c2eb3e7b718fb Mon Sep 17 00:00:00 2001 From: Ben Pfaff Date: Thu, 16 Apr 2015 13:40:04 -0700 Subject: [PATCH] ofp-parse: Properly report error for invalid bucket ID. The inner 'error' shadowed an outer one, so that the error, when set, was never returned to the caller. Found by LLVM scan-build. Reported-by: Kevin Lo Signed-off-by: Ben Pfaff Acked-by: Jarno Rajahalme --- lib/ofp-parse.c | 2 +- tests/ofproto.at | 5 +++++ 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/lib/ofp-parse.c b/lib/ofp-parse.c index 8fce546f4..83f06f30f 100644 --- a/lib/ofp-parse.c +++ b/lib/ofp-parse.c @@ -1333,7 +1333,7 @@ parse_ofp_group_mod_str__(struct ofputil_group_mod *gm, uint16_t command, } else if (!strcmp(value, "last")) { gm->command_bucket_id = OFPG15_BUCKET_LAST; } else { - char *error = str_to_u32(value, &gm->command_bucket_id); + error = str_to_u32(value, &gm->command_bucket_id); if (error) { goto out; } diff --git a/tests/ofproto.at b/tests/ofproto.at index 5ae313998..acab26e5b 100644 --- a/tests/ofproto.at +++ b/tests/ofproto.at @@ -454,6 +454,11 @@ AT_CHECK([STRIP_XIDS stdout], [0], [dnl OFPST_GROUP_DESC reply (OF1.5): group_id=1234,type=all,bucket=bucket_id:0,actions=output:0,bucket=bucket_id:1,actions=output:1,bucket=bucket_id:10,actions=output:10,bucket=bucket_id:11,actions=output:11,bucket=bucket_id:12,actions=output:12,bucket=bucket_id:13,actions=output:13,bucket=bucket_id:14,actions=output:14,bucket=bucket_id:15,actions=output:15,bucket=bucket_id:20,actions=output:20,bucket=bucket_id:21,actions=output:21 ]) + +# Negative test. +AT_CHECK([ovs-ofctl -O OpenFlow15 -vwarn insert-buckets br0 group_id=1234,command_bucket_id=0xffffff01,bucket=bucket_id:0,actions=output:0,bucket=bucket_id:1,actions=output:1], [1], [], + [ovs-ofctl: invalid command bucket id 4294967041 +]) OVS_VSWITCHD_STOP AT_CLEANUP