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/hnswlib-0.4.0/examples/updates_test.cpp
Examining data/hnswlib-0.4.0/hnswlib/bruteforce.h
Examining data/hnswlib-0.4.0/hnswlib/hnswlib.h
Examining data/hnswlib-0.4.0/hnswlib/space_ip.h
Examining data/hnswlib-0.4.0/hnswlib/space_l2.h
Examining data/hnswlib-0.4.0/hnswlib/visited_list_pool.h
Examining data/hnswlib-0.4.0/hnswlib/hnswalg.h
Examining data/hnswlib-0.4.0/main.cpp
Examining data/hnswlib-0.4.0/python_bindings/bindings.cpp
Examining data/hnswlib-0.4.0/sift_1b.cpp
Examining data/hnswlib-0.4.0/sift_test.cpp

FINAL RESULTS:

data/hnswlib-0.4.0/examples/updates_test.cpp:97:10:  [2] (misc) open:
  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.open(path);
data/hnswlib-0.4.0/examples/updates_test.cpp:218:20:  [2] (misc) open:
  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).
        configfile.open(path + "/config.txt");
data/hnswlib-0.4.0/examples/updates_test.cpp:258: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 cpath[1024];
data/hnswlib-0.4.0/examples/updates_test.cpp:259:13:  [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(cpath, "batch_dummy_%02d.bin", b);
data/hnswlib-0.4.0/hnswlib/bruteforce.h:67: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(data_ + size_per_element_ * idx + data_size_, &label, sizeof(labeltype));
data/hnswlib-0.4.0/hnswlib/bruteforce.h:68: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(data_ + size_per_element_ * idx, datapoint, data_size_);
data/hnswlib-0.4.0/hnswlib/bruteforce.h:82: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(data_ + size_per_element_ * cur_c,
data/hnswlib-0.4.0/hnswlib/hnswalg.h:140: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(&return_label,(data_level0_memory_ + internal_id * size_data_per_element_ + label_offset_), sizeof(labeltype));
data/hnswlib-0.4.0/hnswlib/hnswalg.h:145: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((data_level0_memory_ + internal_id * size_data_per_element_ + label_offset_), &label, sizeof(labeltype));
data/hnswlib-0.4.0/hnswlib/hnswalg.h:586: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(data_level0_memory_new, data_level0_memory_,cur_element_count * size_data_per_element_);
data/hnswlib-0.4.0/hnswlib/hnswalg.h:594: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(linkLists_new, linkLists_,cur_element_count * sizeof(void *));
data/hnswlib-0.4.0/hnswlib/hnswalg.h:834: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(getDataByInternalId(internalId), dataPoint, data_size_);
data/hnswlib-0.4.0/hnswlib/hnswalg.h:978: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(result.data(), ll,size * sizeof(tableint));
data/hnswlib-0.4.0/hnswlib/hnswalg.h:1030: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(getExternalLabeLp(cur_c), &label, sizeof(labeltype));
data/hnswlib-0.4.0/hnswlib/hnswalg.h:1031: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(getDataByInternalId(cur_c), data_point, data_size_);
data/hnswlib-0.4.0/sift_1b.cpp:81:15:  [2] (misc) open:
  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 ((fd = open("/proc/self/psinfo", O_RDONLY)) == -1)
data/hnswlib-0.4.0/sift_1b.cpp:132:15:  [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 ((fp = fopen("/proc/self/statm", "r")) == NULL)
data/hnswlib-0.4.0/sift_1b.cpp:243: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 path_index[1024];
data/hnswlib-0.4.0/sift_1b.cpp:244: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 path_gt[1024];
data/hnswlib-0.4.0/sift_1b.cpp:247: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(path_index, "sift1b_%dm_ef_%d_M_%d.bin", subset_size_milllions, efConstruction, M);
data/hnswlib-0.4.0/sift_1b.cpp:249: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(path_gt, "bigann/gnd/idx_%dM.ivecs", subset_size_milllions);
data/hnswlib-0.4.0/sift_1b.cpp:321:22:  [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 mass[128];
data/hnswlib-0.4.0/examples/updates_test.cpp:105:10:  [1] (buffer) read:
  Check buffer boundaries if used in a loop including recursive loops
  (CWE-120, CWE-20).
    file.read((char *)batch.data(), size * sizeof(float));
data/hnswlib-0.4.0/hnswlib/bruteforce.h:163:19:  [1] (buffer) read:
  Check buffer boundaries if used in a loop including recursive loops
  (CWE-120, CWE-20).
            input.read(data_, maxelements_ * size_per_element_);
data/hnswlib-0.4.0/hnswlib/hnswalg.h:703:19:  [1] (buffer) read:
  Check buffer boundaries if used in a loop including recursive loops
  (CWE-120, CWE-20).
            input.read(data_level0_memory_, cur_element_count * size_data_per_element_);
data/hnswlib-0.4.0/hnswlib/hnswalg.h:738:27:  [1] (buffer) read:
  Check buffer boundaries if used in a loop including recursive loops
  (CWE-120, CWE-20).
                    input.read(linkLists_[i], linkListSize);
data/hnswlib-0.4.0/hnswlib/hnswlib.h:49:12:  [1] (buffer) read:
  Check buffer boundaries if used in a loop including recursive loops
  (CWE-120, CWE-20).
        in.read((char *) &podRef, sizeof(T));
data/hnswlib-0.4.0/sift_1b.cpp:83:9:  [1] (buffer) read:
  Check buffer boundaries if used in a loop including recursive loops
  (CWE-120, CWE-20).
    if (read(fd, &psinfo, sizeof(psinfo)) != sizeof(psinfo))
data/hnswlib-0.4.0/sift_1b.cpp:259:17:  [1] (buffer) read:
  Check buffer boundaries if used in a loop including recursive loops
  (CWE-120, CWE-20).
        inputGT.read((char *) &t, 4);
data/hnswlib-0.4.0/sift_1b.cpp:260:17:  [1] (buffer) read:
  Check buffer boundaries if used in a loop including recursive loops
  (CWE-120, CWE-20).
        inputGT.read((char *) (massQA + 1000 * i), t * 4);
data/hnswlib-0.4.0/sift_1b.cpp:274:16:  [1] (buffer) read:
  Check buffer boundaries if used in a loop including recursive loops
  (CWE-120, CWE-20).
        inputQ.read((char *) &in, 4);
data/hnswlib-0.4.0/sift_1b.cpp:279:16:  [1] (buffer) read:
  Check buffer boundaries if used in a loop including recursive loops
  (CWE-120, CWE-20).
        inputQ.read((char *) massb, in);
data/hnswlib-0.4.0/sift_1b.cpp:303:15:  [1] (buffer) read:
  Check buffer boundaries if used in a loop including recursive loops
  (CWE-120, CWE-20).
        input.read((char *) &in, 4);
data/hnswlib-0.4.0/sift_1b.cpp:308:15:  [1] (buffer) read:
  Check buffer boundaries if used in a loop including recursive loops
  (CWE-120, CWE-20).
        input.read((char *) massb, in);
data/hnswlib-0.4.0/sift_1b.cpp:326:23:  [1] (buffer) read:
  Check buffer boundaries if used in a loop including recursive loops
  (CWE-120, CWE-20).
                input.read((char *) &in, 4);
data/hnswlib-0.4.0/sift_1b.cpp:331:23:  [1] (buffer) read:
  Check buffer boundaries if used in a loop including recursive loops
  (CWE-120, CWE-20).
                input.read((char *) massb, in);
data/hnswlib-0.4.0/sift_test.cpp:160:11:  [1] (buffer) read:
  Check buffer boundaries if used in a loop including recursive loops
  (CWE-120, CWE-20).
    input.read((char *) mass, vecsize * vecdim * sizeof(float));
data/hnswlib-0.4.0/sift_test.cpp:167:12:  [1] (buffer) read:
  Check buffer boundaries if used in a loop including recursive loops
  (CWE-120, CWE-20).
    inputQ.read((char *) massQ, qsize * vecdim * sizeof(float));
data/hnswlib-0.4.0/sift_test.cpp:174:13:  [1] (buffer) read:
  Check buffer boundaries if used in a loop including recursive loops
  (CWE-120, CWE-20).
    inputQA.read((char *) massQA, qsize * 100 * sizeof(int));

ANALYSIS SUMMARY:

Hits = 39
Lines analyzed = 3482 in approximately 0.73 seconds (4767 lines/second)
Physical Source Lines of Code (SLOC) = 2570
Hits@level = [0]   2 [1]  17 [2]  22 [3]   0 [4]   0 [5]   0
Hits@level+ = [0+]  41 [1+]  39 [2+]  22 [3+]   0 [4+]   0 [5+]   0
Hits/KSLOC@level+ = [0+] 15.9533 [1+] 15.1751 [2+] 8.56031 [3+]   0 [4+]   0 [5+]   0
Symlinks skipped = 1 (--allowlink overrides but see doc for security issue)
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.