The following issues were found

caffe2/operators/quantized/int8_resize_nearest_op.h
1 issues
memcpy - Does not check for buffer overflows when copying to destination
Security

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

                      const int in_y = std::min((int)(y / height_scale_), (IH - 1));
        for (int x = 0; x < OW; ++x) {
          const int in_x = std::min((int)(x / width_scale_), (IW - 1));
          std::memcpy(
              &Ydata[C * x + C * OW * y + C * OW * OH * n],
              &Xdata[C * in_x + C * IW * in_y + C * IW * IH * n],
              C);
        }
      }

            

Reported by FlawFinder.

caffe2/operators/quantized/int8_fc_op.h
1 issues
memcpy - Does not check for buffer overflows when copying to destination
Security

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

                    if (K < 8) {
        buffer->Resize(std::vector<int64_t>{X.t.numel() + 8});
        inputPtr = buffer->template mutable_data<uint8_t>() + 8;
        memcpy(inputPtr, X.t.template data<uint8_t>(), X.t.numel());
      }

      if (lastBatchSize_ != static_cast<size_t>(M) ||
          lastInputPointer_ != inputPtr ||
          lastOutputPointer_ != Y->t.template mutable_data<uint8_t>()) {

            

Reported by FlawFinder.

caffe2/operators/quantized/int8_conv_transpose_op.h
1 issues
memcpy - Does not check for buffer overflows when copying to destination
Security

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

                    if (IC < 8) {
        buffer->Resize(std::vector<int64_t>{X.t.numel() + 8});
        inputPtr = buffer->template mutable_data<uint8_t>() + 8;
        memcpy(inputPtr, X.t.template data<uint8_t>(), X.t.numel());
      }

      if (lastBatchSize_ != static_cast<size_t>(X.t.size(0)) ||
          lastInputHeight_ != static_cast<size_t>(X.t.size(1)) ||
          lastInputWidth_ != static_cast<size_t>(X.t.size(2)) ||

            

Reported by FlawFinder.

caffe2/operators/quantized/int8_conv_op.h
1 issues
memcpy - Does not check for buffer overflows when copying to destination
Security

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

                        (!isDepthwise && C / this->group_ < 8)) {
        buffer->Resize(std::vector<int64_t>{X.t.numel() + 8});
        inputPtr = buffer->template mutable_data<uint8_t>() + 8;
        memcpy(inputPtr, X.t.template data<uint8_t>(), X.t.numel());
      }

      if (lastBatchSize_ != static_cast<size_t>(X.t.size(0)) ||
          lastInputHeight_ != static_cast<size_t>(X.t.size(1)) ||
          lastInputWidth_ != static_cast<size_t>(X.t.size(2)) ||

            

Reported by FlawFinder.

caffe2/operators/partition_ops.h
1 issues
equal - Function does not check the second iterator for over-read conditions
Security

Line: 55 Column: 26 CWE codes: 126
Suggestion: 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

                    const auto& input = Input(i);
      CAFFE_ENFORCE(meta == input.dtype());
      CAFFE_ENFORCE_GE(input.dim(), 1);
      CAFFE_ENFORCE(std::equal(
          outShape.begin() + keysShape.size(),
          outShape.end(),
          input.sizes().begin() + 1));
      totalSize += input.size(0);
    }

            

Reported by FlawFinder.

caffe2/operators/operator_fallback_gpu_test.cc
1 issues
syntax error
Error

Line: 35

              REGISTER_CPU_OPERATOR(IncrementByOne, IncrementByOneOp);
REGISTER_CUDA_OPERATOR(IncrementByOne, GPUFallbackOp);

TEST(OperatorFallbackTest, IncrementByOneOp) {
  OperatorDef op_def = CreateOperatorDef(
      "IncrementByOne", "", vector<string>{"X"},
      vector<string>{"X"});
  Workspace ws;
  Tensor source_tensor(vector<int64_t>{2, 3}, CPU);

            

Reported by Cppcheck.

caffe2/operators/onnx_while_op.h
1 issues
memcpy - Does not check for buffer overflows when copying to destination
Security

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

                          void* dst_data =
                (char*)scan_output_target->raw_mutable_data(sot_meta) +
                timestep_size * scan_output.itemsize() * itr;
            memcpy(dst_data, src_data, timestep_size * scan_output.itemsize());
          }
        }
        scope_->set_iteration(itr + 1ll);
        scope_->template set_input_condition<CondVarType>(cur_output_condition);
      } else {

            

Reported by FlawFinder.

caffe2/operators/half_float_ops_test.cc
1 issues
syntax error
Error

Line: 68

                }
}

TEST(Float16, UniformDistributionTest) {
  Workspace ws;

  OperatorDef def;
  def.set_name("test");
  def.set_type("Float16UniformFill");

            

Reported by Cppcheck.

caffe2/operators/generate_proposals_op_util_nms_test.cc
1 issues
syntax error
Error

Line: 63

                }
}

TEST(UtilsNMSTest, TestNMS1) {
  Eigen::ArrayXXf proposals(53, 4);
  proposals << 350.9821, 161.8200, 369.9685, 205.2372, 250.5236, 154.2844,
      274.1773, 204.9810, 471.4920, 160.4118, 496.0094, 213.4244, 352.0421,
      164.5933, 366.4458, 205.9624, 166.0765, 169.7707, 183.0102, 232.6606,
      252.3000, 183.1449, 269.6541, 210.6747, 469.7862, 162.0192, 482.1673,

            

Reported by Cppcheck.

caffe2/operators/generate_proposals_op_util_nms_gpu_test.cc
1 issues
syntax error
Error

Line: 166

                }
}

TEST(UtilsNMSTest, TestPerfNMS) {
  if (!HasCudaGPU())
    return;
  const int box_dim = 4;
  const int nboxes = 6000;


            

Reported by Cppcheck.