The following issues were found
src/google/protobuf/inlined_string_field.h
1 issues
Line: 275
Column: 24
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
PROTOBUF_NDEBUG_INLINE std::string* get_mutable();
PROTOBUF_NDEBUG_INLINE const std::string* get_const() const;
alignas(std::string) char value_[sizeof(std::string)];
std::string* MutableSlow(::google::protobuf::Arena* arena, bool donated,
uint32_t* donating_states, uint32_t mask);
Reported by FlawFinder.
src/google/protobuf/inlined_string_field_unittest.cc
1 issues
Line: 63
const uint32 kMask1 = ~0x00000004u;
const uint32 kMask2 = ~0x00000020u;
TEST(InlinedStringFieldTest, SetOnHeap) {
InlinedStringField field;
uint32 donating_states = 0;
const std::string kDefaultValue = "default";
field.Set(&kDefaultValue, WrapString("Test short"), nullptr, false,
&donating_states, kMask);
Reported by Cppcheck.
src/google/protobuf/extension_set_unittest.cc
1 issues
Line: 69
// This test closely mirrors net/proto2/compiler/cpp/internal/unittest.cc
// except that it uses extensions rather than regular fields.
TEST(ExtensionSetTest, Defaults) {
// Check that all default values are set correctly in the initial message.
unittest::TestAllExtensions message;
TestUtil::ExpectExtensionsClear(message);
Reported by Cppcheck.
src/google/protobuf/empty.pb.cc
1 issues
Line: 115
// @@protoc_insertion_point(namespace_scope)
PROTOBUF_NAMESPACE_CLOSE
PROTOBUF_NAMESPACE_OPEN
template<> PROTOBUF_NOINLINE ::PROTOBUF_NAMESPACE_ID::Empty* Arena::CreateMaybeMessage< ::PROTOBUF_NAMESPACE_ID::Empty >(Arena* arena) {
return Arena::CreateMessageInternal< ::PROTOBUF_NAMESPACE_ID::Empty >(arena);
}
PROTOBUF_NAMESPACE_CLOSE
Reported by Cppcheck.
java/core/src/main/java/com/google/protobuf/BufferAllocator.java
1 issues
Line: 41
*/
@ExperimentalApi
abstract class BufferAllocator {
private static final BufferAllocator UNPOOLED =
new BufferAllocator() {
@Override
public AllocatedBuffer allocateHeapBuffer(int capacity) {
return AllocatedBuffer.wrap(new byte[capacity]);
}
Reported by PMD.
src/google/protobuf/dynamic_message_unittest.cc
1 issues
Line: 126
}
};
TEST_F(DynamicMessageTest, Descriptor) {
// Check that the descriptor on the DynamicMessage matches the descriptor
// passed to GetPrototype().
EXPECT_EQ(prototype_->GetDescriptor(), descriptor_);
}
Reported by Cppcheck.