The following issues were found

src/google/protobuf/compiler/cpp/metadata_test.cc
1 issues
syntax error
Error

Line: 110

                  "enum Enum { VALUE = 0; }\n"
    "message Message { }\n";

TEST_F(CppMetadataTest, CapturesEnumNames) {
  FileDescriptorProto file;
  GeneratedCodeInfo info;
  std::string pb_h;
  atu::AddFile("test.proto", kSmallTestFile);
  EXPECT_TRUE(

            

Reported by Cppcheck.

src/google/protobuf/stubs/status_test.cc
1 issues
syntax error
Error

Line: 78

                          util::Status(util::StatusCode::kDataLoss, "").code());
}

TEST(Status, ConstructorZero) {
  util::Status status(util::StatusCode::kOk, "msg");
  EXPECT_TRUE(status.ok());
  EXPECT_EQ("OK", status.ToString());
  EXPECT_EQ(util::OkStatus(), status);
}

            

Reported by Cppcheck.

src/google/protobuf/stubs/statusor_test.cc
1 issues
syntax error
Error

Line: 71

                const CopyNoAssign& operator=(const CopyNoAssign&);
};

TEST(StatusOr, TestDefaultCtor) {
  StatusOr<int> thing;
  EXPECT_FALSE(thing.ok());
  EXPECT_EQ(util::UnknownError(""), thing.status());
}


            

Reported by Cppcheck.

src/google/protobuf/stubs/stringpiece.cc
1 issues
memcpy - Does not check for buffer overflows when copying to destination
Security

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

              StringPiece::size_type StringPiece::copy(char* buf, size_type n,
                                         size_type pos) const {
  size_type ret = std::min(length_ - pos, n);
  memcpy(buf, ptr_ + pos, ret);
  return ret;
}

bool StringPiece::contains(StringPiece s) const {
  return find(s, 0) != npos;

            

Reported by FlawFinder.

src/google/protobuf/stubs/stringpiece.h
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: 211 Column: 27 CWE codes: 126

                StringPiece(const char* str)  // NOLINT(runtime/explicit)
      : ptr_(str), length_(0) {
    if (str != nullptr) {
      length_ = CheckSize(strlen(str));
    }
  }

  template <class Allocator>
  StringPiece(  // NOLINT(runtime/explicit)

            

Reported by FlawFinder.

python/google/protobuf/internal/__init__.py
1 issues
Trailing newlines
Error

Line: 30 Column: 1

              # THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.


            

Reported by Pylint.

src/google/protobuf/compiler/cpp/cpp_unittest.cc
1 issues
syntax error
Error

Line: 102

                EXPECT_EQ(123, message.GetExtension(ExtensionMessage::repeated_int32_ext, 0));
}

TEST(GENERATED_MESSAGE_TEST_NAME, TestConflictingEnumNames) {
  protobuf_unittest::TestConflictingEnumNames message;
  message.set_conflicting_enum(
      protobuf_unittest::TestConflictingEnumNames_while_and_);
  EXPECT_EQ(1, message.conflicting_enum());
  message.set_conflicting_enum(

            

Reported by Cppcheck.

src/google/protobuf/util/type_resolver_util_test.cc
1 issues
syntax error
Error

Line: 175

                std::unique_ptr<TypeResolver> resolver_;
};

TEST_F(DescriptorPoolTypeResolverTest, TestAllTypes) {
  Type type;
  ASSERT_TRUE(resolver_
                  ->ResolveMessageType(
                      GetTypeUrl<protobuf_unittest::TestAllTypes>(), &type)
                  .ok());

            

Reported by Cppcheck.

src/google/protobuf/stubs/structurally_valid.cc
1 issues
char - Statically-sized arrays can be improperly restricted, leading to potential overflows or other issues
Security

Line: 324 Column: 23 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

              static const unsigned char utf8acceptnonsurrogates_remap_string[] = {
0 };

static const unsigned char utf8acceptnonsurrogates_fast[256] = {
0, 0, 0, 0, 0, 0, 0, 0,  0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0,  0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0,  0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0,  0, 0, 0, 0, 0, 0, 0, 0,


            

Reported by FlawFinder.

src/google/protobuf/stubs/structurally_valid_unittest.cc
1 issues
syntax error
Error

Line: 57

                }
}

TEST(StructurallyValidTest, InvalidUTF8String) {
  const std::string invalid_str("abcd\xA0\xB0\xA0\xB0\xA0\xB0 - xyz789");
  EXPECT_FALSE(IsStructurallyValidUTF8(invalid_str.data(),
                                       invalid_str.size()));
  // Additional check for pointer alignment
  for (int i = 1; i < 8; ++i) {

            

Reported by Cppcheck.