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/xmlstarlet-1.6.1/version.h Examining data/xmlstarlet-1.6.1/src/xml_depyx.c Examining data/xmlstarlet-1.6.1/src/escape.h Examining data/xmlstarlet-1.6.1/src/xml_ls.c Examining data/xmlstarlet-1.6.1/src/xml_validate.c Examining data/xmlstarlet-1.6.1/src/xmlstar.h Examining data/xmlstarlet-1.6.1/src/trans.h Examining data/xmlstarlet-1.6.1/src/xml_format.c Examining data/xmlstarlet-1.6.1/src/xml_elem.c Examining data/xmlstarlet-1.6.1/src/xml.c Examining data/xmlstarlet-1.6.1/src/xml_trans.c Examining data/xmlstarlet-1.6.1/src/xml_edit.c Examining data/xmlstarlet-1.6.1/src/trans.c Examining data/xmlstarlet-1.6.1/src/xml_pyx.c Examining data/xmlstarlet-1.6.1/src/xml_C14N.c Examining data/xmlstarlet-1.6.1/src/xml_select.c Examining data/xmlstarlet-1.6.1/src/xml_escape.c FINAL RESULTS: data/xmlstarlet-1.6.1/src/xml_validate.c:245:56: [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. cvp->error = (xmlValidityErrorFunc) fprintf; data/xmlstarlet-1.6.1/src/xml_validate.c:246:58: [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. cvp->warning = (xmlValidityWarningFunc) fprintf; data/xmlstarlet-1.6.1/src/trans.c:105:26: [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. char *catalogs = getenv("SGML_CATALOG_FILES"); data/xmlstarlet-1.6.1/src/trans.c:202:44: [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. style = xmlReadFile((const char *) docs[i], NULL, options); data/xmlstarlet-1.6.1/src/trans.c:253:42: [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. doc = xmlReadFile((const char *) docs[i], NULL, options); data/xmlstarlet-1.6.1/src/xml_depyx.c:106: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. static char line[INSZ]; data/xmlstarlet-1.6.1/src/xml_depyx.c:111:13: [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). in = fopen(file, "r"); data/xmlstarlet-1.6.1/src/xml_elem.c:250:33: [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). elOps.check_depth = atoi(argv[2]+2); data/xmlstarlet-1.6.1/src/xml_escape.c:211:12: [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 entity[MAX_ENTITY_NAME+1]; /* +1 for NUL terminator */ data/xmlstarlet-1.6.1/src/xml_escape.c:226: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(entity, &str[i], entity_len); data/xmlstarlet-1.6.1/src/xml_escape.c:281:15: [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 line[INSZ]; data/xmlstarlet-1.6.1/src/xml_escape.c:302:24: [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(line, partial_entity, offset); data/xmlstarlet-1.6.1/src/xml_ls.c:95: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. static char perms[10]; data/xmlstarlet-1.6.1/src/xml_ls.c:97: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(perms, "---------"); data/xmlstarlet-1.6.1/src/xml_ls.c:145: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 atime[20]; data/xmlstarlet-1.6.1/src/xml_ls.c:146: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 mtime[20]; data/xmlstarlet-1.6.1/src/xml_select.c:656: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. const char *params[2+1] = { "inputFile" }; data/xmlstarlet-1.6.1/src/xml_trans.c:257:18: [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 const char *xsltParams[2 * MAX_PARAMETERS + 1]; data/xmlstarlet-1.6.1/src/xml.c:133: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). msglen = strlen(error->message); data/xmlstarlet-1.6.1/src/xml_depyx.c:123: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(line[strlen(line)-1] == '\n') line[strlen(line)-1] = '\0'; data/xmlstarlet-1.6.1/src/xml_depyx.c:123:50: [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(line[strlen(line)-1] == '\n') line[strlen(line)-1] = '\0'; data/xmlstarlet-1.6.1/src/xml_depyx.c:132: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). if(line[strlen(line)-1] == '\n') line[strlen(line)-1] = '\0'; data/xmlstarlet-1.6.1/src/xml_depyx.c:132:62: [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(line[strlen(line)-1] == '\n') line[strlen(line)-1] = '\0'; data/xmlstarlet-1.6.1/src/xml_depyx.c:156:44: [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(line[strlen(line)-1] == '\n') line[strlen(line)-1] = '\0'; data/xmlstarlet-1.6.1/src/xml_depyx.c:156:74: [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(line[strlen(line)-1] == '\n') line[strlen(line)-1] = '\0'; data/xmlstarlet-1.6.1/src/xml_escape.c:71:40: [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). const char* entnul = entname + strlen(entname); data/xmlstarlet-1.6.1/src/xml_escape.c:301: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). offset = strlen(partial_entity); ANALYSIS SUMMARY: Hits = 27 Lines analyzed = 5651 in approximately 0.15 seconds (36604 lines/second) Physical Source Lines of Code (SLOC) = 4183 Hits@level = [0] 164 [1] 9 [2] 15 [3] 1 [4] 2 [5] 0 Hits@level+ = [0+] 191 [1+] 27 [2+] 18 [3+] 3 [4+] 2 [5+] 0 Hits/KSLOC@level+ = [0+] 45.661 [1+] 6.4547 [2+] 4.30313 [3+] 0.717189 [4+] 0.478126 [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.