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/fsplib-0.14/test.c Examining data/fsplib-0.14/fsplib.h Examining data/fsplib-0.14/lock.h Examining data/fsplib-0.14/lock.c Examining data/fsplib-0.14/fsplib.c FINAL RESULTS: data/fsplib-0.14/lock.c:18:3: [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(lock->key_string,FSP_KEY_PREFIX); data/fsplib-0.14/fsplib.c:247:13: [3] (random) random: This function is not sufficiently random for security-related functions such as key and nonce creation (CWE-327). Use a more secure technique for acquiring random values. retry = random() & 0xfff8; data/fsplib-0.14/fsplib.c:503:12: [3] (random) random: This function is not sufficiently random for security-related functions such as key and nonce creation (CWE-327). Use a more secure technique for acquiring random values. s->seq=random() & 0xfff8; data/fsplib-0.14/fsplib.c:49: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(out->buf,dirname,len+1); data/fsplib-0.14/fsplib.c:62: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(out->buf+out->len,s->password,len+1); data/fsplib-0.14/fsplib.c:107: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(tmp,filename,pos); data/fsplib-0.14/fsplib.c:142: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(ptr+FSP_HSIZE,p->buf,p->len); data/fsplib-0.14/fsplib.c:145: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(ptr+used,p->buf+p->len,p->xlen); data/fsplib-0.14/fsplib.c:215:4: [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(p->buf,ptr+FSP_HSIZE,recv_len - FSP_HSIZE); data/fsplib-0.14/fsplib.c:225: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[FSP_MAXPACKET]; data/fsplib-0.14/fsplib.c:412: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 port_s[6]; data/fsplib-0.14/fsplib.c:422:9: [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(port_s,"fsp"); data/fsplib-0.14/fsplib.c:424:9: [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(port_s,"%hu",port); data/fsplib-0.14/fsplib.c:597: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(dir->data + pos, in.buf,in.len); data/fsplib-0.14/fsplib.c:930: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(ptr,file->in.buf+file->bufpos,havebytes); data/fsplib-0.14/fsplib.c:938: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(ptr,file->in.buf+file->bufpos,total); data/fsplib-0.14/fsplib.c:986: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(file->out.buf+file->bufpos,ptr,freebytes); data/fsplib-0.14/fsplib.c:993: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(file->out.buf+file->bufpos,ptr,total); data/fsplib-0.14/fsplib.c:1310:4: [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(out.buf+out.len,to,l); data/fsplib-0.14/fsplib.c:1322:8: [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(out.buf+out.len+out.xlen,s->password,l); data/fsplib-0.14/fsplib.h:92:34: [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 buf[FSP_SPACE]; /* packet payload */ data/fsplib-0.14/fsplib.h:125:24: [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[255 + 1]; /* entry name */ data/fsplib-0.14/fsplib.h:148:7: [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 fill[offsetof (struct dirent, d_name) + MAXNAMLEN + 1]; data/fsplib-0.14/lock.c:100:8: [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(lock->key_string,O_RDWR|O_CREAT,0666); data/fsplib-0.14/lock.c:271:21: [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). lock->lock_fd = open(lock->key_string, O_RDWR | O_CREAT, 0666); data/fsplib-0.14/lock.h:17: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 key_string[sizeof(FSP_KEY_PREFIX)+32]; data/fsplib-0.14/lock.h:30: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 key_string[sizeof(FSP_KEY_PREFIX)+32]; data/fsplib-0.14/test.c:26:7: [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). port=atoi(argv[1]); data/fsplib-0.14/fsplib.c:42: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(dirname); data/fsplib-0.14/fsplib.c:56:13: [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(s->password); data/fsplib-0.14/fsplib.c:655:26: [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). rc=fentry.namlen-strlen(fentry.name); data/fsplib-0.14/fsplib.c:664:5: [1] (buffer) strncpy: Easily used incorrectly; doesn't always \0-terminate or check for invalid pointers [MS-banned] (CWE-120). strncpy(entry->d_name,fentry.name,MAXNAMLEN); data/fsplib-0.14/fsplib.c:735:8: [1] (buffer) strncpy: Easily used incorrectly; doesn't always \0-terminate or check for invalid pointers [MS-banned] (CWE-120). strncpy(entry->name,(char *)( dir->data + dir->dirpos ),255); data/fsplib-0.14/fsplib.c:739:23: [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). namelen = strlen( (char *) dir->data+dir->dirpos); data/fsplib-0.14/fsplib.c:1304:6: [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). l=strlen(to)+1; data/fsplib-0.14/fsplib.c:1315:10: [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). l=strlen(s->password)+1; data/fsplib-0.14/lock.c:99:11: [1] (access) umask: Ensure that umask is given most restrictive possible setting (e.g., 066 or 077) (CWE-732). omask = umask(0); data/fsplib-0.14/lock.c:101:3: [1] (access) umask: Ensure that umask is given most restrictive possible setting (e.g., 066 or 077) (CWE-732). umask(omask); data/fsplib-0.14/lock.c:229:10: [1] (buffer) read: Check buffer boundaries if used in a loop including recursive loops (CWE-120, CWE-20). if (read(lock->lock_fd, &okey, sizeof(okey)) < 0) data/fsplib-0.14/lock.c:270:13: [1] (access) umask: Ensure that umask is given most restrictive possible setting (e.g., 066 or 077) (CWE-732). omask = umask(0); data/fsplib-0.14/lock.c:272:11: [1] (access) umask: Ensure that umask is given most restrictive possible setting (e.g., 066 or 077) (CWE-732). (void)umask(omask); ANALYSIS SUMMARY: Hits = 41 Lines analyzed = 2023 in approximately 0.09 seconds (21811 lines/second) Physical Source Lines of Code (SLOC) = 1581 Hits@level = [0] 9 [1] 13 [2] 25 [3] 2 [4] 1 [5] 0 Hits@level+ = [0+] 50 [1+] 41 [2+] 28 [3+] 3 [4+] 1 [5+] 0 Hits/KSLOC@level+ = [0+] 31.6256 [1+] 25.933 [2+] 17.7103 [3+] 1.89753 [4+] 0.632511 [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.