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/olpc-kbdshim-27/arm-cross/libudev.h
Examining data/olpc-kbdshim-27/common.c
Examining data/olpc-kbdshim-27/common.h
Examining data/olpc-kbdshim-27/olpc-kbdshim-hal.c
Examining data/olpc-kbdshim-27/olpc-kbdshim-udev.c
Examining data/olpc-kbdshim-27/olpc-kbdshim.c

FINAL RESULTS:

data/olpc-kbdshim-27/common.c:1382:9:  [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(fifo_node, fifomode)) {
data/olpc-kbdshim-27/common.c:287:5:  [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, fmt, ap);
data/olpc-kbdshim-27/common.c:303:5:  [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, fmt, ap);
data/olpc-kbdshim-27/common.c:320:5:  [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, fmt, ap);
data/olpc-kbdshim-27/common.c:654:43:  [4] (race) access:
  This usually indicates a security flaw. If an attacker can change anything
  along the path between the call to access() and the file's actual use
  (e.g., by moving files), the attacker can exploit the race condition
  (CWE-362/CWE-367!). Set up the correct permissions (e.g., using setuid())
  and try to open the file directly.
                if (*rotate_cmd != '/' || access(rotate_cmd, X_OK) == 0) {
data/olpc-kbdshim-27/common.c:656:25:  [4] (shell) system:
  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.
                    if (system(rotate_cmd) == 0)
data/olpc-kbdshim-27/common.c:686:29:  [4] (race) access:
  This usually indicates a security flaw. If an attacker can change anything
  along the path between the call to access() and the file's actual use
  (e.g., by moving files), the attacker can exploit the race condition
  (CWE-362/CWE-367!). Set up the correct permissions (e.g., using setuid())
  and try to open the file directly.
                            access(brightness_cmd, X_OK) == 0) {
data/olpc-kbdshim-27/common.c:697:29:  [4] (shell) system:
  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.
                        if (system(cmd) == 0)
data/olpc-kbdshim-27/common.c:728:29:  [4] (race) access:
  This usually indicates a security flaw. If an attacker can change anything
  along the path between the call to access() and the file's actual use
  (e.g., by moving files), the attacker can exploit the race condition
  (CWE-362/CWE-367!). Set up the correct permissions (e.g., using setuid())
  and try to open the file directly.
                            access(volume_cmd, X_OK) == 0) {
data/olpc-kbdshim-27/common.c:737:29:  [4] (shell) system:
  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.
                        if (system(cmd) == 0)
data/olpc-kbdshim-27/common.c:1548:13:  [4] (shell) system:
  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.
        if (system("/sbin/modprobe uinput") == 0)
data/olpc-kbdshim-27/common.c:1429:17:  [3] (buffer) getopt:
  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.
    while ((c = getopt(argc, argv, "flsdXve:q:n:K:T:t:g:G:R:A:r:b:V:")) != -1) {
data/olpc-kbdshim-27/olpc-kbdshim-hal.c:418:24:  [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.
    if ((commandline = getenv ("SINGLETON_COMMAND_LINE")) == NULL) {
data/olpc-kbdshim-27/common.c:94:1:  [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 local_tpad_enabled[1024];
data/olpc-kbdshim-27/common.c:377:10:  [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).
    fd = open("/dev/input/uinput", O_WRONLY | O_NDELAY);
data/olpc-kbdshim-27/common.c:379:14:  [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).
        fd = open("/dev/uinput", O_WRONLY | O_NDELAY);
data/olpc-kbdshim-27/common.c:397:9:  [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(uinp.absmax,  tscreen_max,  sizeof(tscreen_max));
data/olpc-kbdshim-27/common.c:398:9:  [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(uinp.absmin,  tscreen_min,  sizeof(tscreen_min));
data/olpc-kbdshim-27/common.c:399:9:  [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(uinp.absfuzz, tscreen_fuzz, sizeof(tscreen_fuzz));
data/olpc-kbdshim-27/common.c:400:9:  [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(uinp.absflat, tscreen_flat, sizeof(tscreen_flat));
data/olpc-kbdshim-27/common.c:677: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 cmd[256];
data/olpc-kbdshim-27/common.c:719: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 cmd[256];
data/olpc-kbdshim-27/common.c:1061: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(&(queue[queue_pos]), ev, sizeof(*ev));
data/olpc-kbdshim-27/common.c:1242:18:  [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).
            fd = open(local_tpad_enabled, O_RDWR|O_NONBLOCK);
data/olpc-kbdshim-27/common.c:1340: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 evtbuf[128];
data/olpc-kbdshim-27/common.c:1342:10:  [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).
    fd = open(sysactive_path, O_RDWR|O_NONBLOCK);
data/olpc-kbdshim-27/common.c:1388:10:  [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).
    fd = open(fifo_node, O_RDWR);
data/olpc-kbdshim-27/common.c:1495:27:  [2] (integer) atoi:
  Unless checked, the resulting number can exceed the expected range
  (CWE-190). If source untrusted, check both minimum and maximum, even if the
  input had no minus sign (large numbers can roll over into negative number;
  consider saving to an unsigned value if that is intended).
            watch_ebook = atoi(optarg);
data/olpc-kbdshim-27/common.h:36:8:  [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.
extern char local_tpad_enabled[1024];
data/olpc-kbdshim-27/olpc-kbdshim-hal.c:254:19:  [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).
        eventfp = open(device_file, O_RDONLY | O_NONBLOCK);
data/olpc-kbdshim-27/olpc-kbdshim-udev.c:52:8:  [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.
static char *fd_paths[FD_SETSIZE];
data/olpc-kbdshim-27/olpc-kbdshim-udev.c:95:14:  [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 bit[bits2bytes(EV_MAX)];
data/olpc-kbdshim-27/olpc-kbdshim-udev.c:104:16:  [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).
    if ((dfd = open(path, O_RDONLY)) < 0) {
data/olpc-kbdshim-27/olpc-kbdshim-udev.c:167:18:  [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 swbit[bits2bytes(EV_MAX)];
data/olpc-kbdshim-27/olpc-kbdshim-udev.c:225:18:  [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 keybit[bits2bytes(KEY_MAX)];
data/olpc-kbdshim-27/olpc-kbdshim-udev.c:516: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 command[128];
data/olpc-kbdshim-27/olpc-kbdshim.c:62: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 devname[128];
data/olpc-kbdshim-27/olpc-kbdshim.c:63:14:  [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 bit[bits2bytes(EV_MAX)];
data/olpc-kbdshim-27/olpc-kbdshim.c:69: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).
        if ((dfd = open(devname, O_RDONLY)) < 0)
data/olpc-kbdshim-27/olpc-kbdshim.c:172: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 command[128];
data/olpc-kbdshim-27/common.c:395:9:  [1] (buffer) strncpy:
  Easily used incorrectly; doesn't always \0-terminate or check for invalid
  pointers [MS-banned] (CWE-120). Risk is low because the source is a
  constant string.
        strncpy(uinp.name, "olpc-kbdshim virtual touchscreen", UINPUT_MAX_NAME_SIZE);
data/olpc-kbdshim-27/common.c:430:9:  [1] (buffer) strncpy:
  Easily used incorrectly; doesn't always \0-terminate or check for invalid
  pointers [MS-banned] (CWE-120). Risk is low because the source is a
  constant string.
        strncpy(uinp.name, "olpc-kbdshim virtual input", UINPUT_MAX_NAME_SIZE);
data/olpc-kbdshim-27/common.c:1479:13:  [1] (buffer) strncpy:
  Easily used incorrectly; doesn't always \0-terminate or check for invalid
  pointers [MS-banned] (CWE-120).
            strncpy(local_tpad_enabled, optarg, sizeof(local_tpad_enabled));
data/olpc-kbdshim-27/olpc-kbdshim-udev.c:392:9:  [1] (buffer) read:
  Check buffer boundaries if used in a loop including recursive loops
  (CWE-120, CWE-20).
    if (read(kbd_fd, ev, sizeof(ev)) != sizeof(ev)) {
data/olpc-kbdshim-27/olpc-kbdshim-udev.c:408:9:  [1] (buffer) read:
  Check buffer boundaries if used in a loop including recursive loops
  (CWE-120, CWE-20).
    if (read(tpad_fd, ev, sizeof(ev)) != sizeof(ev)) {
data/olpc-kbdshim-27/olpc-kbdshim-udev.c:424:9:  [1] (buffer) read:
  Check buffer boundaries if used in a loop including recursive loops
  (CWE-120, CWE-20).
    if (read(tpad_fd, ev, sizeof(ev)) != sizeof(ev)) {
data/olpc-kbdshim-27/olpc-kbdshim-udev.c:440:9:  [1] (buffer) read:
  Check buffer boundaries if used in a loop including recursive loops
  (CWE-120, CWE-20).
    if (read(ebook_fd, ev, sizeof(ev)) != sizeof(ev)) {
data/olpc-kbdshim-27/olpc-kbdshim-udev.c:456:9:  [1] (buffer) read:
  Check buffer boundaries if used in a loop including recursive loops
  (CWE-120, CWE-20).
    if (read(oth_fd, ev, sizeof(ev)) != sizeof(ev)) {
data/olpc-kbdshim-27/olpc-kbdshim-udev.c:473:9:  [1] (buffer) read:
  Check buffer boundaries if used in a loop including recursive loops
  (CWE-120, CWE-20).
    if (read(tscrn_fd, ev, sizeof(ev)) != sizeof(ev)) {
data/olpc-kbdshim-27/olpc-kbdshim-udev.c:519:9:  [1] (buffer) read:
  Check buffer boundaries if used in a loop including recursive loops
  (CWE-120, CWE-20).
    n = read(fifo_fd, command, sizeof(command)-1);
data/olpc-kbdshim-27/olpc-kbdshim.c:123:9:  [1] (buffer) read:
  Check buffer boundaries if used in a loop including recursive loops
  (CWE-120, CWE-20).
    if (read(kbd_fd, ev, sizeof(ev)) != sizeof(ev))
data/olpc-kbdshim-27/olpc-kbdshim.c:133:9:  [1] (buffer) read:
  Check buffer boundaries if used in a loop including recursive loops
  (CWE-120, CWE-20).
    if (read(tpad_fd, ev, sizeof(ev)) != sizeof(ev))
data/olpc-kbdshim-27/olpc-kbdshim.c:173:9:  [1] (buffer) read:
  Check buffer boundaries if used in a loop including recursive loops
  (CWE-120, CWE-20).
    n = read(fifo_fd, command, sizeof(command)-1);

ANALYSIS SUMMARY:

Hits = 53
Lines analyzed = 3209 in approximately 0.09 seconds (34057 lines/second)
Physical Source Lines of Code (SLOC) = 2388
Hits@level = [0]  15 [1]  13 [2]  27 [3]   2 [4]  10 [5]   1
Hits@level+ = [0+]  68 [1+]  53 [2+]  40 [3+]  13 [4+]  11 [5+]   1
Hits/KSLOC@level+ = [0+] 28.4757 [1+] 22.1943 [2+] 16.7504 [3+] 5.44389 [4+] 4.60637 [5+] 0.41876
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.