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/bit-babbler-0.8/include/bit-babbler/aligned_recast.h
Examining data/bit-babbler-0.8/include/bit-babbler/chisq.h
Examining data/bit-babbler-0.8/include/bit-babbler/client-socket.h
Examining data/bit-babbler-0.8/include/bit-babbler/control-socket.h
Examining data/bit-babbler-0.8/include/bit-babbler/exceptions.h
Examining data/bit-babbler-0.8/include/bit-babbler/ftdi-device.h
Examining data/bit-babbler-0.8/include/bit-babbler/health-monitor.h
Examining data/bit-babbler-0.8/include/bit-babbler/impl/health-monitor.h
Examining data/bit-babbler-0.8/include/bit-babbler/impl/log.h
Examining data/bit-babbler-0.8/include/bit-babbler/iniparser.h
Examining data/bit-babbler-0.8/include/bit-babbler/json.h
Examining data/bit-babbler-0.8/include/bit-babbler/log.h
Examining data/bit-babbler-0.8/include/bit-babbler/math.h
Examining data/bit-babbler-0.8/include/bit-babbler/qa.h
Examining data/bit-babbler-0.8/include/bit-babbler/refptr.h
Examining data/bit-babbler-0.8/include/bit-babbler/secret-sink.h
Examining data/bit-babbler-0.8/include/bit-babbler/secret-source.h
Examining data/bit-babbler-0.8/include/bit-babbler/signals.h
Examining data/bit-babbler-0.8/include/bit-babbler/socket-source.h
Examining data/bit-babbler-0.8/include/bit-babbler/socket.h
Examining data/bit-babbler-0.8/include/bit-babbler/term_escape.h
Examining data/bit-babbler-0.8/include/bit-babbler/unicode.h
Examining data/bit-babbler-0.8/include/bit-babbler/unordered_map.h
Examining data/bit-babbler-0.8/include/bit-babbler/usbcontext.h
Examining data/bit-babbler-0.8/include/bit-babbler/users.h
Examining data/bit-babbler-0.8/src/bbcheck.cpp
Examining data/bit-babbler-0.8/src/bbctl.cpp
Examining data/bit-babbler-0.8/src/seedd.cpp

FINAL RESULTS:

data/bit-babbler-0.8/include/bit-babbler/control-socket.h:627:17:  [5] (race) chmod:
  This accepts filename arguments; if an attacker can move those files, a
  race condition results. (CWE-362). Use fchmod( ) instead.
            if( chmod( dir.c_str(), dirmode ) )
data/bit-babbler-0.8/include/bit-babbler/control-socket.h:631:34:  [5] (race) chown:
  This accepts filename arguments; if an attacker can move those files, a
  race condition results. (CWE-362). Use fchown( ) instead.
            if( using_group() && chown( dir.c_str(), uid_t(-1), m_gid ) )
data/bit-babbler-0.8/include/bit-babbler/control-socket.h:749:17:  [5] (race) chmod:
  This accepts filename arguments; if an attacker can move those files, a
  race condition results. (CWE-362). Use fchmod( ) instead.
            if( chmod( path.c_str(), sockmode ) )
data/bit-babbler-0.8/include/bit-babbler/control-socket.h:753:34:  [5] (race) chown:
  This accepts filename arguments; if an attacker can move those files, a
  race condition results. (CWE-362). Use fchown( ) instead.
            if( using_group() && chown( path.c_str(), uid_t(-1), m_gid ) )
data/bit-babbler-0.8/include/bit-babbler/impl/log.h:31:25:  [4] (format) snprintf:
  If format strings can be influenced by an attacker, they can be exploited,
  and note that sprintf variations do not always \0-terminate (CWE-134). Use
  a constant for the format specification.
            int     n = snprintf(b, sizeof(b), short_form ? " %02x" : " 0x%02x", octets[i]);
data/bit-babbler-0.8/include/bit-babbler/impl/log.h:451:15:  [4] (format) syslog:
  If syslog's format strings can be influenced by an attacker, they can be
  exploited (CWE-134). Use a constant format string for syslog.
BB_CONST void syslog(int priority, const char *format, ...)
data/bit-babbler-0.8/include/bit-babbler/iniparser.h:47:26:  [4] (format) fprintf:
  If format strings can be influenced by an attacker, they can be exploited
  (CWE-134). Use a constant for the format specification.
 #define debug_inip(...) fprintf(BB_DEBUG_INI_LOGSTREAM, ##__VA_ARGS__);
data/bit-babbler-0.8/include/bit-babbler/iniparser.h:54:26:  [4] (format) fprintf:
  If format strings can be influenced by an attacker, they can be exploited
  (CWE-134). Use a constant for the format specification.
 #define debug_iniv(...) fprintf(BB_DEBUG_INI_LOGSTREAM, ##__VA_ARGS__);
data/bit-babbler-0.8/include/bit-babbler/log.h:40:10:  [4] (format) syslog:
  If syslog's format strings can be influenced by an attacker, they can be
  exploited (CWE-134). Use a constant format string for syslog.
    void syslog(int priority, const char *format, ...);
data/bit-babbler-0.8/include/bit-babbler/log.h:395:17:  [4] (format) vfprintf:
  If format strings can be influenced by an attacker, they can be exploited
  (CWE-134). Use a constant for the format specification.
                vfprintf( stderr, format, arglist );
data/bit-babbler-0.8/include/bit-babbler/usbcontext.h:1779:13:  [4] (format) printf:
  If format strings can be influenced by an attacker, they can be exploited
  (CWE-134). Use a constant for the format specification.
            printf( P_("Have %zu device:\n",
data/bit-babbler-0.8/src/bbcheck.cpp:333:17:  [4] (format) printf:
  If format strings can be influenced by an attacker, they can be exploited
  (CWE-134). Use a constant for the format specification.
                printf( CYAN_IF("\n%s %u Hz\n"), m_id.c_str(), bbo.bitrate );
data/bit-babbler-0.8/src/bbcheck.cpp:336:17:  [4] (format) printf:
  If format strings can be influenced by an attacker, they can be exploited
  (CWE-134). Use a constant for the format specification.
                printf( CYAN_IF("\n%s %u Hz, generator %u\n"), m_id.c_str(),
data/bit-babbler-0.8/src/bbcheck.cpp:339:17:  [4] (format) printf:
  If format strings can be influenced by an attacker, they can be exploited
  (CWE-134). Use a constant for the format specification.
                printf( CYAN_IF("\n%s %u Hz, generator mask 0x%02x\n"),
data/bit-babbler-0.8/src/bbctl.cpp:306:13:  [4] (format) printf:
  If format strings can be influenced by an attacker, they can be exploited
  (CWE-134). Use a constant for the format specification.
            printf( P_("Have %zu active device:\n",
data/bit-babbler-0.8/include/bit-babbler/socket.h:311:20:  [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.
        char  *s = getenv("NOTIFY_SOCKET");
data/bit-babbler-0.8/src/bbcheck.cpp:578:17:  [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.
        int c = getopt_long( argc, argv, ":si:r:b:B:f:Av?",
data/bit-babbler-0.8/src/bbctl.cpp:175:17:  [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.
        int c = getopt_long( argc, argv, ":si:c:bBrSV:v?",
data/bit-babbler-0.8/src/seedd.cpp:797:17:  [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.
        int c = getopt_long( argc, argv, ":sC:i:r:f:g:b:dku:oP:G:c:v?",
data/bit-babbler-0.8/include/bit-babbler/client-socket.h:103:29:  [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( buf, m_buf, len + 1 );
data/bit-babbler-0.8/include/bit-babbler/control-socket.h:169:17:  [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        buf[1024];
data/bit-babbler-0.8/include/bit-babbler/control-socket.h:647:24:  [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).
            m_lockfd = open( lockfile.c_str(), O_RDWR|O_CREAT, mode );
data/bit-babbler-0.8/include/bit-babbler/ftdi-device.h:563:21:  [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( buf, m_chunkbuf + m_chunkhead, n );
data/bit-babbler-0.8/include/bit-babbler/health-monitor.h:252:17:  [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( m_fipsbuf + m_fipsextra, buf, n );
data/bit-babbler-0.8/include/bit-babbler/health-monitor.h:279:17:  [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( m_fipsbuf, buf, len );
data/bit-babbler-0.8/include/bit-babbler/impl/log.h:27:9:  [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            b[6];
data/bit-babbler-0.8/include/bit-babbler/impl/log.h:315:13:  [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    buf[ size + 1 ];
data/bit-babbler-0.8/include/bit-babbler/impl/log.h:342:17:  [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    usec[ 7 ];
data/bit-babbler-0.8/include/bit-babbler/secret-sink.h:176:20:  [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).
            m_fd = open( m_options.devpath.c_str(), O_RDONLY );
data/bit-babbler-0.8/include/bit-babbler/secret-source.h:709:21:  [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( m_buf, b, len );
data/bit-babbler-0.8/include/bit-babbler/secret-source.h:726:21:  [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( buf, m_buf, m_size );
data/bit-babbler-0.8/include/bit-babbler/secret-source.h:873:17:  [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( m_buf + m_fill, buf, b );
data/bit-babbler-0.8/include/bit-babbler/secret-source.h:1436:13:  [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( buf, m_buf + (m_fill - n), n );
data/bit-babbler-0.8/include/bit-babbler/secret-source.h:1535:22:  [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).
            int fd = open( dev.empty() ? m_opt.kernel_device.c_str() : dev.c_str(), O_RDWR );
data/bit-babbler-0.8/include/bit-babbler/secret-source.h:1576:21:  [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( b2 + b2_fill, buf, n );
data/bit-babbler-0.8/include/bit-babbler/socket-source.h:40:17:  [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        buf[8];
data/bit-babbler-0.8/include/bit-babbler/socket.h:125:13:  [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.any, addrinf->ai_addr, addr_len );
data/bit-babbler-0.8/include/bit-babbler/socket.h:144:9:  [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    m_errmsg[65536];
data/bit-babbler-0.8/include/bit-babbler/socket.h:205:9:  [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    errmsg[65536];
data/bit-babbler-0.8/include/bit-babbler/usbcontext.h:1058:26:  [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.
                unsigned char       s[128];
data/bit-babbler-0.8/include/bit-babbler/usbcontext.h:1175:38:  [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).
                int             fd = open( usbfs_path.c_str(), O_RDWR );
data/bit-babbler-0.8/src/seedd.cpp:372:9:  [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            buf[65536];
data/bit-babbler-0.8/src/seedd.cpp:375:29:  [2] (misc) fopen:
  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).
        FILE           *f = fopen( path, "r" );
data/bit-babbler-0.8/include/bit-babbler/client-socket.h:220:16:  [1] (buffer) read:
  Check buffer boundaries if used in a loop including recursive loops
  (CWE-120, CWE-20).
        size_t read( char *buf, size_t size )
data/bit-babbler-0.8/include/bit-babbler/ftdi-device.h:833:13:  [1] (obsolete) usleep:
  This C routine is considered obsolete (as opposed to the shell command by
  the same name). The interaction of this function with SIGALRM and other
  timer functions such as sleep(), alarm(), setitimer(), and nanosleep() is
  unspecified (CWE-676). Use nanosleep(2) or setitimer(2) instead.
            usleep(50000);
data/bit-babbler-0.8/include/bit-babbler/log.h:105:66:  [1] (buffer) strlen:
  Does not handle strings that are not \0-terminated; if given one it may
  perform an over-read (it could cause a crash if unprotected) (CWE-126).
    inline size_t stringlength( const char *s ) { return ( s ) ? strlen( s ) : 0; }
data/bit-babbler-0.8/include/bit-babbler/log.h:111:69:  [1] (buffer) wcslen:
  Does not handle strings that are not \0-terminated; if given one it may
  perform an over-read (it could cause a crash if unprotected) (CWE-126).
    inline size_t stringlength( const wchar_t *s ) { return ( s ) ? wcslen( s ) : 0; }
data/bit-babbler-0.8/include/bit-babbler/secret-sink.h:116:33:  [1] (buffer) read:
  Check buffer boundaries if used in a loop including recursive loops
  (CWE-120, CWE-20).
                    ssize_t r = read( m_fd, buf + n, m_options.block_size - n );
data/bit-babbler-0.8/include/bit-babbler/secret-sink.h:141:21:  [1] (obsolete) usleep:
  This C routine is considered obsolete (as opposed to the shell command by
  the same name). The interaction of this function with SIGALRM and other
  timer functions such as sleep(), alarm(), setitimer(), and nanosleep() is
  unspecified (CWE-676). Use nanosleep(2) or setitimer(2) instead.
                    usleep( useconds_t(m_options.block_delay * 1000) );
data/bit-babbler-0.8/include/bit-babbler/secret-source.h:122:17:  [1] (obsolete) usleep:
  This C routine is considered obsolete (as opposed to the shell command by
  the same name). The interaction of this function with SIGALRM and other
  timer functions such as sleep(), alarm(), setitimer(), and nanosleep() is
  unspecified (CWE-676). Use nanosleep(2) or setitimer(2) instead.
                usleep(30000);
data/bit-babbler-0.8/include/bit-babbler/secret-source.h:408:16:  [1] (buffer) read:
  Check buffer boundaries if used in a loop including recursive loops
  (CWE-120, CWE-20).
        size_t read( uint8_t *buf, size_t len )
data/bit-babbler-0.8/include/bit-babbler/secret-source.h:1012:41:  [1] (buffer) read:
  Check buffer boundaries if used in a loop including recursive loops
  (CWE-120, CWE-20).
                        n = s->babbler->read( s->buf + p, read_size );
data/bit-babbler-0.8/include/bit-babbler/secret-source.h:1424:16:  [1] (buffer) read:
  Check buffer boundaries if used in a loop including recursive loops
  (CWE-120, CWE-20).
        size_t read( uint8_t *buf, size_t len )
data/bit-babbler-0.8/include/bit-babbler/secret-source.h:1455:33:  [1] (buffer) read:
  Check buffer boundaries if used in a loop including recursive loops
  (CWE-120, CWE-20).
                size_t      n = read( buf, b );
data/bit-babbler-0.8/include/bit-babbler/secret-source.h:1566:25:  [1] (buffer) read:
  Check buffer boundaries if used in a loop including recursive loops
  (CWE-120, CWE-20).
                    n = read( buf, N );
data/bit-babbler-0.8/include/bit-babbler/secret-source.h:1613:17:  [1] (obsolete) usleep:
  This C routine is considered obsolete (as opposed to the shell command by
  the same name). The interaction of this function with SIGALRM and other
  timer functions such as sleep(), alarm(), setitimer(), and nanosleep() is
  unspecified (CWE-676). Use nanosleep(2) or setitimer(2) instead.
                usleep( timeout * 1000 );
data/bit-babbler-0.8/include/bit-babbler/socket-source.h:67:37:  [1] (buffer) read:
  Check buffer boundaries if used in a loop including recursive loops
  (CWE-120, CWE-20).
                        r = m_pool->read( rbuf, bytes );
data/bit-babbler-0.8/src/bbcheck.cpp:312:24:  [1] (buffer) read:
  Check buffer boundaries if used in a loop including recursive loops
  (CWE-120, CWE-20).
                r += b.read( m_buf + r, std::min( size_t(65536), rs - r ) );
data/bit-babbler-0.8/src/bbctl.cpp:368:13:  [1] (obsolete) usleep:
  This C routine is considered obsolete (as opposed to the shell command by
  the same name). The interaction of this function with SIGALRM and other
  timer functions such as sleep(), alarm(), setitimer(), and nanosleep() is
  unspecified (CWE-676). Use nanosleep(2) or setitimer(2) instead.
            usleep( useconds_t( w.retry_ms * 1000 ) );
data/bit-babbler-0.8/src/seedd.cpp:1021:9:  [1] (access) umask:
  Ensure that umask is given most restrictive possible setting (e.g., 066 or
  077) (CWE-732).
        umask( S_IWGRP | S_IROTH | S_IWOTH | S_IXOTH );

ANALYSIS SUMMARY:

Hits = 60
Lines analyzed = 19913 in approximately 0.38 seconds (52026 lines/second)
Physical Source Lines of Code (SLOC) = 11310
Hits@level = [0] 155 [1]  17 [2]  24 [3]   4 [4]  11 [5]   4
Hits@level+ = [0+] 215 [1+]  60 [2+]  43 [3+]  19 [4+]  15 [5+]   4
Hits/KSLOC@level+ = [0+] 19.0097 [1+] 5.30504 [2+] 3.80195 [3+] 1.67993 [4+] 1.32626 [5+] 0.353669
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.