The following issues were found

caffe2/mpi/mpi_common.cc
1 issues
char - Statically-sized arrays can be improperly restricted, leading to potential overflows or other issues
Security

Line: 120 Column: 5 CWE codes: 119 120
Suggestion: Perform bounds checking, use functions that limit length, or ensure that the size is larger than the maximum possible length

              
  if (role == "server") {
    // Open a port to accept connections.
    char port_name[MPI_MAX_PORT_NAME] = {'\0'};
    MPI_CHECK(MPI_Open_port(MPI_INFO_NULL, port_name));
    VLOG(1) << "MPI server: port: " << port_name;

    // Writes the port name to the file.
    CHECK(WriteStringToFile(std::string(port_name), job_path.c_str()));

            

Reported by FlawFinder.

caffe2/mobile/contrib/ulp2/ulp_test.cc
1 issues
syntax error
Error

Line: 107

                return r;
}

TEST(ULP, QPadZero) {
  ConvArgs args;
  args.pad_l = 1;
  args.pad_r = 1;
  args.pad_t = 1;
  args.pad_b = 1;

            

Reported by Cppcheck.

caffe2/mobile/contrib/ulp2/ulp_neon.cc
1 issues
memcpy - Does not check for buffer overflows when copying to destination
Security

Line: 254 Column: 18 CWE codes: 120
Suggestion: Make sure destination can always hold the source data

                        for (auto ii = 0; ii < TileSize; ++ii) {
            auto m = i * TileSize + ii;
            auto qk = j * TileDepthBytes;
            std::memcpy(&XPdata[TileDepthBytes * ii + TileDepthBytes * TileSize * j +
                                TileSize * TileDepthBytes * numTilesDepth * i],
                        &Xdata[m * QK + qk],
                        TileDepthBytes);
          }
        } else {

            

Reported by FlawFinder.

caffe2/mobile/contrib/snpe/snpe_op_benchmark.cc
1 issues
memcpy - Does not check for buffer overflows when copying to destination
Security

Line: 19 Column: 5 CWE codes: 120
Suggestion: Make sure destination can always hold the source data

                  Blob* _blob = ws.CreateBlob((_n));                                    \
    auto* _tensor = BlobGetMutableTensor(_blob, CPU);                     \
    _tensor->Resize((_s));                                                \
    memcpy(_tensor->mutable_data<float>(), data_##_l, _tensor->nbytes()); \
  } while (0)
#else
// Rough test on static data
#define POPULATE_DATA(_n, _s, _l)                                 \
  do {                                                            \

            

Reported by FlawFinder.

caffe2/mobile/contrib/nnapi/nnapi_test.cc
1 issues
syntax error
Error

Line: 548

                checkError(t_cpu, t_nn, 0.01);
}

TEST(NNApi, TestConv) {
  for (int C : {13, 32}) {
    for (int M : {4, 7, 17}) {
      for (int W : {13, 104}) {
        for (int K : {1, 3, 5}) {
          for (int P : {0, K - 1}) {

            

Reported by Cppcheck.

caffe2/mobile/contrib/nnapi/dlnnapi.c
1 issues
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)
Security

Line: 101 Column: 24 CWE codes: 126

                      nnapi->functions[i] = function;
      }

      function_name += strlen(function_name) + 1;
    }
    nnapi->flags = (uint32_t)version_flags;

    return true;
  }

            

Reported by FlawFinder.

caffe2/mobile/contrib/libopencl-stub/include/CL/cl_platform.h
1 issues
system - This causes a new program to execute and is difficult to use safely
Security

Line: 64 Column: 79 CWE codes: 78
Suggestion: try using a library call that implements the same functionality if available

                      #define CL_EXT_PREFIX__VERSION_1_1_DEPRECATED
        #define CL_EXT_SUFFIX__VERSION_1_1_DEPRECATED   CL_EXTENSION_WEAK_LINK AVAILABLE_MAC_OS_X_VERSION_10_7_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_8
    #else
        #warning  This path should never happen outside of internal operating system development.  AvailabilityMacros do not function correctly here!
        #define CL_API_SUFFIX__VERSION_1_2              AVAILABLE_MAC_OS_X_VERSION_10_7_AND_LATER
        #define GCL_API_SUFFIX__VERSION_1_2             AVAILABLE_MAC_OS_X_VERSION_10_7_AND_LATER
        #define CL_EXT_SUFFIX__VERSION_1_2              CL_EXTENSION_WEAK_LINK AVAILABLE_MAC_OS_X_VERSION_10_7_AND_LATER
        #define CL_EXT_SUFFIX__VERSION_1_1_DEPRECATED   CL_EXTENSION_WEAK_LINK AVAILABLE_MAC_OS_X_VERSION_10_7_AND_LATER
    #endif

            

Reported by FlawFinder.

caffe2/mobile/contrib/ios/resize_test.cc
1 issues
syntax error
Error

Line: 85

                return std::uniform_int_distribution<int>(a, b)(gen);
}

TEST(ResizeNearestOp, ResizeNearest2x) {
  for (auto i = 0; i < 40; ++i) {
    auto H = randInt(1, 100);
    auto W = randInt(1, 100);
    auto C = randInt(1, 10);
    auto N = randInt(1, 2);

            

Reported by Cppcheck.

caffe2/mobile/contrib/ios/pool_test.cc
1 issues
syntax error
Error

Line: 117

                compareMaxPooling(N, C, H, W, kernel, kernel, stride, stride, pad, pad, pad, pad);
}

TEST(PoolOp, MaxPool2x2s2p0Randomized) {
  for (int i = 0; i < 40; ++i) {
    runMaxPool(2, 2, 0);
  }
}


            

Reported by Cppcheck.

.jenkins/pytorch/perf_test/get_stats.py
1 issues
Missing module docstring
Error

Line: 1 Column: 1

              import sys
import json
import numpy

sample_data_list = sys.argv[1:]
sample_data_list = [float(v.strip()) for v in sample_data_list]

sample_mean = numpy.mean(sample_data_list)
sample_sigma = numpy.std(sample_data_list)

            

Reported by Pylint.