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/buildtorrent-0.8/buildtorrent.c
Examining data/buildtorrent-0.8/md5.h
Examining data/buildtorrent-0.8/sha1.c
Examining data/buildtorrent-0.8/md5.c
Examining data/buildtorrent-0.8/sha1.h

FINAL RESULTS:

data/buildtorrent-0.8/buildtorrent.c:1456:14:  [3] (buffer) getopt_long:
  Some older implementations do not protect against internal buffer overflows
  (CWE-120, CWE-20). Check implementation on installation, or limit the size
  of all string inputs.
    char c = getopt_long(argc, argv, "hVqSsmCDa:f:n:A:w:l:L:c:p:", options, &optidx );
data/buildtorrent-0.8/buildtorrent.c:157: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(s->data, data, length);
data/buildtorrent-0.8/buildtorrent.c:306: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(key->data, keyname, keylength);
data/buildtorrent-0.8/buildtorrent.c:545: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 strbuf[512];
data/buildtorrent-0.8/buildtorrent.c:547: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(strbuf, bd->b.string->data, len);
data/buildtorrent-0.8/buildtorrent.c:587: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 strbuf[512];
data/buildtorrent-0.8/buildtorrent.c:596:7:  [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(strbuf, current->key->data, len);
data/buildtorrent-0.8/buildtorrent.c:688: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(node->file, file, strlen(file) + 1);
data/buildtorrent-0.8/buildtorrent.c:779:7:  [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(path + oldlength + 1, file, strlen(file) + 1);
data/buildtorrent-0.8/buildtorrent.c:781:7:  [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(path, file, strlen(file) + 1);
data/buildtorrent-0.8/buildtorrent.c:795:12:  [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.
  unsigned char digest[16];
data/buildtorrent-0.8/buildtorrent.c:796: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 hexdump[33];
data/buildtorrent-0.8/buildtorrent.c:808: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).
  if (!(file = fopen(filename, "rb"))) {
data/buildtorrent-0.8/buildtorrent.c:989: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 s[53];
data/buildtorrent-0.8/buildtorrent.c:1068:10:  [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).
  file = fopen(node->file, "rb");
data/buildtorrent-0.8/buildtorrent.c:1092:18:  [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).
          file = fopen(node->file, "rb");
data/buildtorrent-0.8/buildtorrent.c:1125: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(hashdata + i * SHA1_DIGEST_LENGTH, digest, SHA1_DIGEST_LENGTH);
data/buildtorrent-0.8/buildtorrent.c:1249: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[8192];
data/buildtorrent-0.8/buildtorrent.c:1250: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 torrname[8192];
data/buildtorrent-0.8/buildtorrent.c:1431: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 path[8192];
data/buildtorrent-0.8/buildtorrent.c:1432: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 nametemp[8192];
data/buildtorrent-0.8/buildtorrent.c:1479: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).
      plen = atoi(optarg);
data/buildtorrent-0.8/buildtorrent.c:1482:15:  [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).
      lplen = atoi(optarg);
data/buildtorrent-0.8/buildtorrent.c:1658: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(path, inname, strlen(inname) + 1);
data/buildtorrent-0.8/buildtorrent.c:1681:27:  [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).
      if ((filelistfile = fopen(filelistfilename, "rb"))) {
data/buildtorrent-0.8/buildtorrent.c:1770:18:  [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).
  if (!(output = fopen(outfile, "wb"))) {
data/buildtorrent-0.8/md5.c:84:6:  [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(p, buf, len);
data/buildtorrent-0.8/md5.c:87: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(p, buf, t);
data/buildtorrent-0.8/md5.c:96: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(ctx->in, buf, 64);
data/buildtorrent-0.8/md5.c:105: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(ctx->in, buf, len);
data/buildtorrent-0.8/md5.c:149: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(digest, ctx->buf, 16);
data/buildtorrent-0.8/sha1.c:130:6:  [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(&context->buffer[j], data, (i = 64-j));
data/buildtorrent-0.8/sha1.c:138: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(&context->buffer[j], &data[i], len - i);
data/buildtorrent-0.8/buildtorrent.c:684:29:  [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 (!(node->file = malloc(strlen(file) + 1))) {
data/buildtorrent-0.8/buildtorrent.c:688: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).
  memcpy(node->file, file, strlen(file) + 1);
data/buildtorrent-0.8/buildtorrent.c:773: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(path) + strlen(file) + 1 + 1 > maxlength) {
data/buildtorrent-0.8/buildtorrent.c:773: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).
  if (strlen(path) + strlen(file) + 1 + 1 > maxlength) {
data/buildtorrent-0.8/buildtorrent.c:776: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 oldlength = strlen(path);
data/buildtorrent-0.8/buildtorrent.c:779: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).
      memcpy(path + oldlength + 1, file, strlen(file) + 1);
data/buildtorrent-0.8/buildtorrent.c:781:26:  [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).
      memcpy(path, file, strlen(file) + 1);
data/buildtorrent-0.8/buildtorrent.c:856:26:  [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 oldlength = strlen(path);
data/buildtorrent-0.8/buildtorrent.c:860: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).
            if ((filename = bt_string(strlen(entry->d_name), entry->d_name))) {
data/buildtorrent-0.8/buildtorrent.c:874: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 ((filename = bt_string(strlen(entry->d_name), entry->d_name))) {
data/buildtorrent-0.8/buildtorrent.c:963: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 (bt_dictionary_insert(file, strlen("length"), "length", filesize)) {
data/buildtorrent-0.8/buildtorrent.c:966: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 (bt_dictionary_insert(file, strlen("path"), "path", filepath)) {
data/buildtorrent-0.8/buildtorrent.c:970:38:  [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 (bt_dictionary_insert(file, strlen("md5sum"), "md5sum", md5sum)) {
data/buildtorrent-0.8/buildtorrent.c:1165: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).
      t = s + strlen(s);
data/buildtorrent-0.8/buildtorrent.c:1218: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).
      t = s + strlen(s);
data/buildtorrent-0.8/buildtorrent.c:1256:9:  [1] (buffer) getc:
  Check buffer boundaries if used in a loop including recursive loops
  (CWE-120, CWE-20).
    c = getc(infile);
data/buildtorrent-0.8/buildtorrent.c:1305: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).
          torrnamestr = bt_string(strlen(torrname), torrname);
data/buildtorrent-0.8/buildtorrent.c:1563: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(inname) > 8190) {
data/buildtorrent-0.8/buildtorrent.c:1567:5:  [1] (buffer) strncpy:
  Easily used incorrectly; doesn't always \0-terminate or check for invalid
  pointers [MS-banned] (CWE-120).
    strncpy(nametemp, inname, 8191);
data/buildtorrent-0.8/buildtorrent.c:1570: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).
    slen = strlen(namebase);
data/buildtorrent-0.8/buildtorrent.c:1599: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).
  if (!(announce = bt_string(strlen(url), url))) {
data/buildtorrent-0.8/buildtorrent.c:1608: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).
    name = bt_string(strlen(nameflag), nameflag);
data/buildtorrent-0.8/buildtorrent.c:1610: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).
    name = bt_string(strlen(namebase), namebase);
data/buildtorrent-0.8/buildtorrent.c:1616:34:  [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 (bt_dictionary_insert(info, strlen("name"), "name", name)) {
data/buildtorrent-0.8/buildtorrent.c:1621: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).
    info, strlen("piece length"), "piece length", piecelength
data/buildtorrent-0.8/buildtorrent.c:1658:26:  [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).
    memcpy(path, inname, strlen(inname) + 1);
data/buildtorrent-0.8/buildtorrent.c:1713: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 (bt_dictionary_insert(info, strlen("private"), "private", private)) {
data/buildtorrent-0.8/buildtorrent.c:1718: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).
  if (bt_dictionary_insert(torrent, strlen("announce"), "announce", announce)) {
data/buildtorrent-0.8/buildtorrent.c:1723: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).
    if (bt_dictionary_insert(torrent, strlen("announce-list"), "announce-list", announcelist)) {
data/buildtorrent-0.8/buildtorrent.c:1729: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).
    if (bt_dictionary_insert(torrent, strlen("url-list"), "url-list", webseedlist)) {
data/buildtorrent-0.8/buildtorrent.c:1740: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).
      torrent, strlen("creation date"), "creation date", creationdate
data/buildtorrent-0.8/buildtorrent.c:1747: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).
    if (!(creator = bt_string(strlen("buildtorrent/" bt_version), "buildtorrent/" bt_version))) {
data/buildtorrent-0.8/buildtorrent.c:1752: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).
      torrent, strlen("created by"), "created by", creator
data/buildtorrent-0.8/buildtorrent.c:1759: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).
    if (!(comment = bt_string(strlen(commentstr), commentstr))) {
data/buildtorrent-0.8/buildtorrent.c:1764: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).
      torrent, strlen("comment"), "comment", comment
data/buildtorrent-0.8/buildtorrent.c:1785: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 (bt_dictionary_insert(info, strlen("files"), "files", files)) {
data/buildtorrent-0.8/buildtorrent.c:1795: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 (bt_dictionary_insert(info, strlen("length"), "length", length)) {
data/buildtorrent-0.8/buildtorrent.c:1800:38:  [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 (bt_dictionary_insert(info, strlen("md5sum"), "md5sum", node->md5sum)) {
data/buildtorrent-0.8/buildtorrent.c:1807:34:  [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 (bt_dictionary_insert(info, strlen("pieces"), "pieces", pieces)) {
data/buildtorrent-0.8/buildtorrent.c:1811: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).
  if (bt_dictionary_insert(torrent, strlen("info"), "info", info)) {

ANALYSIS SUMMARY:

Hits = 73
Lines analyzed = 2333 in approximately 0.11 seconds (21591 lines/second)
Physical Source Lines of Code (SLOC) = 1881
Hits@level = [0]  92 [1]  40 [2]  32 [3]   1 [4]   0 [5]   0
Hits@level+ = [0+] 165 [1+]  73 [2+]  33 [3+]   1 [4+]   0 [5+]   0
Hits/KSLOC@level+ = [0+] 87.7193 [1+] 38.8091 [2+] 17.5439 [3+] 0.531632 [4+]   0 [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.