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/libcacard-2.7.0/tests/common.h Examining data/libcacard-2.7.0/tests/common.c Examining data/libcacard-2.7.0/tests/hwtests.c Examining data/libcacard-2.7.0/tests/simpletlv.c Examining data/libcacard-2.7.0/tests/libcacard.c Examining data/libcacard-2.7.0/src/vcard.c Examining data/libcacard-2.7.0/src/event.c Examining data/libcacard-2.7.0/src/cac.h Examining data/libcacard-2.7.0/src/common.h Examining data/libcacard-2.7.0/src/vcardt.h Examining data/libcacard-2.7.0/src/card_7816t.h Examining data/libcacard-2.7.0/src/vreader.c Examining data/libcacard-2.7.0/src/vcard_emul_type.c Examining data/libcacard-2.7.0/src/simpletlv.h Examining data/libcacard-2.7.0/src/eventt.h Examining data/libcacard-2.7.0/src/cac-aca.h Examining data/libcacard-2.7.0/src/vcardt.c Examining data/libcacard-2.7.0/src/card_7816.c Examining data/libcacard-2.7.0/src/gp.h Examining data/libcacard-2.7.0/src/common.c Examining data/libcacard-2.7.0/src/vcard_emul.h Examining data/libcacard-2.7.0/src/gp.c Examining data/libcacard-2.7.0/src/cac.c Examining data/libcacard-2.7.0/src/capcsc.h Examining data/libcacard-2.7.0/src/msft.c Examining data/libcacard-2.7.0/src/vcard.h Examining data/libcacard-2.7.0/src/glib-compat.h Examining data/libcacard-2.7.0/src/cac-aca.c Examining data/libcacard-2.7.0/src/libcacard.h Examining data/libcacard-2.7.0/src/vscard_common.h Examining data/libcacard-2.7.0/src/capcsc.c Examining data/libcacard-2.7.0/src/card_7816.h Examining data/libcacard-2.7.0/src/vcard_emul_type.h Examining data/libcacard-2.7.0/src/vcard_emul_nss.c Examining data/libcacard-2.7.0/src/vscclient.c Examining data/libcacard-2.7.0/src/vreadert.h Examining data/libcacard-2.7.0/src/vcardt_internal.h Examining data/libcacard-2.7.0/src/vevent.h Examining data/libcacard-2.7.0/src/msft.h Examining data/libcacard-2.7.0/src/simpletlv.c Examining data/libcacard-2.7.0/src/vreader.h FINAL RESULTS: data/libcacard-2.7.0/src/vcard_emul_nss.c:1436:4: [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(stderr, data/libcacard-2.7.0/src/vscclient.c:857:9: [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(new_args, emul_args); data/libcacard-2.7.0/src/vscclient.c:858:9: [4] (buffer) strcat: Does not check for buffer overflows when concatenating to destination [MS-banned] (CWE-120). Consider using strcat_s, strncat, strlcat, or snprintf (warning: strncat is easily misused). strcat(new_args, SOFT_STRING); data/libcacard-2.7.0/src/vscclient.c:860:13: [4] (buffer) strcat: Does not check for buffer overflows when concatenating to destination [MS-banned] (CWE-120). Consider using strcat_s, strncat, strlcat, or snprintf (warning: strncat is easily misused). strcat(new_args, cert_names[i]); data/libcacard-2.7.0/src/vscclient.c:806:17: [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 ((c = getopt(argc, argv, "c:e:d:p")) != -1) { data/libcacard-2.7.0/src/cac-aca.c:215:14: [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 applet_aid[MAX_AID_LEN]; data/libcacard-2.7.0/src/cac-aca.c:353: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(&entry[3], (unsigned char *) &service_table.entries[i], data/libcacard-2.7.0/src/cac-aca.c:393:14: [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 id[2]; data/libcacard-2.7.0/src/cac-aca.c:920:14: [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 amp_aid[7]; data/libcacard-2.7.0/src/cac-aca.c:991: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(&entry[3], (unsigned char *) &_table.entries[i], data/libcacard-2.7.0/src/cac-aca.c:1418: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(p, e->applet_aid, e->applet_aid_len); data/libcacard-2.7.0/src/cac.c:85:14: [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 v[2]; data/libcacard-2.7.0/src/cac.c:208:21: [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(&cp[k], &properties[i], data/libcacard-2.7.0/src/cac.c:528: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(sign_buffer + pki_applet->sign_buffer_len, apdu->a_body, size); data/libcacard-2.7.0/src/cac.c:990: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(applet_private->coids[0].v, object_id, 2); data/libcacard-2.7.0/src/cac.c:1504:14: [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 cardurl[21][16] = { data/libcacard-2.7.0/src/cac.c:1730: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(applet_private->coids[0].v, object_id, 2); data/libcacard-2.7.0/src/cac.c:2054: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(applet_private->coids[0].v, object_id, 2); data/libcacard-2.7.0/src/cac.c:2243: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(atr, cac_atr, len); data/libcacard-2.7.0/src/capcsc.c:110: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[8192]; data/libcacard-2.7.0/src/capcsc.c:315: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(atr, r->atr, r->atrlen); data/libcacard-2.7.0/src/card_7816.c:71: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(new_response->b_data, buf, len); data/libcacard-2.7.0/src/card_7816.c:685:17: [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(&fci_template[4], apdu->a_body, apdu->a_Lc); data/libcacard-2.7.0/src/card_7816t.h:60:14: [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 ah_body[1]; /* indefinite length */ data/libcacard-2.7.0/src/common.c:52:8: [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. static char hexdump_buffer[5*MAX_STATIC_BYTES + 1]; data/libcacard-2.7.0/src/common.c:77: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(p, "0x%02X ", buf[i]); data/libcacard-2.7.0/src/gp.c:88:17: [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(cplp_data + 15, serial, 6); data/libcacard-2.7.0/src/simpletlv.c:122:17: [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, tlv[i].value.value, tlv[i].length); data/libcacard-2.7.0/src/simpletlv.c:255: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(r, a, offset); data/libcacard-2.7.0/src/simpletlv.c:256: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(&r[a_len], b, b_len * sizeof(struct simpletlv_member)); data/libcacard-2.7.0/src/simpletlv.c:296: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(new[i].value.value, tlv[i].value.value, data/libcacard-2.7.0/src/vcard.c:36:14: [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 serial[32]; /* SHA256 of the first certificate */ data/libcacard-2.7.0/src/vcard.c:355: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(card->serial, serial, len); data/libcacard-2.7.0/src/vcard_emul_nss.c:257:14: [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[2048]; data/libcacard-2.7.0/src/vcard_emul_nss.c:299: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(buffer, bp, signature_len); data/libcacard-2.7.0/src/vcard_emul_nss.c:349: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(buffer, bp, signature.len); data/libcacard-2.7.0/src/vcard_emul_nss.c:385: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(&buffer[pad_len], bp, signature_len); data/libcacard-2.7.0/src/vcard_emul_nss.c:429: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(pin_string, pin, pin_len); data/libcacard-2.7.0/src/vcard_emul_nss.c:622: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(atr, nss_atr, len); data/libcacard-2.7.0/src/vcard_emul_nss.c:631:14: [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 digest[32]; data/libcacard-2.7.0/src/vcard_emul_nss.c:1258:13: [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 type_str[100]; data/libcacard-2.7.0/src/vcard_emul_nss.c:1274: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(type_str, type_params, type_params_length); data/libcacard-2.7.0/src/vcardt.c:34: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(&atr[3], prefix, prefix_len); data/libcacard-2.7.0/src/vcardt.c:35: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(&atr[3 + prefix_len], postfix, postfix_len); data/libcacard-2.7.0/src/vreader.c:291: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(receive_buf, response->b_data, size); data/libcacard-2.7.0/src/vscclient.c:227:14: [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 atr[MAX_ATR_LEN]; data/libcacard-2.7.0/src/vscclient.c:327:23: [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). unsigned int id = atoi(string); data/libcacard-2.7.0/src/vscclient.c:508: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(&error_msg, pbSendBuffer, sizeof(VSCMsgError)); data/libcacard-2.7.0/src/vscclient.c:533: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(&init, pbSendBuffer, sizeof(VSCMsgInit)); data/libcacard-2.7.0/src/vscclient.c:786: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 *cert_names[MAX_CERTS]; data/libcacard-2.7.0/tests/common.c:32: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(&selfile[5], coid, 2); data/libcacard-2.7.0/tests/common.c:75: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(&selfile[5], aid, aid_len); data/libcacard-2.7.0/tests/common.c:100:58: [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. void get_properties_coid(VReader *reader, const unsigned char coid[2], data/libcacard-2.7.0/tests/common.c:307:14: [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 coid[2]; data/libcacard-2.7.0/tests/common.c:377: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(data + offset - 2, pbRecvBuffer, dwReadLength); data/libcacard-2.7.0/tests/common.c:509: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(&sign[7], &sign[sign_len-key_bits/8+2], key_bits/8-2); data/libcacard-2.7.0/tests/common.h:36:58: [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. void get_properties_coid(VReader *reader, const unsigned char coid[2], int object_type); data/libcacard-2.7.0/tests/hwtests.c:141: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(&login[5], LOGIN_PIN, pin_len); data/libcacard-2.7.0/tests/libcacard.c:94:14: [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 binary_data[4000]; data/libcacard-2.7.0/tests/simpletlv.c:12:14: [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 long_value[256] = "Long data value"; data/libcacard-2.7.0/tests/simpletlv.c:108:14: [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 long_value[256] = "Long data value"; data/libcacard-2.7.0/tests/simpletlv.c:109:14: [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 long_encoded[261] = "\x25\xFF\x00\x01Long data value"; data/libcacard-2.7.0/src/capcsc.c:132:53: [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). for (p = buf; p && p < buf + sizeof(buf); p += (strlen(p) + 1)) { data/libcacard-2.7.0/src/capcsc.c:133: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). if (strlen(p) > 0) { data/libcacard-2.7.0/src/capcsc.c:346: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). strlen(CAPCSC_APPLET)); data/libcacard-2.7.0/src/vcard_emul_nss.c:1403: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). if (strlen(label) == result.len data/libcacard-2.7.0/src/vcardt.c:28: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). postfix_len = strlen(postfix); data/libcacard-2.7.0/src/vscclient.c:852:15: [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(emul_args) + strlen(SOFT_STRING) + 2; data/libcacard-2.7.0/src/vscclient.c:852: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). len = strlen(emul_args) + strlen(SOFT_STRING) + 2; data/libcacard-2.7.0/src/vscclient.c:854: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). len += strlen(cert_names[i])+1; /* 1 == comma */ data/libcacard-2.7.0/src/vscclient.c:861:13: [1] (buffer) strcat: Does not check for buffer overflows when concatenating to destination [MS-banned] (CWE-120). Consider using strcat_s, strncat, strlcat, or snprintf (warning: strncat is easily misused). Risk is low because the source is a constant character. strcat(new_args, ","); data/libcacard-2.7.0/src/vscclient.c:863:9: [1] (buffer) strcat: Does not check for buffer overflows when concatenating to destination [MS-banned] (CWE-120). Consider using strcat_s, strncat, strlcat, or snprintf (warning: strncat is easily misused). Risk is low because the source is a constant character. strcat(new_args, ")"); data/libcacard-2.7.0/tests/hwtests.c:139:15: [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). pin_len = strlen(LOGIN_PIN); ANALYSIS SUMMARY: Hits = 73 Lines analyzed = 13718 in approximately 0.42 seconds (32497 lines/second) Physical Source Lines of Code (SLOC) = 9381 Hits@level = [0] 73 [1] 11 [2] 57 [3] 1 [4] 4 [5] 0 Hits@level+ = [0+] 146 [1+] 73 [2+] 62 [3+] 5 [4+] 4 [5+] 0 Hits/KSLOC@level+ = [0+] 15.5634 [1+] 7.78169 [2+] 6.6091 [3+] 0.532992 [4+] 0.426394 [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.