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/plr-8.4.1/pg_backend_support.c Examining data/plr-8.4.1/pg_conversion.c Examining data/plr-8.4.1/pg_rsupport.c Examining data/plr-8.4.1/pg_userfuncs.c Examining data/plr-8.4.1/plr.c Examining data/plr-8.4.1/plr.h FINAL RESULTS: data/plr-8.4.1/pg_backend_support.c:261:2: [4] (buffer) sprintf: Does not check for buffer overflows (CWE-120). Use sprintf_s, snprintf, or vsnprintf. sprintf(buf, "dyn.load(\"%s\")", libstr); data/plr-8.4.1/pg_backend_support.c:330:2: [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(new, name); data/plr-8.4.1/pg_backend_support.c:331:2: [4] (buffer) strcat: Does not check for buffer overflows when concatenating to destination [MS-banned] (CWE-120). Consider using strcat_s, strncat, strlcat, or snprintf (warning: strncat is easily misused). strcat(new, DLSUFFIX); data/plr-8.4.1/pg_backend_support.c:380:2: [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(ret, pkglib_path); data/plr-8.4.1/pg_backend_support.c:381:2: [4] (buffer) strcat: Does not check for buffer overflows when concatenating to destination [MS-banned] (CWE-120). Consider using strcat_s, strncat, strlcat, or snprintf (warning: strncat is easily misused). strcat(ret, sep_ptr); data/plr-8.4.1/pg_backend_support.c:441:3: [4] (buffer) sprintf: Does not check for buffer overflows (CWE-120). Use sprintf_s, snprintf, or vsnprintf. sprintf(full, "%s/%s", mangled, basename); data/plr-8.4.1/pg_rsupport.c:182: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(buf, sizeof(buf), UINT64_FORMAT, SPI_processed); data/plr-8.4.1/pg_rsupport.c:544: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(buf, sizeof(buf), UINT64_FORMAT, SPI_processed); data/plr-8.4.1/pg_userfuncs.c:453:3: [4] (buffer) sprintf: Does not check for buffer overflows (CWE-120). Use sprintf_s, snprintf, or vsnprintf. sprintf(rhenv, "R_HOME=%s", rhome); data/plr-8.4.1/pg_userfuncs.c:498:3: [4] (buffer) sprintf: Does not check for buffer overflows (CWE-120). Use sprintf_s, snprintf, or vsnprintf. sprintf(denv, "DISPLAY=%s", display); data/plr-8.4.1/plr.c:335:2: [4] (buffer) sprintf: Does not check for buffer overflows (CWE-120). Use sprintf_s, snprintf, or vsnprintf. sprintf(body, "{%s}", proc_source); data/plr-8.4.1/plr.c:409:3: [4] (buffer) sprintf: Does not check for buffer overflows (CWE-120). Use sprintf_s, snprintf, or vsnprintf. sprintf(buf, "rm -rf \"%s\"", tmpdir); data/plr-8.4.1/plr.c:412:8: [4] (shell) system: 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. rv = system(buf); data/plr-8.4.1/plr.c:470:4: [4] (buffer) sprintf: Does not check for buffer overflows (CWE-120). Use sprintf_s, snprintf, or vsnprintf. sprintf(rhenv, "R_HOME=%s", R_HOME_DEFAULT); data/plr-8.4.1/plr.c:904:3: [4] (format) sprintf: Potential format string problem (CWE-134). Make format string constant. sprintf(internal_env, PLR_WINDOW_ENV_PATTERN, winobj); data/plr-8.4.1/plr.c:394: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. char *tmpdir = getenv("R_SESSION_TMPDIR"); data/plr-8.4.1/plr.c:453:11: [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. r_home = getenv("R_HOME"); data/plr-8.4.1/pg_backend_support.c:361: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 pkglib_path[MAXPGPATH]; data/plr-8.4.1/pg_conversion.c:100: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((char *) RAW(obj), data/plr-8.4.1/pg_conversion.c:204: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(INTEGER_DATA(result), p, nitems * sizeof(int)); data/plr-8.4.1/pg_conversion.c:208: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(NUMERIC_DATA(result), p, nitems * sizeof(double)); data/plr-8.4.1/pg_conversion.c:430: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[256]; data/plr-8.4.1/pg_conversion.c:534: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(buf, "%d", i+1); data/plr-8.4.1/pg_conversion.c:602:33: [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). INTEGER_DATA(*obj)[elnum] = atoi(value); data/plr-8.4.1/pg_conversion.c:1095: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(rptr, (char *) RAW(obj), rsize - VARHDRSZ); data/plr-8.4.1/pg_conversion.c:1717: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(ARR_DIMS(array), dims, ndims * sizeof(int)); data/plr-8.4.1/pg_conversion.c:1718: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(ARR_LBOUND(array), lbs, ndims * sizeof(int)); data/plr-8.4.1/pg_conversion.c:1719: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(ARR_DATA_PTR(array), dvalues, nbytes); data/plr-8.4.1/pg_rsupport.c:131: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[64]; data/plr-8.4.1/pg_rsupport.c:368:3: [2] (buffer) char: Statically-sized arrays can be improperly restricted, leading to potential overflows or other issues (CWE-119!/CWE-120). Perform bounds checking, use functions that limit length, or ensure that the size is larger than the maximum possible length. char buf[128]; data/plr-8.4.1/pg_rsupport.c:411:3: [2] (buffer) char: Statically-sized arrays can be improperly restricted, leading to potential overflows or other issues (CWE-119!/CWE-120). Perform bounds checking, use functions that limit length, or ensure that the size is larger than the maximum possible length. char buf[128]; data/plr-8.4.1/pg_rsupport.c:470: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[64]; data/plr-8.4.1/pg_rsupport.c:637: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 cursor_name[64]; data/plr-8.4.1/pg_userfuncs.c:298: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 *values[2]; data/plr-8.4.1/pg_userfuncs.c:354: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(var_name, *current_env, name_len); data/plr-8.4.1/pg_userfuncs.c:391: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(var_name, buf, name_len); data/plr-8.4.1/pg_userfuncs.c:525: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((char *) RAW(obj), VARDATA(bvalue), VARSIZE(bvalue)); data/plr-8.4.1/pg_userfuncs.c:556: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(brptr, (char *) RAW(result), rsize - VARHDRSZ); data/plr-8.4.1/plr.c:884: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 internal_env[PLR_WINDOW_ENV_NAME_MAX_LENGTH]; data/plr-8.4.1/plr.c:1088: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 internal_proname[MAX_PRONAME_LEN]; data/plr-8.4.1/plr.c:1107:2: [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(internal_proname, "PLR%u", fn_oid); data/plr-8.4.1/plr.h:351: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((char *) dtrigtup, (char *) tup->t_data, tup->t_len); \ data/plr-8.4.1/plr.h:364: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((char *) dtrigtup, (char *) tup->t_data, tup->t_len); \ data/plr-8.4.1/plr.h:375: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((char *) dnewtup, (char *) tup->t_data, tup->t_len); \ data/plr-8.4.1/plr.h:382: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((char *) dtrigtup, (char *) tup->t_data, tup->t_len); \ data/plr-8.4.1/plr.h:489: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 arg_elem_typalign[FUNC_MAX_ARGS]; data/plr-8.4.1/pg_backend_support.c:227: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). size_t len = strlen(raw_path); data/plr-8.4.1/pg_backend_support.c:256: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). buf = (char *) palloc(strlen(libstr) + 12 + 1); data/plr-8.4.1/pg_backend_support.c:329: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). new = palloc(strlen(name) + strlen(DLSUFFIX) + 1); data/plr-8.4.1/pg_backend_support.c:329: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). new = palloc(strlen(name) + strlen(DLSUFFIX) + 1); data/plr-8.4.1/pg_backend_support.c:370: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). sep_ptr = name + strlen(name); data/plr-8.4.1/pg_backend_support.c:372:6: [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("$libdir") != sep_ptr - name || data/plr-8.4.1/pg_backend_support.c:373: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). strncmp(name, "$libdir", strlen("$libdir")) != 0) data/plr-8.4.1/pg_backend_support.c:378: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). ret = palloc(strlen(pkglib_path) + strlen(sep_ptr) + 1); data/plr-8.4.1/pg_backend_support.c:378: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). ret = palloc(strlen(pkglib_path) + strlen(sep_ptr) + 1); data/plr-8.4.1/pg_backend_support.c:408:6: [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(p) == 0) data/plr-8.4.1/pg_backend_support.c:411: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). baselen = strlen(basename); data/plr-8.4.1/pg_backend_support.c:428:3: [1] (buffer) strncpy: Easily used incorrectly; doesn't always \0-terminate or check for invalid pointers [MS-banned] (CWE-120). strncpy(piece, p, len); data/plr-8.4.1/pg_backend_support.c:440: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). full = palloc(strlen(mangled) + 1 + baselen + 1); data/plr-8.4.1/pg_rsupport.c:670:2: [1] (buffer) strncpy: Easily used incorrectly; doesn't always \0-terminate or check for invalid pointers [MS-banned] (CWE-120). strncpy(cursor_name, CHAR(STRING_ELT(cursor_name_arg,0)), 64); data/plr-8.4.1/pg_userfuncs.c:441: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). size_t rh_len = strlen(rhome); data/plr-8.4.1/pg_userfuncs.c:486: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). size_t d_len = strlen(display); data/plr-8.4.1/plr.c:330: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). body = (char *) palloc(strlen(proc_source) + 3); /* {}\x00 */ data/plr-8.4.1/plr.c:408:33: [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). buf = (char *) palloc(9 + 1 + strlen(tmpdir)); data/plr-8.4.1/plr.c:457: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). size_t rh_len = strlen(R_HOME_DEFAULT); data/plr-8.4.1/plr.h:199: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). for (i = 0; i < strlen(names_buf); i++) { \ ANALYSIS SUMMARY: Hits = 66 Lines analyzed = 6528 in approximately 0.16 seconds (41904 lines/second) Physical Source Lines of Code (SLOC) = 4570 Hits@level = [0] 6 [1] 20 [2] 29 [3] 2 [4] 15 [5] 0 Hits@level+ = [0+] 72 [1+] 66 [2+] 46 [3+] 17 [4+] 15 [5+] 0 Hits/KSLOC@level+ = [0+] 15.7549 [1+] 14.442 [2+] 10.0656 [3+] 3.71991 [4+] 3.28228 [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.