Skip to content

Commit

Permalink
Coverity issues in contrail-controller/mvpn_table.cc
Browse files Browse the repository at this point in the history
I have run Coverity on branch R5.0 and it reported the
following issues in contrail-controller/mvpn_table.cc:

- uninit_use_in_call: Using uninitialized value
prefix.ip_prefixlen_ when calling MvpnPrefix
- uninit_use_in_call: Using uninitialized value
prefix.asn_ when calling MvpnPrefix

The issues listed above are encountered in the following
functions from mvpn_table.cc:
MvpnTable::CreateType4LeafADRoutePrefix
MvpnTable::CreateType2ADRoutePrefix
MvpnTable::CreateType1ADRoutePrefix
MvpnTable::CreateType7PrefixFromType4
MvpnTable::CreateType3SPMSIRoutePrefix
MvpnTable::CreateType7SourceTreeJoinRoutePrefix

Indeed, the called MvpnPrefix constructor does not
initialize neither ip_prefixlen_, nor asn_.
Solution is to initialize these variables in all MvpnPrefix
constructors that did not initialize them.

Change-Id: Ie17837b10cfd0a0458d858d538987e51be1206a1
Closes-Bug: #1770394
Signed-off-by: Anda Nicolae <anicolae@lenovo.com>
  • Loading branch information
Anda Nicolae committed Jun 5, 2018
1 parent 7cb8289 commit 9ad6627
Showing 1 changed file with 9 additions and 6 deletions.
15 changes: 9 additions & 6 deletions src/bgp/mvpn/mvpn_route.cc
Expand Up @@ -38,27 +38,29 @@ MvpnPrefix::MvpnPrefix() : type_(MvpnPrefix::Unspecified), ip_prefixlen_(0),

MvpnPrefix::MvpnPrefix(uint8_t type, const RouteDistinguisher &rd,
const uint32_t asn)
: type_(type), rd_(rd), asn_(asn) {
: type_(type), rd_(rd), ip_prefixlen_(0), asn_(asn) {

assert(type == InterASPMSIADRoute);
}

MvpnPrefix::MvpnPrefix(uint8_t type, const Ip4Address &originator)
: type_(type), originator_(originator) {
: type_(type), originator_(originator), ip_prefixlen_(0), asn_(0) {

assert(type == LeafADRoute);
}

MvpnPrefix::MvpnPrefix(uint8_t type, const RouteDistinguisher &rd,
const Ip4Address &originator)
: type_(type), rd_(rd), originator_(originator) {
: type_(type), rd_(rd), originator_(originator), ip_prefixlen_(0),
asn_(0) {

assert(type == IntraASPMSIADRoute);
}

MvpnPrefix::MvpnPrefix(uint8_t type, const RouteDistinguisher &rd,
const Ip4Address &group, const Ip4Address &source)
: type_(type), rd_(rd), group_(group), source_(source) {
: type_(type), rd_(rd), group_(group), source_(source),
ip_prefixlen_(0), asn_(0) {

assert(type == SourceActiveADRoute);
}
Expand All @@ -67,14 +69,15 @@ MvpnPrefix::MvpnPrefix(uint8_t type, const RouteDistinguisher &rd,
const Ip4Address &originator,
const Ip4Address &group, const Ip4Address &source)
: type_(type), rd_(rd), originator_(originator),
group_(group), source_(source) {
group_(group), source_(source), ip_prefixlen_(0), asn_(0) {

assert(type == SPMSIADRoute);
}

MvpnPrefix::MvpnPrefix(uint8_t type, const RouteDistinguisher &rd,
const uint32_t asn, const Ip4Address &group, const Ip4Address &source)
: type_(type), rd_(rd), group_(group), source_(source), asn_(asn) {
: type_(type), rd_(rd), group_(group), source_(source), ip_prefixlen_(0),
asn_(asn) {

assert((type == SharedTreeJoinRoute) || (type == SourceTreeJoinRoute));
}
Expand Down

0 comments on commit 9ad6627

Please sign in to comment.