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/ideviceinstaller-1.1.1/src/ideviceinstaller.c FINAL RESULTS: data/ideviceinstaller-1.1.1/src/ideviceinstaller.c:631:9: [5] (race) readlink: This accepts filename arguments; if an attacker can move those files or change the link content, a race condition results. Also, it does not terminate with ASCII NUL. (CWE-362, CWE-20). Reconsider approach. if (readlink(fpath, target, st.st_size+1) < 0) { data/ideviceinstaller-1.1.1/src/ideviceinstaller.c:69:8: [4] (format) vsnprintf: If format strings can be influenced by an attacker, they can be exploited, and note that sprintf variations do not always \0-terminate (CWE-134). Use a constant for the format specification. res = vsnprintf(buf, 16, TEMPLATE, AP); data/ideviceinstaller-1.1.1/src/ideviceinstaller.c:72:9: [4] (format) vsnprintf: If format strings can be influenced by an attacker, they can be exploited, and note that sprintf variations do not always \0-terminate (CWE-134). Use a constant for the format specification. res = vsnprintf(*PTR, res+1, TEMPLATE, AP); data/ideviceinstaller-1.1.1/src/ideviceinstaller.c:525:5: [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(newopts, options); data/ideviceinstaller-1.1.1/src/ideviceinstaller.c:528:5: [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(newopts, optarg); data/ideviceinstaller-1.1.1/src/ideviceinstaller.c:620:4: [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(fpath, path); data/ideviceinstaller-1.1.1/src/ideviceinstaller.c:622:4: [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(fpath, ep->d_name); data/ideviceinstaller-1.1.1/src/ideviceinstaller.c:624:4: [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(apath, afcpath); data/ideviceinstaller-1.1.1/src/ideviceinstaller.c:626:4: [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(apath, ep->d_name); data/ideviceinstaller-1.1.1/src/ideviceinstaller.c:996:4: [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(filename, appid); data/ideviceinstaller-1.1.1/src/ideviceinstaller.c:1079:4: [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(filename, app_directory_name); data/ideviceinstaller-1.1.1/src/ideviceinstaller.c:450:7: [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. c = getopt_long(argc, argv, "hU:li:u:g:La:r:R:o:nwdv", longopts, data/ideviceinstaller-1.1.1/src/ideviceinstaller.c:68: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[16]; data/ideviceinstaller-1.1.1/src/ideviceinstaller.c:561: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[1048576]; data/ideviceinstaller-1.1.1/src/ideviceinstaller.c:563:6: [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). f = fopen(filename, "rb"); data/ideviceinstaller-1.1.1/src/ideviceinstaller.c:716: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. const char *noties[3] = { NP_APP_INSTALLED, NP_APP_UNINSTALLED, NULL }; data/ideviceinstaller-1.1.1/src/ideviceinstaller.c:835: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 buf[8192]; data/ideviceinstaller-1.1.1/src/ideviceinstaller.c:997:4: [2] (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 string. strcat(filename, "/Info.plist"); data/ideviceinstaller-1.1.1/src/ideviceinstaller.c:1002:43: [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). if (stat(filename, &st) == -1 || (fp = fopen(filename, "r")) == NULL) { data/ideviceinstaller-1.1.1/src/ideviceinstaller.c:1082:4: [2] (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 string. strcat(filename, "Info.plist"); data/ideviceinstaller-1.1.1/src/ideviceinstaller.c:1393:8: [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). f = fopen(localfile, "wb"); data/ideviceinstaller-1.1.1/src/ideviceinstaller.c:1421:14: [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). fsize = atoi(fileinfo[i+1]); data/ideviceinstaller-1.1.1/src/ideviceinstaller.c:1456:4: [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/ideviceinstaller-1.1.1/src/ideviceinstaller.c:312: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). len = strlen(name); data/ideviceinstaller-1.1.1/src/ideviceinstaller.c:339:5: [1] (buffer) strncpy: Easily used incorrectly; doesn't always \0-terminate or check for invalid pointers [MS-banned] (CWE-120). strncpy(*path, name, len); data/ideviceinstaller-1.1.1/src/ideviceinstaller.c:524:28: [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 *newopts = malloc(strlen(options) + strlen(optarg) + 2); data/ideviceinstaller-1.1.1/src/ideviceinstaller.c:524: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). char *newopts = malloc(strlen(options) + strlen(optarg) + 2); data/ideviceinstaller-1.1.1/src/ideviceinstaller.c:527:5: [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(newopts, ","); data/ideviceinstaller-1.1.1/src/ideviceinstaller.c:615: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). char *fpath = (char*)malloc(strlen(path)+1+strlen(ep->d_name)+1); data/ideviceinstaller-1.1.1/src/ideviceinstaller.c:615: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). char *fpath = (char*)malloc(strlen(path)+1+strlen(ep->d_name)+1); data/ideviceinstaller-1.1.1/src/ideviceinstaller.c:616: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). char *apath = (char*)malloc(strlen(afcpath)+1+strlen(ep->d_name)+1); data/ideviceinstaller-1.1.1/src/ideviceinstaller.c:616: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). char *apath = (char*)malloc(strlen(afcpath)+1+strlen(ep->d_name)+1); data/ideviceinstaller-1.1.1/src/ideviceinstaller.c:621:4: [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(fpath, "/"); data/ideviceinstaller-1.1.1/src/ideviceinstaller.c:625:4: [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(apath, "/"); data/ideviceinstaller-1.1.1/src/ideviceinstaller.c:883: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). if ((strlen(appid) > 5) && (strcmp(&appid[strlen(appid)-5], ".ipcc") == 0)) { data/ideviceinstaller-1.1.1/src/ideviceinstaller.c:883:45: [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(appid) > 5) && (strcmp(&appid[strlen(appid)-5], ".ipcc") == 0)) { data/ideviceinstaller-1.1.1/src/ideviceinstaller.c:905: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). if (zname[strlen(zname)-1] == '/') { data/ideviceinstaller-1.1.1/src/ideviceinstaller.c:995: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). char *filename = (char*)malloc(strlen(appid)+11+1); data/ideviceinstaller-1.1.1/src/ideviceinstaller.c:1078: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). filename = (char*)malloc(strlen(app_directory_name)+10+1); data/ideviceinstaller-1.1.1/src/ideviceinstaller.c:1304:17: [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). } else if ((strlen(elem) > 5) && !strncmp(elem, "copy=", 5)) { ANALYSIS SUMMARY: Hits = 40 Lines analyzed = 1539 in approximately 0.08 seconds (19673 lines/second) Physical Source Lines of Code (SLOC) = 1285 Hits@level = [0] 105 [1] 17 [2] 11 [3] 1 [4] 10 [5] 1 Hits@level+ = [0+] 145 [1+] 40 [2+] 23 [3+] 12 [4+] 11 [5+] 1 Hits/KSLOC@level+ = [0+] 112.84 [1+] 31.1284 [2+] 17.8988 [3+] 9.33852 [4+] 8.56031 [5+] 0.77821 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.