diff options
author | lloyd <[email protected]> | 2015-05-15 03:31:56 +0000 |
---|---|---|
committer | lloyd <[email protected]> | 2015-05-15 03:31:56 +0000 |
commit | a4e88fa2610da732ea1125b1ed970baed6d286bb (patch) | |
tree | 10e422f42bcf419bbcec835feb4f41c590286bbe /src/lib/entropy | |
parent | 12eea2e817528e7d1a85e5e80b360eead6e5d206 (diff) |
Fix various bugs found by Coverity scanner.
Uninitialized variables, missing divide by zero checks, missing
virtual destructor, etc. Only thing serious is bug in TLS maximum
fragment decoder; missing breaks in switch statement meant receiver
would treat any negotiated max frament as 4k limit.
Diffstat (limited to 'src/lib/entropy')
-rw-r--r-- | src/lib/entropy/unix_procs/unix_procs.cpp | 27 |
1 files changed, 10 insertions, 17 deletions
diff --git a/src/lib/entropy/unix_procs/unix_procs.cpp b/src/lib/entropy/unix_procs/unix_procs.cpp index d9aa787cf..d3208b7fc 100644 --- a/src/lib/entropy/unix_procs/unix_procs.cpp +++ b/src/lib/entropy/unix_procs/unix_procs.cpp @@ -80,24 +80,11 @@ void UnixProcessInfo_EntropySource::poll(Entropy_Accumulator& accum) accum.add(usage, 0.0); } -namespace { - -void do_exec(const std::vector<std::string>& args) - { - // cleaner way to do this? - const char* arg0 = (args.size() > 0) ? args[0].c_str() : nullptr; - const char* arg1 = (args.size() > 1) ? args[1].c_str() : nullptr; - const char* arg2 = (args.size() > 2) ? args[2].c_str() : nullptr; - const char* arg3 = (args.size() > 3) ? args[3].c_str() : nullptr; - const char* arg4 = (args.size() > 4) ? args[4].c_str() : nullptr; - - ::execl(arg0, arg0, arg1, arg2, arg3, arg4, NULL); - } - -} - void Unix_EntropySource::Unix_Process::spawn(const std::vector<std::string>& args) { + if(args.empty()) + throw std::invalid_argument("Cannot spawn process without path"); + shutdown(); int pipe[2]; @@ -126,7 +113,13 @@ void Unix_EntropySource::Unix_Process::spawn(const std::vector<std::string>& arg if(close(STDERR_FILENO) != 0) ::exit(127); - do_exec(args); + const char* arg0 = args[0].c_str(); + const char* arg1 = (args.size() > 1) ? args[1].c_str() : nullptr; + const char* arg2 = (args.size() > 2) ? args[2].c_str() : nullptr; + const char* arg3 = (args.size() > 3) ? args[3].c_str() : nullptr; + const char* arg4 = (args.size() > 4) ? args[4].c_str() : nullptr; + + ::execl(arg0, arg0, arg1, arg2, arg3, arg4, NULL); ::exit(127); } } |