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/safelease-1.0.1/src/safelease.c FINAL RESULTS: data/safelease-1.0.1/src/safelease.c:70:9: [4] (format) vsprintf: Potential format string problem (CWE-134). Make format string constant. n = vsprintf(buf, msg, va); data/safelease-1.0.1/src/safelease.c:89:9: [4] (format) vsprintf: Potential format string problem (CWE-134). Make format string constant. n = vsprintf(buf, msg, va); data/safelease-1.0.1/src/safelease.c:421:9: [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(path, R_OK | W_OK) < 0) data/safelease-1.0.1/src/safelease.c:462:19: [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, "+hdr:bo:")) != -1) { data/safelease-1.0.1/src/safelease.c:521:19: [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, "+hdr:o:t:")) != -1) { data/safelease-1.0.1/src/safelease.c:581:19: [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, "+hdfo:")) != -1) { data/safelease-1.0.1/src/safelease.c:630:19: [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, "+hdr:o:")) != -1) { data/safelease-1.0.1/src/safelease.c:708:19: [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, "+hd")) != -1) { data/safelease-1.0.1/src/safelease.c:65: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 buf[512]; data/safelease-1.0.1/src/safelease.c:84: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 buf[512]; data/safelease-1.0.1/src/safelease.c:163: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(tag, src, taglen); data/safelease-1.0.1/src/safelease.c:176: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 _id[idlen+1]; data/safelease-1.0.1/src/safelease.c:185: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 _stamp[stamplen+1] = ""; data/safelease-1.0.1/src/safelease.c:187: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(id, tag, idlen); data/safelease-1.0.1/src/safelease.c:189: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(_stamp, tag+idlen, stamplen); data/safelease-1.0.1/src/safelease.c:206: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(tag, iobuf, taglen); data/safelease-1.0.1/src/safelease.c:217: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(iobuf, tag, taglen); data/safelease-1.0.1/src/safelease.c:250: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 curr[taglen+1] = "", last[taglen+1] = "", tag[taglen+1] = ""; data/safelease-1.0.1/src/safelease.c:253: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 dummyid[idlen+1]; data/safelease-1.0.1/src/safelease.c:320: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 curr[taglen+1] = "", tag[taglen+1] = ""; data/safelease-1.0.1/src/safelease.c:321: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 dummyid[idlen+1]; data/safelease-1.0.1/src/safelease.c:374: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 curr[taglen+1] = ""; data/safelease-1.0.1/src/safelease.c:394: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 curr[taglen+1] = ""; data/safelease-1.0.1/src/safelease.c:395: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 id[idlen+1] = ""; data/safelease-1.0.1/src/safelease.c:495:15: [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(path, O_RDWR | O_DIRECT)) < 0) data/safelease-1.0.1/src/safelease.c:554:15: [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(path, O_RDWR | O_DIRECT)) < 0) data/safelease-1.0.1/src/safelease.c:607:15: [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(path, O_RDWR | O_DIRECT)) < 0) data/safelease-1.0.1/src/safelease.c:654:15: [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(path, O_RDWR | O_DIRECT)) < 0) data/safelease-1.0.1/src/safelease.c:265: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(backoff_usec); data/safelease-1.0.1/src/safelease.c:278:9: [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(contend_usec); data/safelease-1.0.1/src/safelease.c:409:7: [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). t[strlen(t)-1] = 0; data/safelease-1.0.1/src/safelease.c:428: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). if (strlen(id) > idlen) ANALYSIS SUMMARY: Hits = 32 Lines analyzed = 737 in approximately 0.03 seconds (24923 lines/second) Physical Source Lines of Code (SLOC) = 582 Hits@level = [0] 13 [1] 4 [2] 20 [3] 5 [4] 3 [5] 0 Hits@level+ = [0+] 45 [1+] 32 [2+] 28 [3+] 8 [4+] 3 [5+] 0 Hits/KSLOC@level+ = [0+] 77.3196 [1+] 54.9828 [2+] 48.11 [3+] 13.7457 [4+] 5.15464 [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.