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/libpam-freerdp2-2.0.0/include/pam-freerdp2.h Examining data/libpam-freerdp2-2.0.0/src/auth-check-path.c Examining data/libpam-freerdp2-2.0.0/src/auth-check-path.h Examining data/libpam-freerdp2-2.0.0/src/freerdp2-auth-check.c Examining data/libpam-freerdp2-2.0.0/src/pam-freerdp2.c Examining data/libpam-freerdp2-2.0.0/src/pam-freerdp2-children.c Examining data/libpam-freerdp2-2.0.0/src/pam-freerdp2-children.h Examining data/libpam-freerdp2-2.0.0/src/pam-freerdp2-private.h Examining data/libpam-freerdp2-2.0.0/tests/mock_guest.c Examining data/libpam-freerdp2-2.0.0/tests/mock_guest.h Examining data/libpam-freerdp2-2.0.0/tests/mock_pam.c Examining data/libpam-freerdp2-2.0.0/tests/mock_pam.h Examining data/libpam-freerdp2-2.0.0/tests/test-freerdp2-auth.c Examining data/libpam-freerdp2-2.0.0/tests/test-freerdp2-wrapper.cc FINAL RESULTS: data/libpam-freerdp2-2.0.0/src/pam-freerdp2-children.c:186:6: [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(socket_addr.sun_path, S_IRUSR | S_IWUSR) != 0 || data/libpam-freerdp2-2.0.0/src/pam-freerdp2-children.c:187:4: [5] (race) chown: This accepts filename arguments; if an attacker can move those files, a race condition results. (CWE-362). Use fchown( ) instead. chown(socket_addr.sun_path, pwdent->pw_uid, pwdent->pw_gid) != 0) { data/libpam-freerdp2-2.0.0/tests/mock_guest.c:51:5: [5] (race) chmod: This accepts filename arguments; if an attacker can move those files, a race condition results. (CWE-362). Use fchmod( ) instead. int chmod(const char *path, mode_t mode) data/libpam-freerdp2-2.0.0/tests/mock_guest.c:54:5: [5] (race) chown: This accepts filename arguments; if an attacker can move those files, a race condition results. (CWE-362). Use fchown( ) instead. int chown(const char *path, uid_t owner, gid_t group) data/libpam-freerdp2-2.0.0/tests/mock_guest.h:21:5: [5] (race) chmod: This accepts filename arguments; if an attacker can move those files, a race condition results. (CWE-362). Use fchmod( ) instead. int chmod(const char *path, mode_t mode); data/libpam-freerdp2-2.0.0/tests/mock_guest.h:22:5: [5] (race) chown: This accepts filename arguments; if an attacker can move those files, a race condition results. (CWE-362). Use fchown( ) instead. int chown(const char *path, uid_t owner, gid_t group); data/libpam-freerdp2-2.0.0/src/pam-freerdp2-children.c:80:2: [4] (shell) execvp: 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. execvp(args[0], args); data/libpam-freerdp2-2.0.0/tests/mock_guest.c:57:5: [4] (shell) execvp: 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. int execvp(const char *file, char *const argv[]) data/libpam-freerdp2-2.0.0/tests/mock_guest.h:23:5: [4] (shell) execvp: 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. int execvp(const char *file, char *const argv[]); data/libpam-freerdp2-2.0.0/tests/mock_guest.c:80:22: [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. const char * home = getenv("HOME"); data/libpam-freerdp2-2.0.0/src/freerdp2-auth-check.c:53: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 password[512]; data/libpam-freerdp2-2.0.0/src/pam-freerdp2-children.c:46: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 * args[5]; data/libpam-freerdp2-2.0.0/src/pam-freerdp2.c:354: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 readbuffer[strlen(ALL_GOOD_SIGNAL) + 1]; data/libpam-freerdp2-2.0.0/tests/mock_guest.c:102: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 buffer[BUFFER_SIZE + 2]; data/libpam-freerdp2-2.0.0/tests/mock_pam.c:146:3: [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, value, nsize); data/libpam-freerdp2-2.0.0/tests/test-freerdp2-auth.c:26: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 password[512]; data/libpam-freerdp2-2.0.0/src/freerdp2-auth-check.c:60:6: [1] (buffer) scanf: It's unclear if the %s limit in the format string is small enough (CWE-120). Check that the limit is sufficiently small, or use a different input function. if (scanf("%511s", password) != 1) { data/libpam-freerdp2-2.0.0/src/pam-freerdp2-children.c:135: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). buffer_len += strlen(ruser) + 1; /* Add one for the space */ data/libpam-freerdp2-2.0.0/src/pam-freerdp2-children.c:136: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). buffer_len += strlen(rhost) + 1; /* Add one for the space */ data/libpam-freerdp2-2.0.0/src/pam-freerdp2-children.c:137: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). buffer_len += strlen(rdomain) + 1; /* Add one for the space */ data/libpam-freerdp2-2.0.0/src/pam-freerdp2-children.c:138: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). buffer_len += strlen(password) + 1; /* Add one for the NULL */ data/libpam-freerdp2-2.0.0/src/pam-freerdp2-children.c:174:2: [1] (buffer) strncpy: Easily used incorrectly; doesn't always \0-terminate or check for invalid pointers [MS-banned] (CWE-120). strncpy(socket_addr.sun_path, pwdent->pw_dir, sizeof(socket_addr.sun_path) - 1); data/libpam-freerdp2-2.0.0/src/pam-freerdp2-children.c:175:2: [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(socket_addr.sun_path + strlen(pwdent->pw_dir), "/.freerdp2-socket", (sizeof(socket_addr.sun_path) - strlen(pwdent->pw_dir)) - 1); data/libpam-freerdp2-2.0.0/src/pam-freerdp2-children.c:175:33: [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). strncpy(socket_addr.sun_path + strlen(pwdent->pw_dir), "/.freerdp2-socket", (sizeof(socket_addr.sun_path) - strlen(pwdent->pw_dir)) - 1); data/libpam-freerdp2-2.0.0/src/pam-freerdp2-children.c:175:110: [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). strncpy(socket_addr.sun_path + strlen(pwdent->pw_dir), "/.freerdp2-socket", (sizeof(socket_addr.sun_path) - strlen(pwdent->pw_dir)) - 1); data/libpam-freerdp2-2.0.0/src/pam-freerdp2-children.c:195:49: [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). readywrite = write(readypipe, ALL_GOOD_SIGNAL, strlen(ALL_GOOD_SIGNAL) + 1); data/libpam-freerdp2-2.0.0/src/pam-freerdp2-children.c:196:20: [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 (readywrite != strlen(ALL_GOOD_SIGNAL) + 1) { data/libpam-freerdp2-2.0.0/src/pam-freerdp2.c:134:21: [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(promptval) == 0){ data/libpam-freerdp2-2.0.0/src/pam-freerdp2.c:139:24: [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 (mlock(promptval, strlen(promptval) + 1) != 0) { data/libpam-freerdp2-2.0.0/src/pam-freerdp2.c:161:29: [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). char * newish = subloc + strlen("://"); data/libpam-freerdp2-2.0.0/src/pam-freerdp2.c:209:32: [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). memset(global_password, 0, strlen(global_password)); data/libpam-freerdp2-2.0.0/src/pam-freerdp2.c:210:30: [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). munlock(global_password, strlen(global_password) + 1); data/libpam-freerdp2-2.0.0/src/pam-freerdp2.c:214:31: [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 (mlock(global_password, strlen(global_password) + 1) != 0) { data/libpam-freerdp2-2.0.0/src/pam-freerdp2.c:224:25: [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). memset(promptval, 0, strlen(promptval) + 1); data/libpam-freerdp2-2.0.0/src/pam-freerdp2.c:225: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). munlock(promptval, strlen(promptval) + 1); data/libpam-freerdp2-2.0.0/src/pam-freerdp2.c:281:46: [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). bytesout += write(stdinpipe[1], password, strlen(password)); data/libpam-freerdp2-2.0.0/src/pam-freerdp2.c:354:19: [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). char readbuffer[strlen(ALL_GOOD_SIGNAL) + 1]; data/libpam-freerdp2-2.0.0/src/pam-freerdp2.c:357:13: [1] (buffer) read: Check buffer boundaries if used in a loop including recursive loops (CWE-120, CWE-20). readlen = read(sessionready[0], readbuffer, strlen(ALL_GOOD_SIGNAL) + 1); data/libpam-freerdp2-2.0.0/src/pam-freerdp2.c:357:47: [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). readlen = read(sessionready[0], readbuffer, strlen(ALL_GOOD_SIGNAL) + 1); data/libpam-freerdp2-2.0.0/src/pam-freerdp2.c:361:18: [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 (readlen == strlen(ALL_GOOD_SIGNAL) + 1) { data/libpam-freerdp2-2.0.0/tests/mock_guest.c:92:12: [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). servlen = strlen(serv_addr.sun_path) + sizeof(serv_addr.sun_family); data/libpam-freerdp2-2.0.0/tests/mock_guest.c:106:7: [1] (buffer) read: Check buffer boundaries if used in a loop including recursive loops (CWE-120, CWE-20). in = read(socket_fd, buffer, BUFFER_SIZE); data/libpam-freerdp2-2.0.0/tests/mock_pam.c:134:11: [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). osize = strlen((const char *)*slot) + 1; data/libpam-freerdp2-2.0.0/tests/mock_pam.c:136:11: [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). nsize = strlen((const char *)value) + 1; data/libpam-freerdp2-2.0.0/tests/test-freerdp2-auth.c:32:6: [1] (buffer) scanf: It's unclear if the %s limit in the format string is small enough (CWE-120). Check that the limit is sufficiently small, or use a different input function. if (scanf("%511s", password) != 1) { ANALYSIS SUMMARY: Hits = 45 Lines analyzed = 1397 in approximately 0.05 seconds (29383 lines/second) Physical Source Lines of Code (SLOC) = 894 Hits@level = [0] 7 [1] 29 [2] 6 [3] 1 [4] 3 [5] 6 Hits@level+ = [0+] 52 [1+] 45 [2+] 16 [3+] 10 [4+] 9 [5+] 6 Hits/KSLOC@level+ = [0+] 58.1655 [1+] 50.3356 [2+] 17.8971 [3+] 11.1857 [4+] 10.0671 [5+] 6.71141 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.