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/tds-fdw-2.0.2/include/deparse.h Examining data/tds-fdw-2.0.2/include/options.h Examining data/tds-fdw-2.0.2/include/tds_fdw.h Examining data/tds-fdw-2.0.2/include/visibility.h Examining data/tds-fdw-2.0.2/src/deparse.c Examining data/tds-fdw-2.0.2/src/options.c Examining data/tds-fdw-2.0.2/src/tds_fdw.c FINAL RESULTS: data/tds-fdw-2.0.2/src/options.c:732:3: [4] (buffer) sprintf: Does not check for buffer overflows (CWE-120). Use sprintf_s, snprintf, or vsnprintf. sprintf(option_set->servername, "%s", DEFAULT_SERVERNAME); data/tds-fdw-2.0.2/src/options.c:751:3: [4] (buffer) sprintf: Does not check for buffer overflows (CWE-120). Use sprintf_s, snprintf, or vsnprintf. sprintf(option_set->row_estimate_method, "%s", DEFAULT_ROW_ESTIMATE_METHOD); data/tds-fdw-2.0.2/src/options.c:770:3: [4] (buffer) sprintf: Does not check for buffer overflows (CWE-120). Use sprintf_s, snprintf, or vsnprintf. sprintf(option_set->msg_handler, "%s", DEFAULT_MSG_HANDLER); data/tds-fdw-2.0.2/src/tds_fdw.c:400: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(option_set->query, sql.data); data/tds-fdw-2.0.2/src/tds_fdw.c:1172: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(dest, datetime_str); data/tds-fdw-2.0.2/src/tds_fdw.c:3299: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(prev_table, table_name); data/tds-fdw-2.0.2/src/tds_fdw.c:3679: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(prev_table, table_name); data/tds-fdw-2.0.2/src/options.c:294:23: [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). option_set->port = atoi(defGetString(def)); data/tds-fdw-2.0.2/src/options.c:316:24: [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). option_set->dbuse = atoi(defGetString(def)); data/tds-fdw-2.0.2/src/options.c:422:35: [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). option_set->fdw_startup_cost = atoi(defGetString(def)); data/tds-fdw-2.0.2/src/options.c:433: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). option_set->fdw_tuple_cost = atoi(defGetString(def)); data/tds-fdw-2.0.2/src/options.c:511:38: [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). option_set->use_remote_estimate = atoi(defGetString(def)); data/tds-fdw-2.0.2/src/options.c:617:37: [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). option_set->match_column_names = atoi(defGetString(def)); data/tds-fdw-2.0.2/src/options.c:623:38: [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). option_set->use_remote_estimate = atoi(defGetString(def)); data/tds-fdw-2.0.2/src/options.c:634: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). option_set->local_tuple_estimate = atoi(defGetString(def)); data/tds-fdw-2.0.2/src/tds_fdw.c:545:4: [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(conn_string + server_len, ":%i", option_set->port); data/tds-fdw-2.0.2/src/tds_fdw.c:1804:8: [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(VARDATA(bytes), src, srclen); data/tds-fdw-2.0.2/src/tds_fdw.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 table_name[255], data/tds-fdw-2.0.2/src/tds_fdw.c:3433: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 table_name[255], data/tds-fdw-2.0.2/src/deparse.c:183:27: [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). result = (char *) palloc(strlen(ident) + 2 + 1); data/tds-fdw-2.0.2/src/deparse.c:708: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(tds_type_local); data/tds-fdw-2.0.2/src/deparse.c:711:3: [1] (buffer) strncpy: Easily used incorrectly; doesn't always \0-terminate or check for invalid pointers [MS-banned] (CWE-120). strncpy(tds_type, tds_type_local, len); data/tds-fdw-2.0.2/src/deparse.c:717: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(postgresql_type); data/tds-fdw-2.0.2/src/deparse.c:720:3: [1] (buffer) strncpy: Easily used incorrectly; doesn't always \0-terminate or check for invalid pointers [MS-banned] (CWE-120). strncpy(tds_type, postgresql_type, len); data/tds-fdw-2.0.2/src/deparse.c:1397:9: [1] (buffer) equal: Function does not check the second iterator for over-read conditions (CWE-126). This function is often discouraged by most C++ coding standards in favor of its safer alternatives provided since C++14. Consider using a form of this function that checks the second iterator before potentially overflowing it. if (equal(node, (Node *) lfirst(lc))) data/tds-fdw-2.0.2/src/deparse.c:1486:46: [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 (strspn(extval, "0123456789+-eE.") == strlen(extval)) data/tds-fdw-2.0.2/src/deparse.c:1492: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). if (strcspn(extval, "eE.") != strlen(extval)) data/tds-fdw-2.0.2/src/deparse.c:1545:8: [1] (buffer) equal: Function does not check the second iterator for over-read conditions (CWE-126). This function is often discouraged by most C++ coding standards in favor of its safer alternatives provided since C++14. Consider using a form of this function that checks the second iterator before potentially overflowing it. if (equal(node, (Node *) lfirst(lc))) data/tds-fdw-2.0.2/src/options.c:724: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). if ((option_set->servername = palloc((strlen(DEFAULT_SERVERNAME) + 1) * sizeof(char))) == NULL) data/tds-fdw-2.0.2/src/options.c:743:50: [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 ((option_set->row_estimate_method = palloc((strlen(DEFAULT_ROW_ESTIMATE_METHOD) + 1) * sizeof(char))) == NULL) data/tds-fdw-2.0.2/src/options.c:762: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). if ((option_set->msg_handler= palloc((strlen(DEFAULT_MSG_HANDLER) + 1) * sizeof(char))) == NULL) data/tds-fdw-2.0.2/src/tds_fdw.c:273:10: [1] (buffer) equal: Function does not check the second iterator for over-read conditions (CWE-126). This function is often discouraged by most C++ coding standards in favor of its safer alternatives provided since C++14. Consider using a form of this function that checks the second iterator before potentially overflowing it. return equal(expr, state->current); data/tds-fdw-2.0.2/src/tds_fdw.c:539:42: [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). int server_len = next_server == NULL ? strlen(servers) : next_server - servers; data/tds-fdw-2.0.2/src/tds_fdw.c:543:3: [1] (buffer) strncpy: Easily used incorrectly; doesn't always \0-terminate or check for invalid pointers [MS-banned] (CWE-120). strncpy(conn_string, servers, server_len); data/tds-fdw-2.0.2/src/tds_fdw.c:1171: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). dest = palloc(strlen(datetime_str) * sizeof(char)); ANALYSIS SUMMARY: Hits = 35 Lines analyzed = 7408 in approximately 0.20 seconds (37656 lines/second) Physical Source Lines of Code (SLOC) = 5201 Hits@level = [0] 3 [1] 16 [2] 12 [3] 0 [4] 7 [5] 0 Hits@level+ = [0+] 38 [1+] 35 [2+] 19 [3+] 7 [4+] 7 [5+] 0 Hits/KSLOC@level+ = [0+] 7.30629 [1+] 6.72948 [2+] 3.65314 [3+] 1.3459 [4+] 1.3459 [5+] 0 Dot directories skipped = 2 (--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.