Opened 4 years ago

Last modified 2 years ago

#3446 new defect

Unitialized member variables in constructors

Reported by: stephen Owned by:
Priority: very low Milestone: Outstanding Tasks
Component: dhcp Version: git
Keywords: Cc:
CVSS Scoring: Parent Tickets:
Sensitive: no Defect Severity: N/A
Sub-Project: DHCP Feature Depending on Ticket:
Estimated Difficulty: 0 Add Hours to Ticket: 0
Total Hours: 0 Internal?: no

Description (last modified by stephen)

Three Coverity-detected unitialized member variable issues:

1) In the constructor of Thread::Impl in src/lib/util/threads/thread.cc (CID 1202723):

 44class Thread::Impl {
 45public:
 46    Impl(const boost::function<void ()>& main) :
 47        // Two things to happen before destruction - thread needs to terminate
 48        // and the creating thread needs to release it.
 49        waiting_(2),
 50        main_(main),
 51        exception_(false)
   
CID 1202723 (#1 of 1): Uninitialized scalar field (UNINIT_CTOR)2. uninit_member: Non-static class member tid_ is not initialized in this constructor nor in any functions that it calls.
 52    {}

All that is needed is the addition of tid_(0) after the initialization of "exception_".

2) In the constructor of NAPTRImpl in src/lib/dns/dataclass.cc (CID 1202726):

2555class NAPTRImpl {
2556public:
    
2. uninit_member: Non-static class member order is not initialized in this constructor nor in any functions that it calls.
    
CID 1202726 (#1 of 1): Uninitialized scalar field (UNINIT_CTOR)4. uninit_member: Non-static class member preference is not initialized in this constructor nor in any functions that it calls.
2557    NAPTRImpl() : replacement(".") {}

("order" and "preference" are both uint16_t, and could be initialized to 0.)

3) In the constructor of SocketSessionForwarded::ForwarderImpl? in src/lib/util/io/socketsession.cc (CID 1202727):

 86struct SocketSessionForwarder::ForwarderImpl {
   
2. uninit_member: Non-static class member field sock_un_.sun_family is not initialized in this constructor nor in any functions that it calls.
   
CID 1202727 (#1 of 1): Uninitialized scalar field (UNINIT_CTOR)4. uninit_member: Non-static class member sock_un_len_ is not initialized in this constructor nor in any functions that it calls.
 87    ForwarderImpl() : fd_(-1), buf_(DEFAULT_HEADER_BUFLEN) {}
 88    struct sockaddr_un sock_un_;
   
3. member_decl: Class member declaration for sock_un_len_.
 89    socklen_t sock_un_len_;

Both these variables should be zeroed.

Subtickets

Change History (4)

comment:1 Changed 4 years ago by stephen

  • Description modified (diff)
  • Summary changed from Unitialized scalar field in Thread::Impl constructor to Unitialized member variables in constructors

comment:2 Changed 4 years ago by tomek

  • Milestone changed from Kea-proposed to Kea1.0

comment:3 Changed 2 years ago by stephen

  • Milestone changed from Kea1.0 to DHCP Outstanding Tasks
  • Version set to git

Per Kea planning meeting in October, move out of 1.0.

comment:4 Changed 2 years ago by tomek

  • Milestone changed from DHCP Outstanding Tasks to Outstanding Tasks

Milestone renamed

Note: See TracTickets for help on using tickets.