Skip to content

Commit

Permalink
ofp-parse: Properly report error for invalid bucket ID.
Browse files Browse the repository at this point in the history
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 <[email protected]>
Signed-off-by: Ben Pfaff <[email protected]>
Acked-by: Jarno Rajahalme <[email protected]>
  • Loading branch information
blp committed Apr 17, 2015
1 parent 8790a8b commit 908995c
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 1 deletion.
2 changes: 1 addition & 1 deletion lib/ofp-parse.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down
5 changes: 5 additions & 0 deletions tests/ofproto.at
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down

0 comments on commit 908995c

Please sign in to comment.