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/python-cups-2.0.1/cupsconnection.c Examining data/python-cups-2.0.1/cupsconnection.h Examining data/python-cups-2.0.1/cupsipp.c Examining data/python-cups-2.0.1/cupsipp.h Examining data/python-cups-2.0.1/cupsmodule.c Examining data/python-cups-2.0.1/cupsmodule.h Examining data/python-cups-2.0.1/cupsppd.c Examining data/python-cups-2.0.1/cupsppd.h FINAL RESULTS: data/python-cups-2.0.1/cupsconnection.c:137: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 (buffer, base); data/python-cups-2.0.1/cupsconnection.c:3078: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 (opt + optionlen, suffix); data/python-cups-2.0.1/cupsconnection.c:3153: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 (opt + optionlen, suffix); data/python-cups-2.0.1/cupsconnection.c:3767: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 (fname, filename); data/python-cups-2.0.1/cupsconnection.c:3864:2: [4] (format) snprintf: 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. snprintf (filename, sizeof (filename), *pattern, datadir); data/python-cups-2.0.1/cupsconnection.c:3865: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 (filename, R_OK) == 0) data/python-cups-2.0.1/cupsconnection.c:3877:4: [4] (format) snprintf: 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. snprintf (filename, sizeof (filename), *pattern, datadir); data/python-cups-2.0.1/cupsconnection.c:3878: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, R_OK) == 0) { data/python-cups-2.0.1/cupsconnection.c:3894:2: [4] (format) snprintf: 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. snprintf (filename, sizeof (filename), testprint[0], dirs[0]); data/python-cups-2.0.1/cupsmodule.c:1268:5: [4] (format) vfprintf: If format strings can be influenced by an attacker, they can be exploited (CWE-134). Use a constant for the format specification. vfprintf (stderr, fmt, ap); data/python-cups-2.0.1/cupsconnection.c:3861:20: [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 ((datadir = getenv ("CUPS_DATADIR")) != NULL) { data/python-cups-2.0.1/cupsmodule.c:1256:12: [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 (ENVAR)) data/python-cups-2.0.1/cupsconnection.c:306: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/python-cups-2.0.1/cupsconnection.c:431: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 uri[HTTP_MAX_URI]; data/python-cups-2.0.1/cupsconnection.c:618: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 unknown[100]; data/python-cups-2.0.1/cupsconnection.c:1220: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 docfilename[PATH_MAX]; data/python-cups-2.0.1/cupsconnection.c:1240:8: [2] (tmpfile) mkstemp: Potential for temporary file vulnerability in some circumstances. Some older Unix-like systems create temp files with permission to write by all by default, so be sure to set the umask to override this. Also, some older Unix systems might fail to use O_EXCL when opening the file, so make sure that O_EXCL is used by the library (CWE-377). fd = mkstemp (docfilename); data/python-cups-2.0.1/cupsconnection.c:1659: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 uri[1024]; data/python-cups-2.0.1/cupsconnection.c:1725: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 uri[1024]; data/python-cups-2.0.1/cupsconnection.c:1763: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 consuri[HTTP_MAX_URI]; data/python-cups-2.0.1/cupsconnection.c:1987: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, PyBytes_AsString(buffer_obj), length); data/python-cups-2.0.1/cupsconnection.c:2077:5: [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 joburi[HTTP_MAX_URI]; data/python-cups-2.0.1/cupsconnection.c:2116: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 *auth_info_values[3]; data/python-cups-2.0.1/cupsconnection.c:2118: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 uri[1024]; data/python-cups-2.0.1/cupsconnection.c:2183: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 uri[1024]; data/python-cups-2.0.1/cupsconnection.c:2228: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 uri[1024]; data/python-cups-2.0.1/cupsconnection.c:2359: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 uri[HTTP_MAX_URI]; data/python-cups-2.0.1/cupsconnection.c:2370: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 uri[HTTP_MAX_URI]; data/python-cups-2.0.1/cupsconnection.c:2458:5: [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 template[PATH_MAX]; data/python-cups-2.0.1/cupsconnection.c:2464:10: [2] (tmpfile) mkstemp: Potential for temporary file vulnerability in some circumstances. Some older Unix-like systems create temp files with permission to write by all by default, so be sure to set the umask to override this. Also, some older Unix systems might fail to use O_EXCL when opening the file, so make sure that O_EXCL is used by the library (CWE-377). fd = mkstemp (ppdfile); data/python-cups-2.0.1/cupsconnection.c:3030: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 string[BUFSIZ]; data/python-cups-2.0.1/cupsconnection.c:3077: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 (opt, option, optionlen); data/python-cups-2.0.1/cupsconnection.c:3152: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 (opt, option, optionlen); data/python-cups-2.0.1/cupsconnection.c:3208: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 consuri[HTTP_MAX_URI]; data/python-cups-2.0.1/cupsconnection.c:3400: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 classuri[HTTP_MAX_URI]; data/python-cups-2.0.1/cupsconnection.c:3401: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 printeruri[HTTP_MAX_URI]; data/python-cups-2.0.1/cupsconnection.c:3504: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 classuri[HTTP_MAX_URI]; data/python-cups-2.0.1/cupsconnection.c:3608: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 classuri[HTTP_MAX_URI]; data/python-cups-2.0.1/cupsconnection.c:3733: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 fname[PATH_MAX]; data/python-cups-2.0.1/cupsconnection.c:3828: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 filename[PATH_MAX]; data/python-cups-2.0.1/cupsconnection.c:3829: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 uri[HTTP_MAX_URI]; data/python-cups-2.0.1/cupsconnection.c:3970: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 ppdfile[1024]; data/python-cups-2.0.1/cupsconnection.c:3971:9: [2] (tmpfile) tmpfile: Function tmpfile() has a security flaw on some systems (e.g., older System V systems) (CWE-377). FILE *tmpfile(void); data/python-cups-2.0.1/cupsconnection.c:3973: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 str[80]; data/python-cups-2.0.1/cupsconnection.c:4000:8: [2] (tmpfile) tmpfile: Function tmpfile() has a security flaw on some systems (e.g., older System V systems) (CWE-377). tf = tmpfile(); data/python-cups-2.0.1/cupsconnection.c:5593: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/python-cups-2.0.1/cupsipp.c:147: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[1024]; data/python-cups-2.0.1/cupsipp.c:507: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. ((char *)values)[i] = (item == Py_True ? 1 : 0); data/python-cups-2.0.1/cupsipp.c:526: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. ((char **)values)[i] = str; data/python-cups-2.0.1/cupsipp.c:533:10: [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. free (((char **)values)[j]); data/python-cups-2.0.1/cupsipp.c:546: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. free (((char **)values)[i]); data/python-cups-2.0.1/cupsipp.c:600: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 (buffer, gotbuffer, got); data/python-cups-2.0.1/cupsmodule.c:449: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 resource[HTTP_MAX_URI]; data/python-cups-2.0.1/cupsppd.c:223: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). self->file = fopen (filename, "r"); data/python-cups-2.0.1/cupsppd.c:1124: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/python-cups-2.0.1/cupsppd.c:1363: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/python-cups-2.0.1/cupsppd.c:1704: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/python-cups-2.0.1/cupsconnection.c:74:43: [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). PyObject *val = PyUnicode_Decode (utf8, strlen (utf8), "utf-8", NULL); data/python-cups-2.0.1/cupsconnection.c:85: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). ascii = malloc (1 + strlen (orig)); data/python-cups-2.0.1/cupsconnection.c:136:7: [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 (base) < buflen) { data/python-cups-2.0.1/cupsconnection.c:138: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). d += strlen (base); data/python-cups-2.0.1/cupsconnection.c:140:5: [1] (buffer) strncpy: Easily used incorrectly; doesn't always \0-terminate or check for invalid pointers [MS-banned] (CWE-120). strncpy (buffer, base, buflen); data/python-cups-2.0.1/cupsconnection.c:3075: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). optionlen = strlen (option); data/python-cups-2.0.1/cupsconnection.c:3150: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). optionlen = strlen (option); data/python-cups-2.0.1/cupsconnection.c:3305: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). size_t namelen = strlen (ippGetName (attr)); data/python-cups-2.0.1/cupsconnection.c:3761:9: [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 (filename) > sizeof (fname)) { data/python-cups-2.0.1/cupsconnection.c:3908: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). resource = uri + strlen ("ipp://localhost"); data/python-cups-2.0.1/cupsconnection.c:4016: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). if (str[strlen(str) -1] == '\n') { data/python-cups-2.0.1/cupsconnection.c:4017: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). str[strlen(str) -1] = '\0'; data/python-cups-2.0.1/cupsipp.c:346:7: [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). strlen (ippGetString (attr, i, NULL)), data/python-cups-2.0.1/cupsppd.c:144:51: [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). return cautious_PyUnicode_DecodeUTF8 (ppdstr, strlen (ppdstr)); data/python-cups-2.0.1/cupsppd.c:150:9: [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 (ppdstr); // CUPS doesn't keep track of string lengths data/python-cups-2.0.1/cupsppd.c:178:9: [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 (inbuf); data/python-cups-2.0.1/cupsppd.c:580: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). return (strlen(*line)); data/python-cups-2.0.1/cupsppd.c:776:7: [1] (buffer) strncpy: Easily used incorrectly; doesn't always \0-terminate or check for invalid pointers [MS-banned] (CWE-120). strncpy(keyword, start, end - start); ANALYSIS SUMMARY: Hits = 75 Lines analyzed = 9930 in approximately 0.24 seconds (41494 lines/second) Physical Source Lines of Code (SLOC) = 8275 Hits@level = [0] 19 [1] 18 [2] 45 [3] 2 [4] 10 [5] 0 Hits@level+ = [0+] 94 [1+] 75 [2+] 57 [3+] 12 [4+] 10 [5+] 0 Hits/KSLOC@level+ = [0+] 11.3595 [1+] 9.06344 [2+] 6.88822 [3+] 1.45015 [4+] 1.20846 [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.