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/xringd-1.20/ringsm.h Examining data/xringd-1.20/uartcount.c Examining data/xringd-1.20/ringsm.c Examining data/xringd-1.20/xringd.c FINAL RESULTS: data/xringd-1.20/xringd.c:142:6: [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 (access(config_file, R_OK) != 0) { data/xringd-1.20/xringd.c:274:2: [4] (format) vsprintf: Potential format string problem (CWE-134). Make format string constant. vsprintf(buf, fmt, p); data/xringd-1.20/xringd.c:278:4: [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. fprintf(stderr, PROG ": %s\n", buf); data/xringd-1.20/xringd.c:295:2: [4] (format) vsprintf: Potential format string problem (CWE-134). Make format string constant. vsprintf(buf, fmt, p); data/xringd-1.20/xringd.c:449:16: [4] (buffer) sprintf: Does not check for buffer overflows (CWE-120). Use sprintf_s, snprintf, or vsnprintf. (void) sprintf(pidfilename, "%s%s.pid", _PATH_VARRUN, PROG); data/xringd-1.20/xringd.c:531:3: [4] (shell) execl: 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. execl("/bin/sh", "sh", "-c", cmd, NULL); data/xringd-1.20/xringd.c:626:2: [4] (buffer) strcpy: Does not check for buffer overflows when copying to destination [MS-banned] (CWE-120). Consider using snprintf, strcpy_s, or strlcpy (warning: strncpy easily misused). strcpy(p, new); data/xringd-1.20/xringd.c:606: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 ( (opt = getopt(argc, argv, "a:c:dl:i:l:m:ent:h?")) != EOF ) data/xringd-1.20/ringsm.c:205:15: [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). *t1 = *t2 = atoi(start); data/xringd-1.20/ringsm.c:213:10: [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). *t2 = atoi(start); data/xringd-1.20/ringsm.c:231:2: [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[MAX_LINE_LEN], *p, *end; data/xringd-1.20/ringsm.c:297:6: [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). f = fopen(config_file, "r"); /* config_file MUST be readable */ data/xringd-1.20/uartcount.c:14:12: [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 ((fd = open(argc == 2 ? argv[1] : "/dev/modem", data/xringd-1.20/xringd.c:93: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 pidfilename[MAXPATHLEN] = "\0"; data/xringd-1.20/xringd.c:137: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. static char str_near[100]; data/xringd-1.20/xringd.c:173:3: [2] (buffer) sprintf: Does not check for buffer overflows (CWE-120). Use sprintf_s, snprintf, or vsnprintf. Risk is low because the source has a constant maximum length. sprintf(str_near, "; rings %ld msec or less apart ignored", msec_ignore); data/xringd-1.20/xringd.c:271:2: [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[MAXLINE]; data/xringd-1.20/xringd.c:292:2: [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[MAXLINE]; data/xringd-1.20/xringd.c:420:12: [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 ((fd = open(file, O_RDONLY | O_NOCTTY | O_NDELAY)) < 0) { data/xringd-1.20/xringd.c:450:21: [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). if ((pidf = fopen(pidfilename, "w")) != NULL) { data/xringd-1.20/xringd.c:520:12: [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). fdnull = open(_PATH_DEVNULL, O_RDWR); data/xringd-1.20/xringd.c:555:17: [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). msec_ignore = atoi(s); data/xringd-1.20/xringd.c:558:15: [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). log_level = atoi(s); data/xringd-1.20/xringd.c:570:19: [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). reset_timeout = atoi(s); data/xringd-1.20/ringsm.c:239:9: [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). len = strlen(line); data/xringd-1.20/xringd.c:423:4: [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(3*1000000); /* uses select - not SIGALRM */ data/xringd-1.20/xringd.c:475:2: [1] (access) umask: Ensure that umask is given most restrictive possible setting (e.g., 066 or 077) (CWE-732). umask(S_IRWXG | S_IRWXO); data/xringd-1.20/xringd.c:619:16: [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). int newsize = strlen(new) + 1; ANALYSIS SUMMARY: Hits = 28 Lines analyzed = 1163 in approximately 0.05 seconds (22966 lines/second) Physical Source Lines of Code (SLOC) = 866 Hits@level = [0] 8 [1] 4 [2] 16 [3] 1 [4] 7 [5] 0 Hits@level+ = [0+] 36 [1+] 28 [2+] 24 [3+] 8 [4+] 7 [5+] 0 Hits/KSLOC@level+ = [0+] 41.5704 [1+] 32.3326 [2+] 27.7136 [3+] 9.23788 [4+] 8.08314 [5+] 0 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.