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/xsettings-kde-0.9/xsettings-common.c Examining data/xsettings-kde-0.9/xsettings-manager.c Examining data/xsettings-kde-0.9/xsettings-common.h Examining data/xsettings-kde-0.9/xsettings-manager.h Examining data/xsettings-kde-0.9/xsettings-kde.c FINAL RESULTS: data/xsettings-kde-0.9/xsettings-kde.c:105:3: [4] (buffer) sprintf: Does not check for buffer overflows (CWE-120). Use sprintf_s, snprintf, or vsnprintf. sprintf(search_string, "%s=%%s", key); data/xsettings-kde-0.9/xsettings-kde.c:106:7: [4] (buffer) sscanf: The scanf() family's %s operation, without a limit specification, permits buffer overflows (CWE-120, CWE-20). Specify a limit to %s, or use a different input function. If the scanf format is influenceable by an attacker, it's exploitable. if (sscanf (buffer, search_string, tmp_string) >= 0) { data/xsettings-kde-0.9/xsettings-kde.c:122:3: [4] (buffer) sprintf: Does not check for buffer overflows (CWE-120). Use sprintf_s, snprintf, or vsnprintf. sprintf(search_string, "%s=%%d", key); data/xsettings-kde-0.9/xsettings-kde.c:123:7: [4] (buffer) sscanf: The scanf() family's %s operation, without a limit specification, permits buffer overflows (CWE-120, CWE-20). Specify a limit to %s, or use a different input function. If the scanf format is influenceable by an attacker, it's exploitable. if (sscanf (buffer, search_string, &tmp_int) >= 0) { data/xsettings-kde-0.9/xsettings-kde.c:139:3: [4] (buffer) sprintf: Does not check for buffer overflows (CWE-120). Use sprintf_s, snprintf, or vsnprintf. sprintf(search_string, "%s=%%s", key); data/xsettings-kde-0.9/xsettings-kde.c:140:7: [4] (buffer) sscanf: The scanf() family's %s operation, without a limit specification, permits buffer overflows (CWE-120, CWE-20). Specify a limit to %s, or use a different input function. If the scanf format is influenceable by an attacker, it's exploitable. if (sscanf (buffer, search_string, &tmp_string) >= 0) { data/xsettings-kde-0.9/xsettings-kde.c:195:10: [4] (buffer) sscanf: The scanf() family's %s operation, without a limit specification, permits buffer overflows (CWE-120, CWE-20). Specify a limit to %s, or use a different input function. if (sscanf (buffer, "prefixes=%s", tmp_string) >= 0) { data/xsettings-kde-0.9/xsettings-kde.c:196:7: [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(kdeprefix, tmp_string); data/xsettings-kde-0.9/xsettings-kde.c:221:6: [4] (buffer) sprintf: Does not check for buffer overflows (CWE-120). Use sprintf_s, snprintf, or vsnprintf. sprintf(filename, "%s/share/config/%s",prefix, file_name[file_index]); data/xsettings-kde-0.9/xsettings-kde.c:222:10: [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 (filename, F_OK) == 0) { data/xsettings-kde-0.9/xsettings-kde.c:235:4: [4] (buffer) sprintf: Does not check for buffer overflows (CWE-120). Use sprintf_s, snprintf, or vsnprintf. sprintf(filename, "%s/%s/share/config/%s",password->pw_dir, is_kde4 ? ".kde4" : ".kde", file_name[file_index]); data/xsettings-kde-0.9/xsettings-kde.c:237:8: [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 (filename, F_OK) == 0) { data/xsettings-kde-0.9/xsettings-kde.c:297:6: [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(color, buffer+12); data/xsettings-kde-0.9/xsettings-kde.c:310:6: [4] (buffer) sprintf: Does not check for buffer overflows (CWE-120). Use sprintf_s, snprintf, or vsnprintf. sprintf(fontname, "%s %s",font,size); data/xsettings-kde-0.9/xsettings-kde.c:319:6: [4] (buffer) sscanf: The scanf() family's %s operation, without a limit specification, permits buffer overflows (CWE-120, CWE-20). Specify a limit to %s, or use a different input function. sscanf(buffer,"widgetStyle=%s", style); data/xsettings-kde-0.9/xsettings-kde.c:331:14: [4] (buffer) sscanf: The scanf() family's %s operation, without a limit specification, permits buffer overflows (CWE-120, CWE-20). Specify a limit to %s, or use a different input function. found = sscanf(buffer,"IconText=%s", toolbar); data/xsettings-kde-0.9/xsettings-kde.c:380:3: [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(style, color); data/xsettings-kde-0.9/xsettings-kde.c:388:3: [4] (buffer) sprintf: Does not check for buffer overflows (CWE-120). Use sprintf_s, snprintf, or vsnprintf. sprintf(themefilename, "/usr/share/themes/%s/gtk-2.0/gtkrc", style); data/xsettings-kde-0.9/xsettings-kde.c:392:4: [4] (buffer) sprintf: Does not check for buffer overflows (CWE-120). Use sprintf_s, snprintf, or vsnprintf. sprintf(gtkrc,"%s/.gtkrc-2.0", password->pw_dir); data/xsettings-kde-0.9/xsettings-kde.c:393:19: [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. gtkrc_access = access (gtkrc, F_OK); data/xsettings-kde-0.9/xsettings-kde.c:411:28: [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 ((gtkrc_access = access (gtkrc_file, F_OK)) == 0) { data/xsettings-kde-0.9/xsettings-kde.c:421:24: [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 (gtkrc_access && (access (themefilename, F_OK) == 0 )) { data/xsettings-kde-0.9/xsettings-kde.c:399:17: [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. gtkrc_env = getenv ("GTK2_RC_FILES"); data/xsettings-kde-0.9/xsettings-kde.c:448: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. kde_version = getenv("KDE_SESSION_VERSION"); data/xsettings-kde-0.9/xsettings-common.c:46: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 (result->name, setting->name, str_len + 1); data/xsettings-kde-0.9/xsettings-common.c:64:7: [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 (result->data.v_string, setting->data.v_string, str_len + 1); data/xsettings-kde-0.9/xsettings-kde.c:80: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 * atom_names [2] = { data/xsettings-kde-0.9/xsettings-kde.c:95: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 * file_name [2] = { data/xsettings-kde-0.9/xsettings-kde.c:102: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 tmp_string[1024]; data/xsettings-kde-0.9/xsettings-kde.c:103: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 search_string[1024]; data/xsettings-kde-0.9/xsettings-kde.c:120: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 search_string[1024]; data/xsettings-kde-0.9/xsettings-kde.c:136: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 tmp_string[1024]; data/xsettings-kde-0.9/xsettings-kde.c:137: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 search_string[1024]; data/xsettings-kde-0.9/xsettings-kde.c:166: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[1024]; data/xsettings-kde-0.9/xsettings-kde.c:167: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 kdeprefix[1024]; data/xsettings-kde-0.9/xsettings-kde.c:169: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 color[1024]; data/xsettings-kde-0.9/xsettings-kde.c:170: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 style[1024]; data/xsettings-kde-0.9/xsettings-kde.c:171: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 themefilename[1024]; data/xsettings-kde-0.9/xsettings-kde.c:183: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 = fopen (is_kde4 ? "/etc/kde4rc" : "/etc/kderc", "r"); data/xsettings-kde-0.9/xsettings-kde.c:186: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 tmp_string[1024]; data/xsettings-kde-0.9/xsettings-kde.c:223:14: [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 = fopen (filename, "r"); data/xsettings-kde-0.9/xsettings-kde.c:238:12: [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 = fopen (filename, "r"); data/xsettings-kde-0.9/xsettings-kde.c:304:6: [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 font[1024]; data/xsettings-kde-0.9/xsettings-kde.c:305:6: [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 size[1024]; data/xsettings-kde-0.9/xsettings-kde.c:306:6: [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 fontname[1024]; data/xsettings-kde-0.9/xsettings-kde.c:327:6: [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 toolbar[1024]; data/xsettings-kde-0.9/xsettings-kde.c:391: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 gtkrc[1024]; data/xsettings-kde-0.9/xsettings-manager.c:107: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 buffer[256]; data/xsettings-kde-0.9/xsettings-manager.c:110:3: [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(buffer, "_XSETTINGS_S%d", screen); data/xsettings-kde-0.9/xsettings-manager.c:129: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 buffer[256]; data/xsettings-kde-0.9/xsettings-manager.c:138:3: [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(buffer, "_XSETTINGS_S%d", screen); data/xsettings-kde-0.9/xsettings-manager.c:335: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 (buffer->pos, setting->name, string_len); data/xsettings-kde-0.9/xsettings-manager.c:360:7: [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->pos, setting->data.v_string, string_len); data/xsettings-kde-0.9/xsettings-common.c:41: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). str_len = strlen (setting->name); data/xsettings-kde-0.9/xsettings-common.c:59: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). str_len = strlen (setting->data.v_string); data/xsettings-kde-0.9/xsettings-kde.c:101: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). if (strncmp (buffer, key, strlen (key)) == 0) { data/xsettings-kde-0.9/xsettings-kde.c:118: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). if (strncmp (buffer, key, strlen (key)) == 0) { data/xsettings-kde-0.9/xsettings-kde.c:135: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). if (strncmp (buffer, key, strlen (key)) == 0) { data/xsettings-kde-0.9/xsettings-kde.c:163:18: [1] (buffer) read: Check buffer boundaries if used in a loop including recursive loops (CWE-120, CWE-20). size_t len = 0, read; data/xsettings-kde-0.9/xsettings-kde.c:298:12: [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). color[strlen(color)-1]='\0'; data/xsettings-kde-0.9/xsettings-kde.c:382: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). style[strlen(style)-6] = '\0'; data/xsettings-kde-0.9/xsettings-manager.c:302: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). length += XSETTINGS_PAD (strlen (setting->name), 4); data/xsettings-kde-0.9/xsettings-manager.c:310:36: [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). length += 4 + XSETTINGS_PAD (strlen (setting->data.v_string), 4); data/xsettings-kde-0.9/xsettings-manager.c:330: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). string_len = strlen (setting->name); data/xsettings-kde-0.9/xsettings-manager.c:355: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). string_len = strlen (setting->data.v_string); ANALYSIS SUMMARY: Hits = 65 Lines analyzed = 1418 in approximately 0.06 seconds (25653 lines/second) Physical Source Lines of Code (SLOC) = 1008 Hits@level = [0] 4 [1] 12 [2] 29 [3] 2 [4] 22 [5] 0 Hits@level+ = [0+] 69 [1+] 65 [2+] 53 [3+] 24 [4+] 22 [5+] 0 Hits/KSLOC@level+ = [0+] 68.4524 [1+] 64.4841 [2+] 52.5794 [3+] 23.8095 [4+] 21.8254 [5+] 0 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.