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/pkcs11-data-0.7.4/pkcs11-data.c FINAL RESULTS: data/pkcs11-data-0.7.4/pkcs11-data.c:109: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 ( data/pkcs11-data-0.7.4/pkcs11-data.c:380:2: [4] (format) vfprintf: If format strings can be influenced by an attacker, they can be exploited (CWE-134). Use a constant for the format specification. vfprintf (stderr, format, args); data/pkcs11-data-0.7.4/pkcs11-data.c:465:13: [4] (misc) getpass: This function is obsolete and not portable. It was in SUSv2 but removed by POSIX.2. What it does exactly varies considerably between systems, particularly in where its prompt is displayed and where it gets its data (e.g., /dev/tty, stdin, stderr, etc.). In addition, some implementations overflow buffers. (CWE-676, CWE-120, CWE-20). Make the specific calls to do exactly what you want. If you continue to use it, or write your own, be sure to zero the password as soon as possible to avoid leaving the cleartext password visible in the process' address space. char *p = getpass (prompt); data/pkcs11-data-0.7.4/pkcs11-data.c:638:5: [4] (format) printf: If format strings can be influenced by an attacker, they can be exploited (CWE-134). Use a constant for the format specification. printf ( data/pkcs11-data-0.7.4/pkcs11-data.c:730:3: [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 ( data/pkcs11-data-0.7.4/pkcs11-data.c:566:23: [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. (long_options_ret = getopt_long (argc, argv, "", long_options, NULL)) != -1 data/pkcs11-data-0.7.4/pkcs11-data.c:235:17: [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). else if ((fp = fopen (szFile, "wb")) == NULL) { data/pkcs11-data-0.7.4/pkcs11-data.c:304:11: [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 blob[100*1024]; data/pkcs11-data-0.7.4/pkcs11-data.c:312:17: [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). else if ((fp = fopen (szFile, "rb")) == NULL) { data/pkcs11-data-0.7.4/pkcs11-data.c:393: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[1024]; data/pkcs11-data-0.7.4/pkcs11-data.c:394: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 prompt[1024]; data/pkcs11-data-0.7.4/pkcs11-data.c:411:5: [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 (buf, "cancel"); data/pkcs11-data-0.7.4/pkcs11-data.c:444: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 prompt[1024]; data/pkcs11-data-0.7.4/pkcs11-data.c:471:4: [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 (pin, "cancel"); data/pkcs11-data-0.7.4/pkcs11-data.c:798: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 prompt[2048]; data/pkcs11-data-0.7.4/pkcs11-data.c:799: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[1024]; data/pkcs11-data-0.7.4/pkcs11-data.c:801:5: [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 ( data/pkcs11-data-0.7.4/pkcs11-data.c:822:7: [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 (buf, "cancel"); data/pkcs11-data-0.7.4/pkcs11-data.c:145:12: [1] (buffer) read: Check buffer boundaries if used in a loop including recursive loops (CWE-120, CWE-20). if ((r = read (fds[0], input, input_size)) == -1) { data/pkcs11-data-0.7.4/pkcs11-data.c:152: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). if (strlen (input) > 0 && input[strlen (input)-1] == '\n') { data/pkcs11-data-0.7.4/pkcs11-data.c:152:35: [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 (input) > 0 && input[strlen (input)-1] == '\n') { data/pkcs11-data-0.7.4/pkcs11-data.c:153: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). input[strlen (input)-1] = '\0'; data/pkcs11-data-0.7.4/pkcs11-data.c:415: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). if (buf[0] != '\0' && buf[strlen (buf)-1] == '\n') { data/pkcs11-data-0.7.4/pkcs11-data.c:416:8: [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). buf[strlen (buf)-1] = '\0'; data/pkcs11-data-0.7.4/pkcs11-data.c:418: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). if (buf[0] != '\0' && buf[strlen (buf)-1] == '\r') { data/pkcs11-data-0.7.4/pkcs11-data.c:419:8: [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). buf[strlen (buf)-1] = '\0'; data/pkcs11-data-0.7.4/pkcs11-data.c:466:3: [1] (buffer) strncpy: Easily used incorrectly; doesn't always \0-terminate or check for invalid pointers [MS-banned] (CWE-120). strncpy (pin, p, pin_max); data/pkcs11-data-0.7.4/pkcs11-data.c:807:14: [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). prompt+strlen (prompt), data/pkcs11-data-0.7.4/pkcs11-data.c:808: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). sizeof (prompt)-strlen (prompt), data/pkcs11-data-0.7.4/pkcs11-data.c:826: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 (buf[0] != '\0' && buf[strlen (buf)-1] == '\n') { data/pkcs11-data-0.7.4/pkcs11-data.c:827: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). buf[strlen (buf)-1] = '\0'; data/pkcs11-data-0.7.4/pkcs11-data.c:829: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 (buf[0] != '\0' && buf[strlen (buf)-1] == '\r') { data/pkcs11-data-0.7.4/pkcs11-data.c:830: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). buf[strlen (buf)-1] = '\0'; ANALYSIS SUMMARY: Hits = 33 Lines analyzed = 1013 in approximately 0.06 seconds (16521 lines/second) Physical Source Lines of Code (SLOC) = 868 Hits@level = [0] 14 [1] 15 [2] 12 [3] 1 [4] 5 [5] 0 Hits@level+ = [0+] 47 [1+] 33 [2+] 18 [3+] 6 [4+] 5 [5+] 0 Hits/KSLOC@level+ = [0+] 54.1475 [1+] 38.0184 [2+] 20.7373 [3+] 6.91244 [4+] 5.76037 [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.