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/fbterm-1.7/im/example.c Examining data/fbterm-1.7/im/imapi.c Examining data/fbterm-1.7/im/imapi.h Examining data/fbterm-1.7/im/keycode.c Examining data/fbterm-1.7/im/keycode.h Examining data/fbterm-1.7/src/fbconfig.cpp Examining data/fbterm-1.7/src/fbconfig.h Examining data/fbterm-1.7/src/fbdev.cpp Examining data/fbterm-1.7/src/fbdev.h Examining data/fbterm-1.7/src/fbio.cpp Examining data/fbterm-1.7/src/fbio.h Examining data/fbterm-1.7/src/fbshell.cpp Examining data/fbterm-1.7/src/fbshell.h Examining data/fbterm-1.7/src/fbshellman.cpp Examining data/fbterm-1.7/src/fbshellman.h Examining data/fbterm-1.7/src/fbterm.cpp Examining data/fbterm-1.7/src/fbterm.h Examining data/fbterm-1.7/src/font.cpp Examining data/fbterm-1.7/src/font.h Examining data/fbterm-1.7/src/immessage.h Examining data/fbterm-1.7/src/improxy.cpp Examining data/fbterm-1.7/src/improxy.h Examining data/fbterm-1.7/src/input.cpp Examining data/fbterm-1.7/src/input.h Examining data/fbterm-1.7/src/input_key.h Examining data/fbterm-1.7/src/lib/charsetmap.cpp Examining data/fbterm-1.7/src/lib/instance.h Examining data/fbterm-1.7/src/lib/io.cpp Examining data/fbterm-1.7/src/lib/io.h Examining data/fbterm-1.7/src/lib/shell.cpp Examining data/fbterm-1.7/src/lib/shell.h Examining data/fbterm-1.7/src/lib/type.h Examining data/fbterm-1.7/src/lib/vterm.h Examining data/fbterm-1.7/src/lib/vterm_action.cpp Examining data/fbterm-1.7/src/lib/wcwidth.cpp Examining data/fbterm-1.7/src/lib/vterm.cpp Examining data/fbterm-1.7/src/lib/vterm_states.cpp Examining data/fbterm-1.7/src/mouse.cpp Examining data/fbterm-1.7/src/mouse.h Examining data/fbterm-1.7/src/screen.cpp Examining data/fbterm-1.7/src/screen.h Examining data/fbterm-1.7/src/screen_render.cpp Examining data/fbterm-1.7/src/signalfd.h Examining data/fbterm-1.7/src/vbe.h Examining data/fbterm-1.7/src/vesadev.cpp Examining data/fbterm-1.7/src/vesadev.h FINAL RESULTS: data/fbterm-1.7/src/improxy.cpp:107:3: [4] (shell) execlp: 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. execlp(app, app, NULL); data/fbterm-1.7/src/lib/shell.cpp:85:4: [4] (shell) execvp: 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. execvp(command[0], command); data/fbterm-1.7/src/lib/shell.cpp:88:15: [4] (shell) execlp: 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. if (shell) execlp(shell, shell, NULL); data/fbterm-1.7/src/lib/shell.cpp:91:4: [4] (shell) execlp: 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. execlp(userpd->pw_shell, userpd->pw_shell, NULL); data/fbterm-1.7/src/lib/shell.cpp:93:4: [4] (shell) execlp: 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. execlp("/bin/sh", "/bin/sh", NULL); data/fbterm-1.7/im/imapi.c:50:15: [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 *val = getenv("FBTERM_IM_SOCKET"); data/fbterm-1.7/src/fbconfig.cpp:41:19: [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. const s8 *home = getenv("HOME"); data/fbterm-1.7/src/fbconfig.cpp:247:18: [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 ((index = getopt_long(argc, argv, "Vvhn:s:f:b:e:r:i:a", options, 0)) != -1) { data/fbterm-1.7/src/fbdev.cpp:42:14: [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. s8 *fbdev = getenv("FRAMEBUFFER"); data/fbterm-1.7/src/lib/shell.cpp:87:16: [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. s8 *shell = getenv("SHELL"); data/fbterm-1.7/src/screen_render.cpp:75:6: [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. if (getenv("FBTERM_BACKGROUND_IMAGE")) { data/fbterm-1.7/im/imapi.c:33: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 pending_msg_buf[10240]; data/fbterm-1.7/im/imapi.c:77: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[OFFSET(Message, texts) + len]; data/fbterm-1.7/im/imapi.c:81: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(MSG(buf)->texts, text, len); data/fbterm-1.7/im/imapi.c:116: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[OFFSET(Message, drawText.texts) + len]; data/fbterm-1.7/im/imapi.c:125: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(MSG(buf)->drawText.texts, text, len); data/fbterm-1.7/im/imapi.c:235: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(cur, cur + MSG(cur)->len, end - cur - MSG(cur)->len); data/fbterm-1.7/im/imapi.c:256: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[sizeof(pending_msg_buf)]; data/fbterm-1.7/im/imapi.c:263: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(buf, pending_msg_buf, len); data/fbterm-1.7/im/keycode.c:30: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 key_down[NR_KEYS]; data/fbterm-1.7/im/keycode.c:31:17: [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 shift_down[NR_SHIFT]; data/fbterm-1.7/src/fbconfig.cpp:56:11: [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). s32 fd = open(name, O_RDONLY); data/fbterm-1.7/src/fbconfig.cpp:96: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(val, entry->val, len); data/fbterm-1.7/src/fbconfig.cpp:215:11: [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). s32 fd = open(name, O_WRONLY | O_CREAT, S_IRUSR | S_IWUSR); data/fbterm-1.7/src/fbdev.cpp:45:14: [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). fbdev_fd = open(fbdev, O_RDWR); data/fbterm-1.7/src/fbdev.cpp:47:14: [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). fbdev_fd = open("/dev/fb0", O_RDWR); data/fbterm-1.7/src/fbdev.cpp:48:32: [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). if (fbdev_fd < 0) fbdev_fd = open("/dev/fb/0", O_RDWR); data/fbterm-1.7/src/fbshell.cpp:522: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(mPalette, defaultPalette, sizeof(defaultPalette)); data/fbterm-1.7/src/fbshell.cpp:555:31: [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). if (tty0_fd == -1) tty0_fd = open("/dev/tty0", O_RDWR); data/fbterm-1.7/src/fbshell.cpp:560:18: [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). s32 slavefd = open(ptsname(fd()), O_RDWR); data/fbterm-1.7/src/immessage.h:168: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 keys[0]; ///< included in message SendKey data/fbterm-1.7/src/immessage.h:169: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 texts[0]; ///< included in message PutText data/fbterm-1.7/src/immessage.h:197: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 texts[0]; data/fbterm-1.7/src/improxy.cpp:193: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(MSG(buf)->keys, keys, len); data/fbterm-1.7/src/improxy.cpp:377: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(buf, m, m->len); data/fbterm-1.7/src/lib/io.cpp:51: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(local_codec, "UTF-8"); data/fbterm-1.7/src/lib/io.cpp:145: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(buf, mBufRead, mBufLenRead); data/fbterm-1.7/src/lib/io.cpp:218: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(bufleft, inptr, total); data/fbterm-1.7/src/lib/vterm.cpp:176: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(new_tab_stops, tab_stops, max_width / 8 + 1); data/fbterm-1.7/src/lib/vterm.cpp:217: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_text[new_start], &text[start], sizeof(*text) * max_width); data/fbterm-1.7/src/lib/vterm.cpp:218: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_attrs[new_start], &attrs[start], sizeof(*attrs) * max_width); data/fbterm-1.7/src/lib/vterm.cpp:229: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_text[new_start], &text[start], sizeof(*text) * max_width); data/fbterm-1.7/src/lib/vterm.cpp:230: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_attrs[new_start], &attrs[start], sizeof(*attrs) * max_width); data/fbterm-1.7/src/lib/vterm.cpp:758: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(&text[yp_history], &text[yp], sizeof(*text) * width); data/fbterm-1.7/src/lib/vterm.cpp:759: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(&attrs[yp_history], &attrs[yp], sizeof(*attrs) * width); data/fbterm-1.7/src/screen_render.cpp:86: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(bgimage_mem, mVMemBase, size); data/fbterm-1.7/src/screen_render.cpp:136: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(mVMemBase + offset, bgimage_mem + offset, w * bytes_per_pixel); data/fbterm-1.7/src/vbe.h:55: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 vbe_signature[4]; data/fbterm-1.7/src/vbe.h:70: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 reserved[222]; data/fbterm-1.7/src/vbe.h:71: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 oem_data[256]; data/fbterm-1.7/src/vbe.h:124: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 res2[189]; data/fbterm-1.7/src/vesadev.cpp:91: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(state_buf, buf, state_size); data/fbterm-1.7/src/vesadev.cpp:97: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(buf, state_buf, state_size); data/fbterm-1.7/src/vesadev.cpp:141: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(info->vbe_signature, "VBE2", 4); data/fbterm-1.7/src/vesadev.cpp:286: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). s32 fd = open("/dev/mem", O_RDWR); data/fbterm-1.7/im/example.c:62: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). put_im_text(str, strlen(str)); data/fbterm-1.7/im/imapi.c:221:13: [1] (buffer) read: Check buffer boundaries if used in a loop including recursive loops (CWE-120, CWE-20). int len = read(imfd, cur, sizeof(pending_msg_buf) - pending_msg_buf_len); data/fbterm-1.7/im/imapi.c:267:8: [1] (buffer) read: Check buffer boundaries if used in a loop including recursive loops (CWE-120, CWE-20). len = read(imfd, buf, sizeof(buf)); data/fbterm-1.7/im/keycode.c:213:11: [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). index = strlen(buf); data/fbterm-1.7/src/fbconfig.cpp:62:12: [1] (buffer) read: Check buffer boundaries if used in a loop including recursive loops (CWE-120, CWE-20). s32 ret = read(fd, mConfigBuf, cstat.st_size); data/fbterm-1.7/src/fbconfig.cpp:94:16: [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). u32 val_len = strlen(entry->val); data/fbterm-1.7/src/fbconfig.cpp:144:30: [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). s8 *cur = str, *end = str + strlen(str) - 1; data/fbterm-1.7/src/fbshell.cpp:725: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). s32 ret = ::write(STDIN_FILENO, str, strlen(str)); data/fbterm-1.7/src/improxy.cpp:452:28: [1] (buffer) read: Check buffer boundaries if used in a loop including recursive loops (CWE-120, CWE-20). void ImProxy::ioError(bool read, s32 err) data/fbterm-1.7/src/improxy.cpp:454:6: [1] (buffer) read: Check buffer boundaries if used in a loop including recursive loops (CWE-120, CWE-20). if (read && mMsgWaitState == WaitingMessage) mMsgWaitState = GotMessage; data/fbterm-1.7/src/improxy.h:46:28: [1] (buffer) read: Check buffer boundaries if used in a loop including recursive loops (CWE-120, CWE-20). virtual void ioError(bool read, s32 err); data/fbterm-1.7/src/lib/io.cpp:53:4: [1] (buffer) strncpy: Easily used incorrectly; doesn't always \0-terminate or check for invalid pointers [MS-banned] (CWE-120). strncpy(local_codec, nl_langinfo(CODESET), sizeof(local_codec) - 1); data/fbterm-1.7/src/lib/io.cpp:135:12: [1] (buffer) read: Check buffer boundaries if used in a loop including recursive loops (CWE-120, CWE-20). s32 len = read(mFd, buf + mBufLenRead, sizeof(buf) - mBufLenRead); data/fbterm-1.7/src/lib/io.h:43:28: [1] (buffer) read: Check buffer boundaries if used in a loop including recursive loops (CWE-120, CWE-20). virtual void ioError(bool read, s32 err) {} data/fbterm-1.7/src/lib/shell.cpp:46:3: [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. usleep(100 * 1000); data/fbterm-1.7/src/lib/shell.cpp:115: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). write((s8*)data, strlen(data)); data/fbterm-1.7/src/mouse.cpp:45: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). u32 index = strlen(buf) - 1; data/fbterm-1.7/src/mouse.cpp:60:2: [1] (buffer) strncpy: Easily used incorrectly; doesn't always \0-terminate or check for invalid pointers [MS-banned] (CWE-120). strncpy(addr.sun_path, GPM_NODE_CTL, sizeof(addr.sun_path) - 1); ANALYSIS SUMMARY: Hits = 73 Lines analyzed = 9568 in approximately 0.27 seconds (35165 lines/second) Physical Source Lines of Code (SLOC) = 6819 Hits@level = [0] 29 [1] 18 [2] 44 [3] 6 [4] 5 [5] 0 Hits@level+ = [0+] 102 [1+] 73 [2+] 55 [3+] 11 [4+] 5 [5+] 0 Hits/KSLOC@level+ = [0+] 14.9582 [1+] 10.7054 [2+] 8.0657 [3+] 1.61314 [4+] 0.733245 [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.