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/bti-034/bti.h Examining data/bti-034/config.c Examining data/bti-034/bti.c FINAL RESULTS: data/bti-034/bti.c:47:4: [4] (format) fprintf: If format strings can be influenced by an attacker, they can be exploited (CWE-134). Use a constant for the format specification. fprintf(stdout, "bti: %s: " format , __func__ , \ data/bti-034/bti.c:155: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(tmp, libpath); data/bti-034/bti.c:333:2: [4] (buffer) sprintf: Does not check for buffer overflows (CWE-120). Use sprintf_s, snprintf, or vsnprintf. sprintf(file, "%s/%s", home, config_user_default); data/bti-034/bti.c:343:2: [4] (buffer) sprintf: Does not check for buffer overflows (CWE-120). Use sprintf_s, snprintf, or vsnprintf. sprintf(file, "%s/%s", home, config_xdg_default); data/bti-034/bti.c:801:3: [4] (buffer) sprintf: Does not check for buffer overflows (CWE-120). Use sprintf_s, snprintf, or vsnprintf. sprintf(token_uri, "%s%s", data/bti-034/bti.c:831:3: [4] (buffer) sprintf: Does not check for buffer overflows (CWE-120). Use sprintf_s, snprintf, or vsnprintf. sprintf(at_uri, "%s?oauth_verifier=%s", data/bti-034/bti.c:837:3: [4] (buffer) sprintf: Does not check for buffer overflows (CWE-120). Use sprintf_s, snprintf, or vsnprintf. sprintf(at_uri, "%s%s?oauth_verifier=%s", data/bti-034/bti.c:1064:5: [4] (buffer) sprintf: Does not check for buffer overflows (CWE-120). Use sprintf_s, snprintf, or vsnprintf. sprintf(endpoint, data/bti-034/bti.c:1069:5: [4] (buffer) sprintf: Does not check for buffer overflows (CWE-120). Use sprintf_s, snprintf, or vsnprintf. sprintf(endpoint, "%s%s?status=%s", data/bti-034/bti.c:1077:4: [4] (buffer) sprintf: Does not check for buffer overflows (CWE-120). Use sprintf_s, snprintf, or vsnprintf. sprintf(endpoint, "%s%s?screen_name=%s&page=%d", data/bti-034/bti.c:1082:4: [4] (buffer) sprintf: Does not check for buffer overflows (CWE-120). Use sprintf_s, snprintf, or vsnprintf. sprintf(endpoint, "%s%s?page=%d", session->hosturl, data/bti-034/bti.c:1086:4: [4] (buffer) sprintf: Does not check for buffer overflows (CWE-120). Use sprintf_s, snprintf, or vsnprintf. sprintf(endpoint, "%s%s", twitter_host_stream, data/bti-034/bti.c:1090:4: [4] (buffer) sprintf: Does not check for buffer overflows (CWE-120). Use sprintf_s, snprintf, or vsnprintf. sprintf(endpoint, "%s%s%s.xml?page=%d", data/bti-034/bti.c:1095:4: [4] (buffer) sprintf: Does not check for buffer overflows (CWE-120). Use sprintf_s, snprintf, or vsnprintf. sprintf(endpoint, "%s%s?page=%d", session->hosturl, data/bti-034/bti.c:1099:4: [4] (buffer) sprintf: Does not check for buffer overflows (CWE-120). Use sprintf_s, snprintf, or vsnprintf. sprintf(endpoint, "%s%s%s.xml", session->hosturl, data/bti-034/bti.c:1105:4: [4] (buffer) sprintf: Does not check for buffer overflows (CWE-120). Use sprintf_s, snprintf, or vsnprintf. sprintf(endpoint, "%s%s?user=%s&text=%s", twitter_host_simple, data/bti-034/bti.c:1170:2: [4] (buffer) sprintf: Does not check for buffer overflows (CWE-120). Use sprintf_s, snprintf, or vsnprintf. sprintf(filename, "%s/%s", session->homedir, session->logfile); data/bti-034/bti.c:1388:3: [4] (shell) execvp: 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. execvp(exe, (char **)argv); data/bti-034/bti.c:1816:4: [4] (buffer) sprintf: Does not check for buffer overflows (CWE-120). Use sprintf_s, snprintf, or vsnprintf. sprintf(session->retweet, "%s", rtid); data/bti-034/bti.c:1843:4: [4] (buffer) sprintf: Does not check for buffer overflows (CWE-120). Use sprintf_s, snprintf, or vsnprintf. sprintf(session->tweet, "%c %s", data/bti-034/bti.c:1846:4: [4] (buffer) sprintf: Does not check for buffer overflows (CWE-120). Use sprintf_s, snprintf, or vsnprintf. sprintf(session->tweet, "%s", tweet); data/bti-034/bti.h:87:4: [4] (format) fprintf: If format strings can be influenced by an attacker, they can be exploited (CWE-134). Use a constant for the format specification. fprintf(stdout, "bti: %s: " format , __func__ , \ data/bti-034/bti.c:315:9: [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. home = getenv("HOME"); data/bti-034/bti.c:1588:15: [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. http_proxy = getenv("http_proxy"); data/bti-034/bti.c:495:1: [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 *keystack[MAXKEYSTACK]; data/bti-034/bti.c:730: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(temp, curl_buf->data, curl_buf->length); data/bti-034/bti.c:733: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(&curl_buf->data[curl_buf->length], (char *)buffer, buffer_size); data/bti-034/bti.c:789: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 at_uri[90]; data/bti-034/bti.c:790: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 token_uri[90]; data/bti-034/bti.c:867: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 endpoint[endpoint_size]; data/bti-034/bti.c:868: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 user_password[500]; data/bti-034/bti.c:869: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 data[500]; data/bti-034/bti.c:1172:13: [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). log_file = fopen(filename, "a+"); data/bti-034/bti.c:1243: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 pwd[80]; data/bti-034/bti.c:1564: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. static char password[80]; data/bti-034/bti.c:1618:14: [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). page_nr = atoi(optarg); data/bti-034/bti.c:1623:29: [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). session->column_output = atoi(optarg); data/bti-034/config.c:327: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). config_file = fopen(session->configfile, "r"); data/bti-034/bti.c:152: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). tmp = malloc(strlen(libpath)+1); data/bti-034/bti.c:325: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). homedir_size = strlen(session->homedir); data/bti-034/bti.c:332:31: [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). file = zalloc(homedir_size + strlen(config_user_default) + 7); data/bti-034/bti.c:342:31: [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). file = zalloc(homedir_size + strlen(config_xdg_default) + 7); data/bti-034/bti.c:421:32: [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). doc = xmlReadMemory(document, strlen(document), "timeline.xml", data/bti-034/bti.c:1167: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). filename = alloca(strlen(session->homedir) + data/bti-034/bti.c:1168: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). strlen(session->logfile) + 3); data/bti-034/bti.c:1261:8: [1] (buffer) scanf: It's unclear if the %s limit in the format string is small enough (CWE-120). Check that the limit is sufficiently small, or use a different input function. (void)scanf("%79s", pwd); data/bti-034/bti.c:1268:2: [1] (buffer) strncpy: Easily used incorrectly; doesn't always \0-terminate or check for invalid pointers [MS-banned] (CWE-120). strncpy(buf, pwd, len); data/bti-034/bti.c:1301: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). tweetlen = strlen(tweet); data/bti-034/bti.c:1304:35: [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). rc = pcre_exec(re, NULL, tweet, strlen(tweet), startoffset, 0, data/bti-034/bti.c:1420: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). int biglen = strlen(big); data/bti-034/bti.c:1434:7: [1] (buffer) read: Check buffer boundaries if used in a loop including recursive loops (CWE-120, CWE-20). rc = read(rwepipe[1], small, smalllen); data/bti-034/bti.c:1466: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). int inlen = strlen(text); data/bti-034/bti.c:1488: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). short_url_len = url ? strlen(url) : 0; data/bti-034/bti.c:1495:5: [1] (buffer) strncpy: Easily used incorrectly; doesn't always \0-terminate or check for invalid pointers [MS-banned] (CWE-120). strncpy(text + outofs, text + inofs, data/bti-034/bti.c:1503:4: [1] (buffer) strncpy: Easily used incorrectly; doesn't always \0-terminate or check for invalid pointers [MS-banned] (CWE-120). strncpy(text + outofs, text + inofs, not_url_len); data/bti-034/bti.c:1508:4: [1] (buffer) strncpy: Easily used incorrectly; doesn't always \0-terminate or check for invalid pointers [MS-banned] (CWE-120). strncpy(text + outofs, url, short_url_len); data/bti-034/bti.c:1520:4: [1] (buffer) strncpy: Easily used incorrectly; doesn't always \0-terminate or check for invalid pointers [MS-banned] (CWE-120). strncpy(text + outofs, text + inofs, tail); data/bti-034/bti.c:1582: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). session->time[strlen(session->time)-1] = 0x00; data/bti-034/bti.c:1815: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). session->retweet = zalloc(strlen(rtid) + 10); data/bti-034/bti.c:1820: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 (!session->retweet || strlen(session->retweet) == 0) { data/bti-034/bti.c:1833: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). if (!tweet || strlen(tweet) == 0) { data/bti-034/bti.c:1841: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). session->tweet = zalloc(strlen(tweet) + 10); data/bti-034/config.c:303:35: [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 (strncasecmp(item->key, key, strlen(item->key)) == 0) { ANALYSIS SUMMARY: Hits = 63 Lines analyzed = 2351 in approximately 0.10 seconds (22620 lines/second) Physical Source Lines of Code (SLOC) = 1864 Hits@level = [0] 81 [1] 25 [2] 14 [3] 2 [4] 22 [5] 0 Hits@level+ = [0+] 144 [1+] 63 [2+] 38 [3+] 24 [4+] 22 [5+] 0 Hits/KSLOC@level+ = [0+] 77.2532 [1+] 33.7983 [2+] 20.3863 [3+] 12.8755 [4+] 11.8026 [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.