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/chirp-20200227+py3+20200213/tools/serialsniff.c FINAL RESULTS: data/chirp-20200227+py3+20200213/tools/serialsniff.c:380:7: [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. c = getopt_long(argc, argv, "A:B:d:l:q", data/chirp-20200227+py3+20200213/tools/serialsniff.c:83: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 path[1024]; data/chirp-20200227+py3+20200213/tools/serialsniff.c:84: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 name[1024]; data/chirp-20200227+py3+20200213/tools/serialsniff.c:170:3: [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[4096]; data/chirp-20200227+py3+20200213/tools/serialsniff.c:257:13: [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). path->fd = open(serpath, O_RDWR); data/chirp-20200227+py3+20200213/tools/serialsniff.c:306:2: [2] (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). Risk is low because the source is a constant string. strcpy(path->path, "SOCKET"); data/chirp-20200227+py3+20200213/tools/serialsniff.c:323: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). path->rawlog_fd = open(filename, O_WRONLY | O_CREAT, 0644); data/chirp-20200227+py3+20200213/tools/serialsniff.c:420:14: [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). total_hex=atoi(optarg); data/chirp-20200227+py3+20200213/tools/serialsniff.c:153:9: [1] (buffer) read: Check buffer boundaries if used in a loop including recursive loops (CWE-120, CWE-20). ret = read(fd, &(buf[count]), len - count); data/chirp-20200227+py3+20200213/tools/serialsniff.c:245:2: [1] (buffer) strncpy: Easily used incorrectly; doesn't always \0-terminate or check for invalid pointers [MS-banned] (CWE-120). strncpy(path->path,ptsname_path,sizeof(path->path) - 1); data/chirp-20200227+py3+20200213/tools/serialsniff.c:261:2: [1] (buffer) strncpy: Easily used incorrectly; doesn't always \0-terminate or check for invalid pointers [MS-banned] (CWE-120). strncpy(path->path, serpath, sizeof(path->path)); data/chirp-20200227+py3+20200213/tools/serialsniff.c:359:2: [1] (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). Risk is low because the source is a constant character. strcpy(pathA.name, "A"); data/chirp-20200227+py3+20200213/tools/serialsniff.c:360:2: [1] (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). Risk is low because the source is a constant character. strcpy(pathB.name, "B"); data/chirp-20200227+py3+20200213/tools/serialsniff.c:408:4: [1] (buffer) strncpy: Easily used incorrectly; doesn't always \0-terminate or check for invalid pointers [MS-banned] (CWE-120). strncpy(pathA.name, optarg, sizeof(pathA.name)); data/chirp-20200227+py3+20200213/tools/serialsniff.c:412:4: [1] (buffer) strncpy: Easily used incorrectly; doesn't always \0-terminate or check for invalid pointers [MS-banned] (CWE-120). strncpy(pathB.name, optarg, sizeof(pathB.name)); ANALYSIS SUMMARY: Hits = 15 Lines analyzed = 440 in approximately 0.07 seconds (6368 lines/second) Physical Source Lines of Code (SLOC) = 296 Hits@level = [0] 21 [1] 7 [2] 7 [3] 1 [4] 0 [5] 0 Hits@level+ = [0+] 36 [1+] 15 [2+] 8 [3+] 1 [4+] 0 [5+] 0 Hits/KSLOC@level+ = [0+] 121.622 [1+] 50.6757 [2+] 27.027 [3+] 3.37838 [4+] 0 [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.