Skip to content

Commit

Permalink
[syncd][Drop Counters] Check for string length before calling substr (s…
Browse files Browse the repository at this point in the history
…onic-net#1456)

* [orchagent][drop counter] Check for string length before calling substr
  • Loading branch information
smaheshm authored Oct 2, 2020
1 parent 23be627 commit e4dfb37
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions orchagent/debug_counter/drop_counter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -318,11 +318,21 @@ unordered_set<string> DropCounter::getSupportedDropReasons(sai_debug_counter_att
if (drop_reason_type == SAI_DEBUG_COUNTER_ATTR_IN_DROP_REASON_LIST)
{
drop_reason = sai_serialize_ingress_drop_reason(static_cast<sai_in_drop_reason_t>(drop_reason_list.list[i]));
// in case of unsupported counter, enum value is returned as a str
if (drop_reason.length() < INGRESS_DROP_REASON_PREFIX_LENGTH)
{
continue;
}
drop_reason = drop_reason.substr(INGRESS_DROP_REASON_PREFIX_LENGTH);
}
else
{
drop_reason = sai_serialize_egress_drop_reason(static_cast<sai_out_drop_reason_t>(drop_reason_list.list[i]));
// in case of unsupported counter, enum value is returned as a str
if (drop_reason.length() < EGRESS_DROP_REASON_PREFIX_LENGTH)
{
continue;
}
drop_reason = drop_reason.substr(EGRESS_DROP_REASON_PREFIX_LENGTH);
}

Expand Down

0 comments on commit e4dfb37

Please sign in to comment.