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/r-cran-rpostgresql-0.6-2+dfsg/src/S4R.h Examining data/r-cran-rpostgresql-0.6-2+dfsg/src/RS-pgsql-pqexec.c Examining data/r-cran-rpostgresql-0.6-2+dfsg/src/RS-DBI.h Examining data/r-cran-rpostgresql-0.6-2+dfsg/src/RS-pgsql-getResult.c Examining data/r-cran-rpostgresql-0.6-2+dfsg/src/RS-PostgreSQL.h Examining data/r-cran-rpostgresql-0.6-2+dfsg/src/RS-pgsql-pqexecparams.c Examining data/r-cran-rpostgresql-0.6-2+dfsg/src/RS-pgsql-copy.c Examining data/r-cran-rpostgresql-0.6-2+dfsg/src/RS-PQescape.c Examining data/r-cran-rpostgresql-0.6-2+dfsg/src/RS-DBI.c Examining data/r-cran-rpostgresql-0.6-2+dfsg/src/RS-PostgreSQL.c FINAL RESULTS: data/r-cran-rpostgresql-0.6-2+dfsg/src/RS-DBI.c:155:16: [4] (format) sprintf: Potential format string problem (CWE-134). Make format string constant. (void) sprintf(buf, msg, (int) mgr->length); data/r-cran-rpostgresql-0.6-2+dfsg/src/RS-DBI.c:279:16: [4] (format) sprintf: Potential format string problem (CWE-134). Make format string constant. (void) sprintf(msg, fmt, con->length); data/r-cran-rpostgresql-0.6-2+dfsg/src/RS-DBI.c:625:12: [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). return strcpy(buffer, str); data/r-cran-rpostgresql-0.6-2+dfsg/src/RS-DBI.c:734:17: [4] (buffer) sprintf: Does not check for buffer overflows (CWE-120). Use sprintf_s, snprintf, or vsnprintf. sprintf(msg,"unsupported data type in createNamedList: %i in list %i (%s)", types[j], j, names[j]); data/r-cran-rpostgresql-0.6-2+dfsg/src/RS-DBI.c:1184:20: [4] (buffer) sprintf: Does not check for buffer overflows (CWE-120). Use sprintf_s, snprintf, or vsnprintf. (void) sprintf(errMsg, "SQL identifier %s longer than %d chars", name, RS_DBI_MAX_IDENTIFIER_LENGTH); data/r-cran-rpostgresql-0.6-2+dfsg/src/RS-PostgreSQL.c:1527:9: [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(buff, LST_CHR_EL(data, group_field, i)); data/r-cran-rpostgresql-0.6-2+dfsg/src/RS-pgsql-copy.c:244:9: [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(rserrmsg, len, format, pqerrmsg); data/r-cran-rpostgresql-0.6-2+dfsg/src/RS-DBI.c:152: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 buf[128], msg[128]; data/r-cran-rpostgresql-0.6-2+dfsg/src/RS-DBI.c:153:16: [2] (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). Risk is low because the source is a constant string. (void) strcat(msg, "cannot allocate a new connection -- maximum of "); data/r-cran-rpostgresql-0.6-2+dfsg/src/RS-DBI.c:154:16: [2] (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). Risk is low because the source is a constant string. (void) strcat(msg, "%d connections already opened"); data/r-cran-rpostgresql-0.6-2+dfsg/src/RS-DBI.c:276: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 msg[128], fmt[128]; data/r-cran-rpostgresql-0.6-2+dfsg/src/RS-DBI.c:277:16: [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. (void) strcpy(fmt, "cannot allocate a new resultSet -- "); data/r-cran-rpostgresql-0.6-2+dfsg/src/RS-DBI.c:278:16: [2] (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). Risk is low because the source is a constant string. (void) strcat(fmt, "maximum of %d resultSets already reached"); data/r-cran-rpostgresql-0.6-2+dfsg/src/RS-DBI.c:424: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 buf[1024]; data/r-cran-rpostgresql-0.6-2+dfsg/src/RS-DBI.c:444:16: [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. (void) sprintf(buf, "%d", i + 1); data/r-cran-rpostgresql-0.6-2+dfsg/src/RS-DBI.c:636: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 errMsg[128]; data/r-cran-rpostgresql-0.6-2+dfsg/src/RS-DBI.c:637:16: [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. (void) sprintf(errMsg, "could not malloc %ld bytes in RS_DBI_nCopyString", (long) len + 1); data/r-cran-rpostgresql-0.6-2+dfsg/src/RS-DBI.c:733: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. char msg[256]; data/r-cran-rpostgresql-0.6-2+dfsg/src/RS-DBI.c:1142: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 buf[128]; data/r-cran-rpostgresql-0.6-2+dfsg/src/RS-DBI.c:1149:5: [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, "unknown (%ld)", (long) t); data/r-cran-rpostgresql-0.6-2+dfsg/src/RS-DBI.c:1176: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 errMsg[128]; data/r-cran-rpostgresql-0.6-2+dfsg/src/RS-PQescape.c:106:9: [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(RAW(output), rawbuffer, raw_length); data/r-cran-rpostgresql-0.6-2+dfsg/src/RS-PostgreSQL.c:330: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 buf[1024]; data/r-cran-rpostgresql-0.6-2+dfsg/src/RS-PostgreSQL.c:487:39: [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). result->rowsAffected = (Sint) atoi(PQcmdTuples(my_result)); data/r-cran-rpostgresql-0.6-2+dfsg/src/RS-PostgreSQL.c:514: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 errMsg[128]; data/r-cran-rpostgresql-0.6-2+dfsg/src/RS-PostgreSQL.c:524: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 buff[1000]; /* Buffer to hold the sql query to check whether the given column is nullable */ data/r-cran-rpostgresql-0.6-2+dfsg/src/RS-PostgreSQL.c:766:55: [2] (integer) atol: 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). LST_INT_EL(output, j, i) = (Sint) atol(PQgetvalue(my_result, k, j)); /* NOTE: changed */ data/r-cran-rpostgresql-0.6-2+dfsg/src/RS-PostgreSQL.c:793:21: [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 warn[64]; data/r-cran-rpostgresql-0.6-2+dfsg/src/RS-PostgreSQL.c:976: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 buf1[64]; data/r-cran-rpostgresql-0.6-2+dfsg/src/RS-PostgreSQL.c:1319:46: [2] (integer) atol: 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). LST_INT_EL(data, j, i) = atol(PQgetvalue(my_result, row_counter, j)); /* NOTE: changed */ data/r-cran-rpostgresql-0.6-2+dfsg/src/RS-PostgreSQL.c:1338:25: [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 warn[128]; data/r-cran-rpostgresql-0.6-2+dfsg/src/RS-PostgreSQL.c:1363:21: [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 warn[64]; data/r-cran-rpostgresql-0.6-2+dfsg/src/RS-PostgreSQL.c:1444:13: [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[512]; data/r-cran-rpostgresql-0.6-2+dfsg/src/RS-PostgreSQL.c:1445:20: [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. (void) strcpy(buf, "exhausted the pre-allocated storage. The last "); data/r-cran-rpostgresql-0.6-2+dfsg/src/RS-PostgreSQL.c:1446:20: [2] (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). Risk is low because the source is a constant string. (void) strcat(buf, "output group was computed with partial data. "); data/r-cran-rpostgresql-0.6-2+dfsg/src/RS-PostgreSQL.c:1447:20: [2] (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). Risk is low because the source is a constant string. (void) strcat(buf, "The remaining data were left un-read in the "); data/r-cran-rpostgresql-0.6-2+dfsg/src/RS-PostgreSQL.c:1448:20: [2] (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). Risk is low because the source is a constant string. (void) strcat(buf, "result set."); data/r-cran-rpostgresql-0.6-2+dfsg/src/RS-PostgreSQL.c:1513: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 buff[1024]; data/r-cran-rpostgresql-0.6-2+dfsg/src/RS-PostgreSQL.c:1518:16: [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. (void) sprintf(buff, "%ld", (long) LST_LGL_EL(data, group_field, i)); data/r-cran-rpostgresql-0.6-2+dfsg/src/RS-PostgreSQL.c:1521:16: [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. (void) sprintf(buff, "%ld", (long) LST_INT_EL(data, group_field, i)); data/r-cran-rpostgresql-0.6-2+dfsg/src/RS-PostgreSQL.c:1524:16: [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. (void) sprintf(buff, "%f", (double) LST_NUM_EL(data, group_field, i)); data/r-cran-rpostgresql-0.6-2+dfsg/src/RS-pgsql-copy.c:42: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 copybuf[COPY_IN_BUFSIZE]; data/r-cran-rpostgresql-0.6-2+dfsg/src/RS-pgsql-copy.c:51: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). filehandle=fopen(dyn_filename, "r"); data/r-cran-rpostgresql-0.6-2+dfsg/src/RS-pgsql-copy.c:53: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 errmsg[1024]; data/r-cran-rpostgresql-0.6-2+dfsg/src/RS-pgsql-copy.c:149:13: [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(buff->data, escapedstring, escaped_length); data/r-cran-rpostgresql-0.6-2+dfsg/src/RS-pgsql-copy.c:316:25: [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(strendp, tmp, n);/* we already know the length */ data/r-cran-rpostgresql-0.6-2+dfsg/src/RS-pgsql-copy.c:319:25: [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(strendp, tmp, n);/* we already know the length */ data/r-cran-rpostgresql-0.6-2+dfsg/src/RS-pgsql-pqexecparams.c:108:39: [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). result->rowsAffected = (Sint) atoi(PQcmdTuples(my_result)); data/r-cran-rpostgresql-0.6-2+dfsg/src/RS-DBI.c:621:39: [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). buffer = (char *) malloc((size_t) strlen(str) + 1); data/r-cran-rpostgresql-0.6-2+dfsg/src/RS-DBI.c:645:12: [1] (buffer) strncpy: Easily used incorrectly; doesn't always \0-terminate or check for invalid pointers [MS-banned] (CWE-120). (void) strncpy(str_buffer, str, len); data/r-cran-rpostgresql-0.6-2+dfsg/src/RS-DBI.c:1183: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 (strlen(name) > RS_DBI_MAX_IDENTIFIER_LENGTH) { data/r-cran-rpostgresql-0.6-2+dfsg/src/RS-DBI.c:1191: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). len = strlen(name); data/r-cran-rpostgresql-0.6-2+dfsg/src/RS-PQescape.c:28: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). length = strlen(statement_cstr); data/r-cran-rpostgresql-0.6-2+dfsg/src/RS-PostgreSQL.c:440: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). len = strlen(omsg); data/r-cran-rpostgresql-0.6-2+dfsg/src/RS-PostgreSQL.c:464: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). len = strlen(omsg); data/r-cran-rpostgresql-0.6-2+dfsg/src/RS-PostgreSQL.c:1337:59: [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 ((size_t) PQfsize(my_result, j) != strlen(PQgetvalue(my_result, row_counter, j))) { /* NOTE: changed */ data/r-cran-rpostgresql-0.6-2+dfsg/src/RS-pgsql-copy.c:161: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). len = strlen(s); data/r-cran-rpostgresql-0.6-2+dfsg/src/RS-pgsql-copy.c:242: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). size_t len = strlen(pqerrmsg) + strlen(format) + 1; data/r-cran-rpostgresql-0.6-2+dfsg/src/RS-pgsql-copy.c:242:41: [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(pqerrmsg) + strlen(format) + 1; data/r-cran-rpostgresql-0.6-2+dfsg/src/RS-pgsql-copy.c:314: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). n = strlen(tmp); data/r-cran-rpostgresql-0.6-2+dfsg/src/RS-pgsql-getResult.c:67: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). len = strlen(omsg); data/r-cran-rpostgresql-0.6-2+dfsg/src/RS-pgsql-pqexec.c:65: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). len = strlen(omsg); data/r-cran-rpostgresql-0.6-2+dfsg/src/RS-pgsql-pqexec.c:86: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). len = strlen(omsg); data/r-cran-rpostgresql-0.6-2+dfsg/src/RS-pgsql-pqexecparams.c:66: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). len = strlen(omsg); data/r-cran-rpostgresql-0.6-2+dfsg/src/RS-pgsql-pqexecparams.c:86: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). len = strlen(omsg); ANALYSIS SUMMARY: Hits = 65 Lines analyzed = 4250 in approximately 0.13 seconds (33483 lines/second) Physical Source Lines of Code (SLOC) = 3091 Hits@level = [0] 21 [1] 17 [2] 41 [3] 0 [4] 7 [5] 0 Hits@level+ = [0+] 86 [1+] 65 [2+] 48 [3+] 7 [4+] 7 [5+] 0 Hits/KSLOC@level+ = [0+] 27.8227 [1+] 21.0288 [2+] 15.529 [3+] 2.26464 [4+] 2.26464 [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.