Comment 9 for bug 1770169

Revision history for this message
OpenContrail Admin (ci-admin-f) wrote : A change has been merged

Reviewed: https://review.opencontrail.org/42902
Committed: http://github.com/Juniper/contrail-controller/commit/e0552404e0c1714a342e8329a4bacc726ed18855
Submitter: Zuul v3 CI (<email address hidden>)
Branch: master

commit e0552404e0c1714a342e8329a4bacc726ed18855
Author: Anda Nicolae <email address hidden>
Date: Wed May 9 17:14:21 2018 +0300

Coverity issues in contrail-controller/agent_param.cc

I have run Coverity on branch R5.0 and it reported the
following issues in contrail-controller/agent_param.cc:
- buffer_size_warning: Calling strncpy with a maximum size
argument of 16 bytes on destination array ifrn.ifrn_name of
size 16 bytes might leave the destination string unterminated
in agent_param.cc:ValidateInterface
- leaked_storage: Variable f going out of scope leaks the storage
it points to in agent_param.cc:ValidateInterface

Indeed, for the 1st issue, the length of std::string::c_str() may be
greater than IF_NAMESIZE. In that case, after calling strncpy, ifrn.ifrn_name
will not be a NULL-terminated string.
For the 2nd issue, we need to close the file pointer before exiting the function.

Change-Id: I9ad412d02323fb5fe8175f67680d5c232bb76dc2
Closes-bug: #1770169
Signed-off-by: Anda Nicolae <email address hidden>