Flawfinder version 2.0.10, (C) 2001-2019 David A. Wheeler.
Number of rules (primarily dangerous function names) in C/C++ ruleset: 223
Examining data/mahimahi-0.98/src/frontend/delay_queue.cc
Examining data/mahimahi-0.98/src/frontend/delayshell.cc
Examining data/mahimahi-0.98/src/frontend/link_queue.cc
Examining data/mahimahi-0.98/src/frontend/linkshell.cc
Examining data/mahimahi-0.98/src/frontend/loss_queue.cc
Examining data/mahimahi-0.98/src/frontend/lossshell.cc
Examining data/mahimahi-0.98/src/frontend/meter.cc
Examining data/mahimahi-0.98/src/frontend/meter_queue.cc
Examining data/mahimahi-0.98/src/frontend/mod_deepcgi.c
Examining data/mahimahi-0.98/src/frontend/onoffshell.cc
Examining data/mahimahi-0.98/src/frontend/recordshell.cc
Examining data/mahimahi-0.98/src/frontend/replayserver.cc
Examining data/mahimahi-0.98/src/frontend/replayserver_filename.cc
Examining data/mahimahi-0.98/src/frontend/replayshell.cc
Examining data/mahimahi-0.98/src/frontend/web_server.cc
Examining data/mahimahi-0.98/src/graphing/binned_livegraph.cc
Examining data/mahimahi-0.98/src/graphing/cairo_objects.cc
Examining data/mahimahi-0.98/src/graphing/display.cc
Examining data/mahimahi-0.98/src/graphing/graph.cc
Examining data/mahimahi-0.98/src/http/backing_store.cc
Examining data/mahimahi-0.98/src/http/chunked_parser.cc
Examining data/mahimahi-0.98/src/http/http_header.cc
Examining data/mahimahi-0.98/src/http/http_message.cc
Examining data/mahimahi-0.98/src/http/http_request.cc
Examining data/mahimahi-0.98/src/http/http_response.cc
Examining data/mahimahi-0.98/src/http/http_response_parser.cc
Examining data/mahimahi-0.98/src/http/mime_type.cc
Examining data/mahimahi-0.98/src/httpserver/http_proxy.cc
Examining data/mahimahi-0.98/src/httpserver/secure_socket.cc
Examining data/mahimahi-0.98/src/packet/codel_packet_queue.cc
Examining data/mahimahi-0.98/src/packet/dropping_packet_queue.cc
Examining data/mahimahi-0.98/src/packet/packetshell.cc
Examining data/mahimahi-0.98/src/packet/pie_packet_queue.cc
Examining data/mahimahi-0.98/src/util/address.cc
Examining data/mahimahi-0.98/src/util/bytestream_queue.cc
Examining data/mahimahi-0.98/src/util/child_process.cc
Examining data/mahimahi-0.98/src/util/dns_proxy.cc
Examining data/mahimahi-0.98/src/util/dns_server.cc
Examining data/mahimahi-0.98/src/util/event_loop.cc
Examining data/mahimahi-0.98/src/util/ezio.cc
Examining data/mahimahi-0.98/src/util/file_descriptor.cc
Examining data/mahimahi-0.98/src/util/interfaces.cc
Examining data/mahimahi-0.98/src/util/nat.cc
Examining data/mahimahi-0.98/src/util/poller.cc
Examining data/mahimahi-0.98/src/util/signalfd.cc
Examining data/mahimahi-0.98/src/util/socket.cc
Examining data/mahimahi-0.98/src/util/socketpair.cc
Examining data/mahimahi-0.98/src/util/system_runner.cc
Examining data/mahimahi-0.98/src/util/temp_file.cc
Examining data/mahimahi-0.98/src/util/timestamp.cc
Examining data/mahimahi-0.98/src/util/util.cc
Examining data/mahimahi-0.98/src/util/netdevice.cc

FINAL RESULTS:

data/mahimahi-0.98/src/frontend/mod_deepcgi.c:99:16:  [4] (shell) popen:
  This causes a new program to execute and is difficult to use safely
  (CWE-78). try using a library call that implements the same functionality
  if available.
    FILE* fp = popen( replayserver_filename, "r" );
data/mahimahi-0.98/src/frontend/link_queue.cc:78:31:  [3] (buffer) getenv:
  Environment variables are untrustable input if they can be set by an
  attacker. They can have any content and length, and the same variable can
  be set more than once (CWE-807, CWE-20). Check environment variables
  carefully before using them.
        const char * prefix = getenv( "MAHIMAHI_SHELL_PREFIX" );
data/mahimahi-0.98/src/frontend/linkshell.cc:113:29:  [3] (buffer) getopt_long:
  Some older implementations do not protect against internal buffer overflows
  (CWE-120, CWE-20). Check implementation on installation, or limit the size
  of all string inputs.
            const int opt = getopt_long( argc, argv, "u:d:", command_line_options, nullptr );
data/mahimahi-0.98/src/frontend/meter.cc:33:29:  [3] (buffer) getopt_long:
  Some older implementations do not protect against internal buffer overflows
  (CWE-120, CWE-20). Check implementation on installation, or limit the size
  of all string inputs.
            const int opt = getopt_long( argc, argv, "ud", command_line_options, nullptr );
data/mahimahi-0.98/src/frontend/replayserver.cc:24:32:  [3] (buffer) getenv:
  Environment variables are untrustable input if they can be set by an
  attacker. They can have any content and length, and the same variable can
  be set more than once (CWE-807, CWE-20). Check environment variables
  carefully before using them.
    const char * const value = getenv( key.c_str() );
data/mahimahi-0.98/src/frontend/replayserver.cc:36:36:  [3] (buffer) getenv:
  Environment variables are untrustable input if they can be set by an
  attacker. They can have any content and length, and the same variable can
  be set more than once (CWE-807, CWE-20). Check environment variables
  carefully before using them.
    const char * const env_value = getenv( env_var_name.c_str() );
data/mahimahi-0.98/src/frontend/replayserver.cc:114:31:  [3] (buffer) getenv:
  Environment variables are untrustable input if they can be set by an
  attacker. They can have any content and length, and the same variable can
  be set more than once (CWE-807, CWE-20). Check environment variables
  carefully before using them.
        const bool is_https = getenv( "HTTPS" );
data/mahimahi-0.98/src/frontend/replayshell.cc:85:9:  [3] (random) srandom:
  This function is not sufficiently random for security-related functions
  such as key and nonce creation (CWE-327). Use a more secure technique for
  acquiring random values.
        srandom( time( NULL ) );
data/mahimahi-0.98/src/frontend/web_server.cc:31:107:  [3] (random) random:
  This function is not sufficiently random for security-related functions
  such as key and nonce creation (CWE-327). Use a more secure technique for
  acquiring random values.
    config_file_.write( "PidFile /tmp/replayshell_apache_pid." + to_string( getpid() ) + "." + to_string( random() ) + "\n" );
data/mahimahi-0.98/src/packet/packetshell.cc:221:40:  [3] (buffer) getenv:
  Environment variables are untrustable input if they can be set by an
  attacker. They can have any content and length, and the same variable can
  be set more than once (CWE-807, CWE-20). Check environment variables
  carefully before using them.
    const char * const mahimahi_base = getenv( "MAHIMAHI_BASE" );
data/mahimahi-0.98/src/packet/pie_packet_queue.cc:72:8:  [3] (random) random:
  This function is not sufficiently random for security-related functions
  such as key and nonce creation (CWE-327). Use a more secure technique for
  acquiring random values.
  if ( random < drop_prob_ ) {
data/mahimahi-0.98/src/util/util.cc:133:26:  [3] (buffer) getenv:
  Environment variables are untrustable input if they can be set by an
  attacker. They can have any content and length, and the same variable can
  be set more than once (CWE-807, CWE-20). Check environment variables
  carefully before using them.
    const char *prefix = getenv( "MAHIMAHI_SHELL_PREFIX" );
data/mahimahi-0.98/src/frontend/mod_deepcgi.c:105:5:  [2] (buffer) char:
  Statically-sized arrays can be improperly restricted, leading to potential
  overflows or other issues (CWE-119!/CWE-120). Perform bounds checking, use
  functions that limit length, or ensure that the size is larger than the
  maximum possible length.
    char line[HUGE_STRING_LEN];
data/mahimahi-0.98/src/frontend/replayserver.cc:124:52:  [2] (misc) open:
  Check when opening files - can an attacker redirect it (via symlinks),
  force the opening of special file type (e.g., device files), move things
  around to create a race condition, control its ancestors, or change its
  contents? (CWE-362).
            FileDescriptor fd( SystemCall( "open", open( filename.c_str(), O_RDONLY ) ) );
data/mahimahi-0.98/src/frontend/replayshell.cc:99:56:  [2] (misc) open:
  Check when opening files - can an attacker redirect it (via symlinks),
  force the opening of special file type (e.g., device files), move things
  around to create a race condition, control its ancestors, or change its
  contents? (CWE-362).
                FileDescriptor fd( SystemCall( "open", open( filename.c_str(), O_RDONLY ) ) );
data/mahimahi-0.98/src/httpserver/secure_socket.cc:152:5:  [2] (buffer) char:
  Statically-sized arrays can be improperly restricted, leading to potential
  overflows or other issues (CWE-119!/CWE-120). Perform bounds checking, use
  functions that limit length, or ensure that the size is larger than the
  maximum possible length.
    char buffer[ SSL_max_record_length ];
data/mahimahi-0.98/src/util/address.cc:37:5:  [2] (buffer) memcpy:
  Does not check for buffer overflows when copying to destination (CWE-120).
  Make sure destination can always hold the source data.
    memcpy( &addr_, &addr, size_ );
data/mahimahi-0.98/src/util/address.cc:46:5:  [2] (buffer) memcpy:
  Does not check for buffer overflows when copying to destination (CWE-120).
  Make sure destination can always hold the source data.
    memcpy( &addr_, &addr, size_ );
data/mahimahi-0.98/src/util/address.cc:122:5:  [2] (buffer) char:
  Statically-sized arrays can be improperly restricted, leading to potential
  overflows or other issues (CWE-119!/CWE-120). Perform bounds checking, use
  functions that limit length, or ensure that the size is larger than the
  maximum possible length.
    char ip[ NI_MAXHOST ], port[ NI_MAXSERV ];
data/mahimahi-0.98/src/util/bytestream_queue.cc:52:5:  [2] (buffer) memcpy:
  Does not check for buffer overflows when copying to destination (CWE-120).
  Make sure destination can always hold the source data.
    memcpy( &buffer_.at( next_byte_to_push ), new_chunk.data(), new_chunk.size() );
data/mahimahi-0.98/src/util/file_descriptor.cc:73:5:  [2] (buffer) char:
  Statically-sized arrays can be improperly restricted, leading to potential
  overflows or other issues (CWE-119!/CWE-120). Perform bounds checking, use
  functions that limit length, or ensure that the size is larger than the
  maximum possible length.
    char buffer[ BUFFER_SIZE ];
data/mahimahi-0.98/src/util/interfaces.cc:52:40:  [2] (misc) open:
  Check when opening files - can an attacker redirect it (via symlinks),
  force the opening of special file type (e.g., device files), move things
  around to create a race condition, control its ancestors, or change its
  contents? (CWE-362).
                                       open( "/proc/net/route", O_RDONLY ) ) );
data/mahimahi-0.98/src/util/netdevice.cc:24:56:  [2] (misc) open:
  Check when opening files - can an attacker redirect it (via symlinks),
  force the opening of special file type (e.g., device files), move things
  around to create a race condition, control its ancestors, or change its
  contents? (CWE-362).
    : FileDescriptor( SystemCall( "open /dev/net/tun", open( "/dev/net/tun", O_RDWR ) ) )
data/mahimahi-0.98/src/util/signalfd.cc:67:5:  [2] (buffer) memcpy:
  Does not check for buffer overflows when copying to destination (CWE-120).
  Make sure destination can always hold the source data.
    memcpy( &delivered_signal, delivered_signal_str.data(), sizeof( signalfd_siginfo ) );
data/mahimahi-0.98/src/util/socket.cc:161:5:  [2] (buffer) char:
  Statically-sized arrays can be improperly restricted, leading to potential
  overflows or other issues (CWE-119!/CWE-120). Perform bounds checking, use
  functions that limit length, or ensure that the size is larger than the
  maximum possible length.
    char buffer[ RECEIVE_MTU ];
data/mahimahi-0.98/src/util/socketpair.cc:25:5:  [2] (buffer) char:
  Statically-sized arrays can be improperly restricted, leading to potential
  overflows or other issues (CWE-119!/CWE-120). Perform bounds checking, use
  functions that limit length, or ensure that the size is larger than the
  maximum possible length.
    char control_buffer[ CMSG_SPACE( sizeof( fd.fd_num() ) ) ];
data/mahimahi-0.98/src/util/socketpair.cc:48:5:  [2] (buffer) char:
  Statically-sized arrays can be improperly restricted, leading to potential
  overflows or other issues (CWE-119!/CWE-120). Perform bounds checking, use
  functions that limit length, or ensure that the size is larger than the
  maximum possible length.
    char control_buffer[ CMSG_SPACE( sizeof( int ) ) ];
data/mahimahi-0.98/src/util/temp_file.cc:26:35:  [2] (tmpfile) mkstemp:
  Potential for temporary file vulnerability in some circumstances. Some
  older Unix-like systems create temp files with permission to write by all
  by default, so be sure to set the umask to override this. Also, some older
  Unix systems might fail to use O_EXCL when opening the file, so make sure
  that O_EXCL is used by the library (CWE-377).
      fd_( SystemCall( "mkstemp", mkstemp( &mutable_temp_filename_[ 0 ] ) ) ),
data/mahimahi-0.98/src/util/util.cc:75:51:  [2] (misc) open:
  Check when opening files - can an attacker redirect it (via symlinks),
  force the opening of special file type (e.g., device files), move things
  around to create a race condition, control its ancestors, or change its
  contents? (CWE-362).
    FileDescriptor( SystemCall( "open /dev/null", open( "/dev/null", O_RDONLY ) ) );
data/mahimahi-0.98/src/util/util.cc:93:37:  [2] (misc) open:
  Check when opening files - can an attacker redirect it (via symlinks),
  force the opening of special file type (e.g., device files), move things
  around to create a race condition, control its ancestors, or change its
  contents? (CWE-362).
                                    open( "/proc/sys/net/ipv4/ip_forward", O_RDONLY ) ) );
data/mahimahi-0.98/src/frontend/recordshell.cc:92:33:  [1] (buffer) read:
  Check buffer boundaries if used in a loop including recursive loops
  (CWE-120, CWE-20).
                    pipe.second.read();
data/mahimahi-0.98/src/http/chunked_parser.cc:34:38:  [1] (buffer) read:
  Check buffer boundaries if used in a loop including recursive loops
  (CWE-120, CWE-20).
string::size_type ChunkedBodyParser::read( const std::string & input_buffer )
data/mahimahi-0.98/src/http/http_response.cc:73:40:  [1] (buffer) read:
  Check buffer boundaries if used in a loop including recursive loops
  (CWE-120, CWE-20).
    auto amount_parsed = body_parser_->read( str );
data/mahimahi-0.98/src/httpserver/http_proxy.cc:50:67:  [1] (buffer) read:
  Check buffer boundaries if used in a loop including recursive loops
  (CWE-120, CWE-20).
                                           string buffer = server.read();
data/mahimahi-0.98/src/httpserver/http_proxy.cc:59:67:  [1] (buffer) read:
  Check buffer boundaries if used in a loop including recursive loops
  (CWE-120, CWE-20).
                                           string buffer = client.read();
data/mahimahi-0.98/src/httpserver/secure_socket.cc:147:22:  [1] (buffer) read:
  Check buffer boundaries if used in a loop including recursive loops
  (CWE-120, CWE-20).
string SecureSocket::read( void )
data/mahimahi-0.98/src/packet/packetshell.cc:175:64:  [1] (buffer) read:
  Check buffer boundaries if used in a loop including recursive loops
  (CWE-120, CWE-20).
                                  ferry_queue.read_packet( tun.read() );
data/mahimahi-0.98/src/util/bytestream_queue.cc:46:27:  [1] (buffer) read:
  Check buffer boundaries if used in a loop including recursive loops
  (CWE-120, CWE-20).
    string new_chunk = fd.read( contiguous_space_to_push );
data/mahimahi-0.98/src/util/dns_proxy.cc:63:89:  [1] (buffer) read:
  Check buffer boundaries if used in a loop including recursive loops
  (CWE-120, CWE-20).
                                                                             dns_server.read() );
data/mahimahi-0.98/src/util/file_descriptor.cc:71:24:  [1] (buffer) read:
  Check buffer boundaries if used in a loop including recursive loops
  (CWE-120, CWE-20).
string FileDescriptor::read( const size_t limit )
data/mahimahi-0.98/src/util/file_descriptor.cc:75:48:  [1] (buffer) read:
  Check buffer boundaries if used in a loop including recursive loops
  (CWE-120, CWE-20).
    ssize_t bytes_read = SystemCall( "read", ::read( fd_, buffer, min( BUFFER_SIZE, limit ) ) );
data/mahimahi-0.98/src/util/interfaces.cc:57:35:  [1] (buffer) read:
  Check buffer boundaries if used in a loop including recursive loops
  (CWE-120, CWE-20).
        string new_chunk = routes.read();
data/mahimahi-0.98/src/util/netdevice.cc:38:5:  [1] (buffer) strncpy:
  Easily used incorrectly; doesn't always \0-terminate or check for invalid
  pointers [MS-banned] (CWE-120).
    strncpy( ifr.ifr_name, name.c_str(), IFNAMSIZ -1 ); /* interface name */
data/mahimahi-0.98/src/util/signalfd.cc:61:39:  [1] (buffer) read:
  Check buffer boundaries if used in a loop including recursive loops
  (CWE-120, CWE-20).
    string delivered_signal_str = fd_.read( sizeof( signalfd_siginfo ) );
data/mahimahi-0.98/src/util/util.cc:94:14:  [1] (buffer) read:
  Check buffer boundaries if used in a loop including recursive loops
  (CWE-120, CWE-20).
    if ( ipf.read() != "1\n" ) {

ANALYSIS SUMMARY:

Hits = 45
Lines analyzed = 6099 in approximately 0.17 seconds (36778 lines/second)
Physical Source Lines of Code (SLOC) = 4493
Hits@level = [0]   6 [1]  15 [2]  18 [3]  11 [4]   1 [5]   0
Hits@level+ = [0+]  51 [1+]  45 [2+]  30 [3+]  12 [4+]   1 [5+]   0
Hits/KSLOC@level+ = [0+] 11.351 [1+] 10.0156 [2+] 6.67705 [3+] 2.67082 [4+] 0.222568 [5+]   0
Dot directories skipped = 1 (--followdotdir overrides)
Minimum risk level = 1
Not every hit is necessarily a security vulnerability.
There may be other security vulnerabilities; review your code!
See 'Secure Programming HOWTO'
(https://dwheeler.com/secure-programs) for more information.