Skip to content

Commit e03eac2

Browse files
chumakdigsilya
authored andcommitted
ovs-router: Fix potential integer overflow.
There was a theoretical (but unlikely to happen in practice) integer overflow in ovs_router_rule_add_cmd() in the case when rule list comprised only of rules with priority zero, the new rule priority would be calculated as UINT_MAX. Coverity issue: CID 556927: Integer handling issues (INTEGER_OVERFLOW) Expression "rule->prio - 1U", where "rule->prio" is known to be equal to 0, under-flows the type of "rule->prio - 1U", which is type "unsigned int". Fixes: e2a2415 ("ovs-router: Introduce ovs/route/rule/{add, del} commands.") Signed-off-by: Dima Chumak <dchumak@nvidia.com> Signed-off-by: Ilya Maximets <i.maximets@ovn.org>
1 parent 708c83f commit e03eac2

File tree

1 file changed

+1
-2
lines changed

1 file changed

+1
-2
lines changed

lib/ovs-router.c

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1030,8 +1030,7 @@ ovs_router_rule_add_cmd(struct unixctl_conn *conn, int argc OVS_UNUSED,
10301030
uint32_t prev_prio = 0;
10311031

10321032
PVECTOR_FOR_EACH (rule, &rules) {
1033-
if ((!prio && rule->prio) ||
1034-
(rule->prio - prev_prio > 1)) {
1033+
if (rule->prio && (!prio || (rule->prio - prev_prio > 1))) {
10351034
prio = rule->prio - 1;
10361035
}
10371036
prev_prio = rule->prio;

0 commit comments

Comments
 (0)