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/imx-usb-loader-0~git20200517.30b43d69/sdp.c Examining data/imx-usb-loader-0~git20200517.30b43d69/imx_sdp.h Examining data/imx-usb-loader-0~git20200517.30b43d69/imx_sdp_simulation.c Examining data/imx-usb-loader-0~git20200517.30b43d69/imx_loader.h Examining data/imx-usb-loader-0~git20200517.30b43d69/imx_usb.c Examining data/imx-usb-loader-0~git20200517.30b43d69/imx_uart.c Examining data/imx-usb-loader-0~git20200517.30b43d69/imx_sdp.c Examining data/imx-usb-loader-0~git20200517.30b43d69/image.h Examining data/imx-usb-loader-0~git20200517.30b43d69/sdp.h Examining data/imx-usb-loader-0~git20200517.30b43d69/imx_sdp_simulation.h Examining data/imx-usb-loader-0~git20200517.30b43d69/sdps.c Examining data/imx-usb-loader-0~git20200517.30b43d69/msvc/getopt.c Examining data/imx-usb-loader-0~git20200517.30b43d69/msvc/getopt.h Examining data/imx-usb-loader-0~git20200517.30b43d69/imx_loader_config.c Examining data/imx-usb-loader-0~git20200517.30b43d69/portable.h Examining data/imx-usb-loader-0~git20200517.30b43d69/imx_loader_config.h Examining data/imx-usb-loader-0~git20200517.30b43d69/sdps.h FINAL RESULTS: data/imx-usb-loader-0~git20200517.30b43d69/imx_loader_config.c:92:3: [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. readlink("/proc/self/exe", base_path,sizeof(base_path)); data/imx-usb-loader-0~git20200517.30b43d69/imx_loader_config.c:115:2: [5] (buffer) strncat: Easily used incorrectly (e.g., incorrectly computing the correct maximum size to add) [MS-banned] (CWE-120). Consider strcat_s, strlcat, snprintf, or automatically resizing strings. Risk is high; the length parameter appears to be a constant, instead of computing the number of characters left. strncat(conf, &sep, sizeof(conf)); data/imx-usb-loader-0~git20200517.30b43d69/imx_loader_config.c:116:2: [5] (buffer) strncat: Easily used incorrectly (e.g., incorrectly computing the correct maximum size to add) [MS-banned] (CWE-120). Consider strcat_s, strlcat, snprintf, or automatically resizing strings. Risk is high; the length parameter appears to be a constant, instead of computing the number of characters left. strncat(conf, subdir, sizeof(conf)); data/imx-usb-loader-0~git20200517.30b43d69/imx_loader_config.c:132:6: [4] (race) access: This usually indicates a security flaw. If an attacker can change anything along the path between the call to access() and the file's actual use (e.g., by moving files), the attacker can exploit the race condition (CWE-362/CWE-367!). Set up the correct permissions (e.g., using setuid()) and try to open the file directly. if (access(conf, R_OK) != -1) { data/imx-usb-loader-0~git20200517.30b43d69/imx_loader_config.c:505:7: [4] (race) access: This usually indicates a security flaw. If an attacker can change anything along the path between the call to access() and the file's actual use (e.g., by moving files), the attacker can exploit the race condition (CWE-362/CWE-367!). Set up the correct permissions (e.g., using setuid()) and try to open the file directly. if (access(w->filename, R_OK) == -1) { data/imx-usb-loader-0~git20200517.30b43d69/imx_sdp.c:668:4: [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((i==4) ? " %08x":" %08x", p[0]); data/imx-usb-loader-0~git20200517.30b43d69/portable.h:7:52: [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. #define dbg_printf(fmt, args...) do{ if(debugmode) fprintf(stderr, fmt, ## args); } while(0) data/imx-usb-loader-0~git20200517.30b43d69/portable.h:12:30: [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. #define dbg_printf(fmt, ...) fprintf(stderr, fmt, __VA_ARGS__) data/imx-usb-loader-0~git20200517.30b43d69/portable.h:54:9: [4] (race) access: This usually indicates a security flaw. If an attacker can change anything along the path between the call to access() and the file's actual use (e.g., by moving files), the attacker can exploit the race condition (CWE-362/CWE-367!). Set up the correct permissions (e.g., using setuid()) and try to open the file directly. #define access(filename,oflag) _access(filename,oflag) data/imx-usb-loader-0~git20200517.30b43d69/imx_loader_config.c:112:25: [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 const *progdata = getenv("ProgramData"); data/imx-usb-loader-0~git20200517.30b43d69/imx_uart.c:310:14: [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. while ((c = getopt_long(argc, argv, "+hdvVnN", long_options, NULL)) != -1) { data/imx-usb-loader-0~git20200517.30b43d69/imx_usb.c:594:14: [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. while ((c = getopt_long(argc, argv, "+hdvVc:b:D:S:", long_options, NULL)) != -1) { data/imx-usb-loader-0~git20200517.30b43d69/msvc/getopt.c:119:45: [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. d->__posixly_correct = posixly_correct | !!getenv("POSIXLY_CORRECT"); data/imx-usb-loader-0~git20200517.30b43d69/msvc/getopt.h:123:11: [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. #define getopt getopt_w data/imx-usb-loader-0~git20200517.30b43d69/msvc/getopt.h:124:11: [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. #define getopt_long getopt_long_w data/imx-usb-loader-0~git20200517.30b43d69/msvc/getopt.h:129:11: [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. #define getopt getopt_a data/imx-usb-loader-0~git20200517.30b43d69/msvc/getopt.h:130:11: [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. #define getopt_long getopt_long_a data/imx-usb-loader-0~git20200517.30b43d69/imx_loader_config.c:85: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. static char base_path[PATH_MAX]; data/imx-usb-loader-0~git20200517.30b43d69/imx_loader_config.c:109: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. static char conf[PATH_MAX]; data/imx-usb-loader-0~git20200517.30b43d69/imx_loader_config.c:126: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. static char conf[PATH_MAX]; data/imx-usb-loader-0~git20200517.30b43d69/imx_loader_config.c:142: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 path[PATH_MAX]; data/imx-usb-loader-0~git20200517.30b43d69/imx_loader_config.c:398: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 line[512]; data/imx-usb-loader-0~git20200517.30b43d69/imx_loader_config.c:408:10: [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). xfile = fopen(filename, "rb" ); data/imx-usb-loader-0~git20200517.30b43d69/imx_sdp.c:64: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 writeable_header[1024]; data/imx-usb-loader-0~git20200517.30b43d69/imx_sdp.c:162: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 tmp[64] = { 0 }; data/imx-usb-loader-0~git20200517.30b43d69/imx_sdp.c:204: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 buf[MAX_PROTOCOL_SIZE]; data/imx-usb-loader-0~git20200517.30b43d69/imx_sdp.c:210: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 tmp[64]; data/imx-usb-loader-0~git20200517.30b43d69/imx_sdp.c:249: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(dest, tmp, last_trans); data/imx-usb-loader-0~git20200517.30b43d69/imx_sdp.c:259: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 buf[MAX_PROTOCOL_SIZE]; data/imx-usb-loader-0~git20200517.30b43d69/imx_sdp.c:263: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 tmp[64] = { 0 }; data/imx-usb-loader-0~git20200517.30b43d69/imx_sdp.c:316: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 buf[MAX_PROTOCOL_SIZE]; data/imx-usb-loader-0~git20200517.30b43d69/imx_sdp.c:404: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 buf[MAX_PROTOCOL_SIZE]; data/imx-usb-loader-0~git20200517.30b43d69/imx_sdp.c:616: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 buf[8*9 + 2]; data/imx-usb-loader-0~git20200517.30b43d69/imx_sdp.c:745: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. unsigned char mem_buf[64]; data/imx-usb-loader-0~git20200517.30b43d69/imx_sdp.c:812: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 buf[MAX_PROTOCOL_SIZE]; data/imx-usb-loader-0~git20200517.30b43d69/imx_sdp.c:818: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 combine_buf[1024]; data/imx-usb-loader-0~git20200517.30b43d69/imx_sdp.c:846:4: [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(combine_buf, p, cnt); data/imx-usb-loader-0~git20200517.30b43d69/imx_sdp.c:853: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(&combine_buf[cnt], p, next_cnt); data/imx-usb-loader-0~git20200517.30b43d69/imx_sdp.c:903: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 buf[MAX_PROTOCOL_SIZE]; data/imx-usb-loader-0~git20200517.30b43d69/imx_sdp.c:1370: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). ld.xfile = fopen(curr->filename, "rb" ); data/imx-usb-loader-0~git20200517.30b43d69/imx_sdp.h:44: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 filename[256]; data/imx-usb-loader-0~git20200517.30b43d69/imx_sdp.h:83: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 name[64]; data/imx-usb-loader-0~git20200517.30b43d69/imx_sdp_simulation.c:41: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 unsigned char cur_cmd[MAX_PROTOCOL_SIZE]; data/imx-usb-loader-0~git20200517.30b43d69/imx_sdp_simulation.c:56: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(cur_cmd, p, cmd_size); data/imx-usb-loader-0~git20200517.30b43d69/imx_sdp_simulation.c:93: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(cur_mem->buf + cur_mem->offset, p, count); data/imx-usb-loader-0~git20200517.30b43d69/imx_sdp_simulation.c:125:4: [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, cur_mem->buf + offset, cnt); data/imx-usb-loader-0~git20200517.30b43d69/imx_uart.c:93: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 magic_response[4]; data/imx-usb-loader-0~git20200517.30b43d69/imx_uart.c:100:13: [2] (misc) open: 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). *uart_fd = open(tty, flags); data/imx-usb-loader-0~git20200517.30b43d69/imx_usb.c:50: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 file_name[256]; data/imx-usb-loader-0~git20200517.30b43d69/imx_usb.c:136: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 line[512]; data/imx-usb-loader-0~git20200517.30b43d69/imx_usb.c:142:16: [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). FILE* xfile = fopen(filename, "rb" ); data/imx-usb-loader-0~git20200517.30b43d69/imx_usb.c:248: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 tmp[1028]; data/imx-usb-loader-0~git20200517.30b43d69/imx_usb.c:261: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[1], p, cnt); data/imx-usb-loader-0~git20200517.30b43d69/imx_usb.c:297:6: [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, &tmp[1], *last_trans); data/imx-usb-loader-0~git20200517.30b43d69/imx_usb.c:614:10: [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). bus = atoi(optarg); data/imx-usb-loader-0~git20200517.30b43d69/imx_usb.c:617: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). address = atoi(optarg); data/imx-usb-loader-0~git20200517.30b43d69/portable.h:50:9: [2] (misc) open: 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). #define open(filename,oflag) _open(filename,oflag) data/imx-usb-loader-0~git20200517.30b43d69/sdp.c:40:2: [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(buf, &read_reg_command, cmd_size); data/imx-usb-loader-0~git20200517.30b43d69/sdp.c:56:2: [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(buf, &write_reg_command, cmd_size); data/imx-usb-loader-0~git20200517.30b43d69/sdp.c:72:2: [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(buf, &status_command, cmd_size); data/imx-usb-loader-0~git20200517.30b43d69/sdp.c:88:2: [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(buf, &dl_command, cmd_size); data/imx-usb-loader-0~git20200517.30b43d69/sdp.c:104:2: [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(buf, &dl_command, cmd_size); data/imx-usb-loader-0~git20200517.30b43d69/sdp.c:120:2: [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(buf, &jump_command, cmd_size); data/imx-usb-loader-0~git20200517.30b43d69/sdps.c:25: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 reserved[2]; // Reserved - shall be zero. data/imx-usb-loader-0~git20200517.30b43d69/sdps.c:28: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 reserved2[11]; data/imx-usb-loader-0~git20200517.30b43d69/sdps.c:65:2: [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(buf, &dl_command, cmd_size); data/imx-usb-loader-0~git20200517.30b43d69/imx_loader_config.c:88:2: [1] (buffer) strncpy: Easily used incorrectly; doesn't always \0-terminate or check for invalid pointers [MS-banned] (CWE-120). strncpy(base_path, argv0, sizeof(base_path)); data/imx-usb-loader-0~git20200517.30b43d69/imx_loader_config.c:114:2: [1] (buffer) strncpy: Easily used incorrectly; doesn't always \0-terminate or check for invalid pointers [MS-banned] (CWE-120). strncpy(conf, progdata, sizeof(conf)); data/imx-usb-loader-0~git20200517.30b43d69/imx_loader_config.c:129:2: [1] (buffer) strncpy: Easily used incorrectly; doesn't always \0-terminate or check for invalid pointers [MS-banned] (CWE-120). strncpy(conf, conf_path, sizeof(conf)); data/imx-usb-loader-0~git20200517.30b43d69/imx_loader_config.c:130:2: [1] (buffer) strncat: Easily used incorrectly (e.g., incorrectly computing the correct maximum size to add) [MS-banned] (CWE-120). Consider strcat_s, strlcat, snprintf, or automatically resizing strings. strncat(conf, &sep, sizeof(conf) - strlen(conf) - 1); data/imx-usb-loader-0~git20200517.30b43d69/imx_loader_config.c:130:37: [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). strncat(conf, &sep, sizeof(conf) - strlen(conf) - 1); data/imx-usb-loader-0~git20200517.30b43d69/imx_loader_config.c:131:2: [1] (buffer) strncat: Easily used incorrectly (e.g., incorrectly computing the correct maximum size to add) [MS-banned] (CWE-120). Consider strcat_s, strlcat, snprintf, or automatically resizing strings. strncat(conf, conf_file, sizeof(conf) - strlen(conf) - 1); data/imx-usb-loader-0~git20200517.30b43d69/imx_loader_config.c:131:42: [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). strncat(conf, conf_file, sizeof(conf) - strlen(conf) - 1); data/imx-usb-loader-0~git20200517.30b43d69/imx_loader_config.c:504:3: [1] (buffer) strncpy: Easily used incorrectly; doesn't always \0-terminate or check for invalid pointers [MS-banned] (CWE-120). strncpy(w->filename, argv[i], sizeof(w->filename) - 1); data/imx-usb-loader-0~git20200517.30b43d69/imx_sdp.c:774:10: [1] (buffer) mismatch: Function does not check the second iterator for over-read conditions (CWE-126). This function is often discouraged by most C++ coding standards in favor of its safer alternatives provided since C++14. Consider using a form of this function that checks the second iterator before potentially overflowing it. if (!mismatch) data/imx-usb-loader-0~git20200517.30b43d69/imx_sdp.c:794:9: [1] (buffer) mismatch: Function does not check the second iterator for over-read conditions (CWE-126). This function is often discouraged by most C++ coding standards in favor of its safer alternatives provided since C++14. Consider using a form of this function that checks the second iterator before potentially overflowing it. if (mismatch >= 5) data/imx-usb-loader-0~git20200517.30b43d69/imx_sdp.c:804:7: [1] (buffer) mismatch: Function does not check the second iterator for over-read conditions (CWE-126). This function is often discouraged by most C++ coding standards in favor of its safer alternatives provided since C++14. Consider using a form of this function that checks the second iterator before potentially overflowing it. if (!mismatch) data/imx-usb-loader-0~git20200517.30b43d69/imx_sdp.c:806:9: [1] (buffer) mismatch: Function does not check the second iterator for over-read conditions (CWE-126). This function is often discouraged by most C++ coding standards in favor of its safer alternatives provided since C++14. Consider using a form of this function that checks the second iterator before potentially overflowing it. return mismatch ? -1 : 0; data/imx-usb-loader-0~git20200517.30b43d69/imx_uart.c:62:10: [1] (buffer) read: Check buffer boundaries if used in a loop including recursive loops (CWE-120, CWE-20). ret = read(fd, p, expected - *last_trans); data/imx-usb-loader-0~git20200517.30b43d69/imx_uart.c:197:10: [1] (buffer) read: Check buffer boundaries if used in a loop including recursive loops (CWE-120, CWE-20). err = read(*uart_fd, buf, 4 - count); data/imx-usb-loader-0~git20200517.30b43d69/msvc/getopt.c:213:34: [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 (namelen == (unsigned int)strlen(p->name)) data/imx-usb-loader-0~git20200517.30b43d69/msvc/getopt.c:250:22: [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). d->__nextchar += strlen(d->__nextchar); data/imx-usb-loader-0~git20200517.30b43d69/msvc/getopt.c:276: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). d->__nextchar += strlen(d->__nextchar); data/imx-usb-loader-0~git20200517.30b43d69/msvc/getopt.c:291: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). d->__nextchar += strlen(d->__nextchar); data/imx-usb-loader-0~git20200517.30b43d69/msvc/getopt.c:296:22: [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). d->__nextchar += strlen(d->__nextchar); data/imx-usb-loader-0~git20200517.30b43d69/msvc/getopt.c:374:54: [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 ((unsigned int) (nameend - d->__nextchar) == strlen(p->name)) data/imx-usb-loader-0~git20200517.30b43d69/msvc/getopt.c:395: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). d->__nextchar += strlen(d->__nextchar); data/imx-usb-loader-0~git20200517.30b43d69/msvc/getopt.c:412: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). d->__nextchar += strlen(d->__nextchar); data/imx-usb-loader-0~git20200517.30b43d69/msvc/getopt.c:426: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). d->__nextchar += strlen(d->__nextchar); data/imx-usb-loader-0~git20200517.30b43d69/msvc/getopt.c:432: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). d->__nextchar += strlen(d->__nextchar); data/imx-usb-loader-0~git20200517.30b43d69/msvc/getopt.c:673:34: [1] (buffer) wcslen: 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 (namelen == (unsigned int)wcslen(p->name)) data/imx-usb-loader-0~git20200517.30b43d69/msvc/getopt.c:710:22: [1] (buffer) wcslen: 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). d->__nextchar += wcslen(d->__nextchar); data/imx-usb-loader-0~git20200517.30b43d69/msvc/getopt.c:736:24: [1] (buffer) wcslen: 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). d->__nextchar += wcslen(d->__nextchar); data/imx-usb-loader-0~git20200517.30b43d69/msvc/getopt.c:751:24: [1] (buffer) wcslen: 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). d->__nextchar += wcslen(d->__nextchar); data/imx-usb-loader-0~git20200517.30b43d69/msvc/getopt.c:756:22: [1] (buffer) wcslen: 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). d->__nextchar += wcslen(d->__nextchar); data/imx-usb-loader-0~git20200517.30b43d69/msvc/getopt.c:834:54: [1] (buffer) wcslen: 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 ((unsigned int) (nameend - d->__nextchar) == wcslen(p->name)) data/imx-usb-loader-0~git20200517.30b43d69/msvc/getopt.c:855:23: [1] (buffer) wcslen: 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). d->__nextchar += wcslen(d->__nextchar); data/imx-usb-loader-0~git20200517.30b43d69/msvc/getopt.c:872:25: [1] (buffer) wcslen: 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). d->__nextchar += wcslen(d->__nextchar); data/imx-usb-loader-0~git20200517.30b43d69/msvc/getopt.c:886:25: [1] (buffer) wcslen: 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). d->__nextchar += wcslen(d->__nextchar); data/imx-usb-loader-0~git20200517.30b43d69/msvc/getopt.c:892:23: [1] (buffer) wcslen: 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). d->__nextchar += wcslen(d->__nextchar); data/imx-usb-loader-0~git20200517.30b43d69/portable.h:40:20: [1] (obsolete) usleep: This C routine is considered obsolete (as opposed to the shell command by the same name). The interaction of this function with SIGALRM and other timer functions such as sleep(), alarm(), setitimer(), and nanosleep() is unspecified (CWE-676). Use nanosleep(2) or setitimer(2) instead. #define msleep(ms) usleep((ms) * 1000) data/imx-usb-loader-0~git20200517.30b43d69/portable.h:52:9: [1] (buffer) read: Check buffer boundaries if used in a loop including recursive loops (CWE-120, CWE-20). #define read(fd,buffer,count) _read(fd,buffer,count) ANALYSIS SUMMARY: Hits = 102 Lines analyzed = 5139 in approximately 0.18 seconds (29271 lines/second) Physical Source Lines of Code (SLOC) = 4214 Hits@level = [0] 180 [1] 36 [2] 49 [3] 8 [4] 6 [5] 3 Hits@level+ = [0+] 282 [1+] 102 [2+] 66 [3+] 17 [4+] 9 [5+] 3 Hits/KSLOC@level+ = [0+] 66.9198 [1+] 24.205 [2+] 15.6621 [3+] 4.03417 [4+] 2.13574 [5+] 0.711913 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.