The following issues were found
java/core/src/main/java/com/google/protobuf/ListFieldSchema.java
14 issues
Line: 76
@Override
void makeImmutableListAt(Object message, long offset) {
List<?> list = (List<?>) UnsafeUtil.getObject(message, offset);
Object immutable = null;
if (list instanceof LazyStringList) {
immutable = ((LazyStringList) list).getUnmodifiableView();
} else if (UNMODIFIABLE_LIST_CLASS.isAssignableFrom(list.getClass())) {
// already immutable
return;
Reported by PMD.
Line: 79
Object immutable = null;
if (list instanceof LazyStringList) {
immutable = ((LazyStringList) list).getUnmodifiableView();
} else if (UNMODIFIABLE_LIST_CLASS.isAssignableFrom(list.getClass())) {
// already immutable
return;
} else if (list instanceof PrimitiveNonBoxingCollection && list instanceof ProtobufList) {
if (((ProtobufList<?>) list).isModifiable()) {
((ProtobufList<?>) list).makeImmutable();
Reported by PMD.
Line: 94
}
@SuppressWarnings("unchecked")
private static <L> List<L> mutableListAt(Object message, long offset, int additionalCapacity) {
List<L> list = getList(message, offset);
if (list.isEmpty()) {
if (list instanceof LazyStringList) {
list = (List<L>) new LazyStringArrayList(additionalCapacity);
} else if (list instanceof PrimitiveNonBoxingCollection && list instanceof ProtobufList) {
Reported by PMD.
Line: 96
@SuppressWarnings("unchecked")
private static <L> List<L> mutableListAt(Object message, long offset, int additionalCapacity) {
List<L> list = getList(message, offset);
if (list.isEmpty()) {
if (list instanceof LazyStringList) {
list = (List<L>) new LazyStringArrayList(additionalCapacity);
} else if (list instanceof PrimitiveNonBoxingCollection && list instanceof ProtobufList) {
list = ((ProtobufList<L>) list).mutableCopyWithCapacity(additionalCapacity);
} else {
Reported by PMD.
Line: 127
@Override
<E> void mergeListsAt(Object msg, Object otherMsg, long offset) {
List<E> other = getList(otherMsg, offset);
List<E> mine = mutableListAt(msg, offset, other.size());
int size = mine.size();
int otherSize = other.size();
if (size > 0 && otherSize > 0) {
mine.addAll(other);
Reported by PMD.
Line: 129
List<E> other = getList(otherMsg, offset);
List<E> mine = mutableListAt(msg, offset, other.size());
int size = mine.size();
int otherSize = other.size();
if (size > 0 && otherSize > 0) {
mine.addAll(other);
}
Reported by PMD.
Line: 130
List<E> mine = mutableListAt(msg, offset, other.size());
int size = mine.size();
int otherSize = other.size();
if (size > 0 && otherSize > 0) {
mine.addAll(other);
}
List<E> merged = size > 0 ? mine : other;
Reported by PMD.
Line: 151
@Override
<L> List<L> mutableListAt(Object message, long offset) {
ProtobufList<L> list = getProtobufList(message, offset);
if (!list.isModifiable()) {
int size = list.size();
list =
list.mutableCopyWithCapacity(
size == 0 ? AbstractProtobufList.DEFAULT_CAPACITY : size * 2);
UnsafeUtil.putObject(message, offset, list);
Reported by PMD.
Line: 164
@Override
void makeImmutableListAt(Object message, long offset) {
ProtobufList<?> list = getProtobufList(message, offset);
list.makeImmutable();
}
@Override
<E> void mergeListsAt(Object msg, Object otherMsg, long offset) {
ProtobufList<E> mine = getProtobufList(msg, offset);
Reported by PMD.
Line: 172
ProtobufList<E> mine = getProtobufList(msg, offset);
ProtobufList<E> other = getProtobufList(otherMsg, offset);
int size = mine.size();
int otherSize = other.size();
if (size > 0 && otherSize > 0) {
if (!mine.isModifiable()) {
mine = mine.mutableCopyWithCapacity(size + otherSize);
}
Reported by PMD.
conformance/update_failure_list.py
14 issues
Line: 51
Column: 1
remove_set = set()
for add_file in (args.add_list or []):
with open(add_file) as f:
for line in f:
add_set.add(line)
for remove_file in (args.remove_list or []):
with open(remove_file) as f:
Reported by Pylint.
Line: 52
Column: 1
for add_file in (args.add_list or []):
with open(add_file) as f:
for line in f:
add_set.add(line)
for remove_file in (args.remove_list or []):
with open(remove_file) as f:
for line in f:
Reported by Pylint.
Line: 53
Column: 1
for add_file in (args.add_list or []):
with open(add_file) as f:
for line in f:
add_set.add(line)
for remove_file in (args.remove_list or []):
with open(remove_file) as f:
for line in f:
if line in add_set:
Reported by Pylint.
Line: 56
Column: 1
add_set.add(line)
for remove_file in (args.remove_list or []):
with open(remove_file) as f:
for line in f:
if line in add_set:
raise Exception("Asked to both add and remove test: " + line)
remove_set.add(line.strip())
Reported by Pylint.
Line: 57
Column: 1
for remove_file in (args.remove_list or []):
with open(remove_file) as f:
for line in f:
if line in add_set:
raise Exception("Asked to both add and remove test: " + line)
remove_set.add(line.strip())
add_list = sorted(add_set, reverse=True)
Reported by Pylint.
Line: 58
Column: 1
for remove_file in (args.remove_list or []):
with open(remove_file) as f:
for line in f:
if line in add_set:
raise Exception("Asked to both add and remove test: " + line)
remove_set.add(line.strip())
add_list = sorted(add_set, reverse=True)
Reported by Pylint.
Line: 59
Column: 1
with open(remove_file) as f:
for line in f:
if line in add_set:
raise Exception("Asked to both add and remove test: " + line)
remove_set.add(line.strip())
add_list = sorted(add_set, reverse=True)
with open(args.filename) as in_file:
Reported by Pylint.
Line: 60
Column: 1
for line in f:
if line in add_set:
raise Exception("Asked to both add and remove test: " + line)
remove_set.add(line.strip())
add_list = sorted(add_set, reverse=True)
with open(args.filename) as in_file:
existing_list = in_file.read()
Reported by Pylint.
Line: 68
Column: 1
existing_list = in_file.read()
with open(args.filename, "w") as f:
for line in existing_list.splitlines(True):
test = line.split("#")[0].strip()
while len(add_list) > 0 and test > add_list[-1]:
f.write(add_list.pop())
if test not in remove_set:
f.write(line)
Reported by Pylint.
Line: 69
Column: 1
with open(args.filename, "w") as f:
for line in existing_list.splitlines(True):
test = line.split("#")[0].strip()
while len(add_list) > 0 and test > add_list[-1]:
f.write(add_list.pop())
if test not in remove_set:
f.write(line)
Reported by Pylint.
java/core/src/main/java/com/google/protobuf/UnknownFieldSetLite.java
14 issues
Line: 234
break;
default:
// TODO(liujisi): Change writeTo to throw IOException?
throw new RuntimeException(InvalidProtocolBufferException.invalidWireType());
}
}
/**
* Get the number of bytes required to encode this field, including field number, using {@code
Reported by PMD.
Line: 46
*
* @author dweis@google.com (Daniel Weis)
*/
public final class UnknownFieldSetLite {
// Arbitrarily chosen.
// TODO(dweis): Tune this number?
private static final int MIN_CAPACITY = 8;
Reported by PMD.
Line: 46
*
* @author dweis@google.com (Daniel Weis)
*/
public final class UnknownFieldSetLite {
// Arbitrarily chosen.
// TODO(dweis): Tune this number?
private static final int MIN_CAPACITY = 8;
Reported by PMD.
Line: 83
}
/** The number of elements in the set. */
private int count;
/** The tag numbers for the elements in the set. */
private int[] tags;
/** The boxed values of the elements in the set. */
Reported by PMD.
Line: 86
private int count;
/** The tag numbers for the elements in the set. */
private int[] tags;
/** The boxed values of the elements in the set. */
private Object[] objects;
/** The lazily computed serialized size of the set. */
Reported by PMD.
Line: 89
private int[] tags;
/** The boxed values of the elements in the set. */
private Object[] objects;
/** The lazily computed serialized size of the set. */
private int memoizedSerializedSize = -1;
/** Indicates that this object is mutable. */
Reported by PMD.
Line: 92
private Object[] objects;
/** The lazily computed serialized size of the set. */
private int memoizedSerializedSize = -1;
/** Indicates that this object is mutable. */
private boolean isMutable;
/** Constructs a mutable {@code UnknownFieldSetLite}. */
Reported by PMD.
Line: 95
private int memoizedSerializedSize = -1;
/** Indicates that this object is mutable. */
private boolean isMutable;
/** Constructs a mutable {@code UnknownFieldSetLite}. */
private UnknownFieldSetLite() {
this(0, new int[MIN_CAPACITY], new Object[MIN_CAPACITY], /* isMutable= */ true);
}
Reported by PMD.
Line: 337
}
UnknownFieldSetLite other = (UnknownFieldSetLite) obj;
if (count != other.count
|| !tagsEquals(tags, other.tags, count)
|| !objectsEquals(objects, other.objects, count)) {
return false;
}
Reported by PMD.
Line: 134
public void writeTo(CodedOutputStream output) throws IOException {
for (int i = 0; i < count; i++) {
int tag = tags[i];
int fieldNumber = WireFormat.getTagFieldNumber(tag);
switch (WireFormat.getTagWireType(tag)) {
case WireFormat.WIRETYPE_VARINT:
output.writeUInt64(fieldNumber, (Long) objects[i]);
break;
case WireFormat.WIRETYPE_FIXED32:
Reported by PMD.
java/core/src/main/java/com/google/protobuf/StructuralMessageInfo.java
14 issues
Line: 44
* contained within a message.
*/
@ExperimentalApi
final class StructuralMessageInfo implements MessageInfo {
private final ProtoSyntax syntax;
private final boolean messageSetWireFormat;
private final int[] checkInitialized;
private final FieldInfo[] fields;
private final MessageLite defaultInstance;
Reported by PMD.
Line: 60
StructuralMessageInfo(
ProtoSyntax syntax,
boolean messageSetWireFormat,
int[] checkInitialized,
FieldInfo[] fields,
Object defaultInstance) {
this.syntax = syntax;
this.messageSetWireFormat = messageSetWireFormat;
this.checkInitialized = checkInitialized;
Reported by PMD.
Line: 61
ProtoSyntax syntax,
boolean messageSetWireFormat,
int[] checkInitialized,
FieldInfo[] fields,
Object defaultInstance) {
this.syntax = syntax;
this.messageSetWireFormat = messageSetWireFormat;
this.checkInitialized = checkInitialized;
this.fields = fields;
Reported by PMD.
Line: 84
/** An array of field numbers that need to be checked for isInitialized(). */
public int[] getCheckInitialized() {
return checkInitialized;
}
/**
* Gets the information for all fields within this message, sorted in ascending order by their
* field number.
Reported by PMD.
Line: 92
* field number.
*/
public FieldInfo[] getFields() {
return fields;
}
@Override
public MessageLite getDefaultInstance() {
return defaultInstance;
Reported by PMD.
Line: 112
/** A builder of {@link MessageInfo} instances. */
public static final class Builder {
private final List<FieldInfo> fields;
private ProtoSyntax syntax;
private boolean wasBuilt;
private boolean messageSetWireFormat;
private int[] checkInitialized = null;
private Object defaultInstance;
Reported by PMD.
Line: 113
/** A builder of {@link MessageInfo} instances. */
public static final class Builder {
private final List<FieldInfo> fields;
private ProtoSyntax syntax;
private boolean wasBuilt;
private boolean messageSetWireFormat;
private int[] checkInitialized = null;
private Object defaultInstance;
Reported by PMD.
Line: 114
public static final class Builder {
private final List<FieldInfo> fields;
private ProtoSyntax syntax;
private boolean wasBuilt;
private boolean messageSetWireFormat;
private int[] checkInitialized = null;
private Object defaultInstance;
public Builder() {
Reported by PMD.
Line: 115
private final List<FieldInfo> fields;
private ProtoSyntax syntax;
private boolean wasBuilt;
private boolean messageSetWireFormat;
private int[] checkInitialized = null;
private Object defaultInstance;
public Builder() {
fields = new ArrayList<FieldInfo>();
Reported by PMD.
Line: 116
private ProtoSyntax syntax;
private boolean wasBuilt;
private boolean messageSetWireFormat;
private int[] checkInitialized = null;
private Object defaultInstance;
public Builder() {
fields = new ArrayList<FieldInfo>();
}
Reported by PMD.
python/google/protobuf/internal/message_listener.py
14 issues
Line: 40
Column: 1
__author__ = 'robinson@google.com (Will Robinson)'
class MessageListener(object):
"""Listens for modifications made to a message. Meant to be registered via
Message._SetListener().
Attributes:
Reported by Pylint.
Line: 40
Column: 1
__author__ = 'robinson@google.com (Will Robinson)'
class MessageListener(object):
"""Listens for modifications made to a message. Meant to be registered via
Message._SetListener().
Attributes:
Reported by Pylint.
Line: 42
Column: 1
class MessageListener(object):
"""Listens for modifications made to a message. Meant to be registered via
Message._SetListener().
Attributes:
dirty: If True, then calling Modified() would be a no-op. This can be
used to avoid these calls entirely in the common case.
Reported by Pylint.
Line: 50
Column: 3
used to avoid these calls entirely in the common case.
"""
def Modified(self):
"""Called every time the message is modified in such a way that the parent
message may need to be updated. This currently means either:
(a) The message was modified for the first time, so the parent message
should henceforth mark the message as present.
(b) The message's cached byte size became dirty -- i.e. the message was
Reported by Pylint.
Line: 50
Column: 1
used to avoid these calls entirely in the common case.
"""
def Modified(self):
"""Called every time the message is modified in such a way that the parent
message may need to be updated. This currently means either:
(a) The message was modified for the first time, so the parent message
should henceforth mark the message as present.
(b) The message's cached byte size became dirty -- i.e. the message was
Reported by Pylint.
Line: 51
Column: 1
"""
def Modified(self):
"""Called every time the message is modified in such a way that the parent
message may need to be updated. This currently means either:
(a) The message was modified for the first time, so the parent message
should henceforth mark the message as present.
(b) The message's cached byte size became dirty -- i.e. the message was
modified for the first time after a previous call to ByteSize().
Reported by Pylint.
Line: 70
Column: 1
it will be true most of the time.
"""
raise NotImplementedError
class NullMessageListener(object):
"""No-op MessageListener implementation."""
Reported by Pylint.
Line: 73
Column: 1
raise NotImplementedError
class NullMessageListener(object):
"""No-op MessageListener implementation."""
def Modified(self):
pass
Reported by Pylint.
Line: 73
Column: 1
raise NotImplementedError
class NullMessageListener(object):
"""No-op MessageListener implementation."""
def Modified(self):
pass
Reported by Pylint.
Line: 75
Column: 1
class NullMessageListener(object):
"""No-op MessageListener implementation."""
def Modified(self):
pass
Reported by Pylint.
src/google/protobuf/compiler/cpp/cpp_parse_function_generator.cc
14 issues
Line: 85
Column: 10
CWE codes:
120
}
std::string TcParserBaseName(const Options& options) {
return StrCat("::", ProtobufNamespace(options),
"::internal::TcParserBase::");
}
std::string MessageTcParseFunctionName(const FieldDescriptor* field,
const Options& options) {
Reported by FlawFinder.
Line: 97
Column: 12
CWE codes:
120
// `ZeroFieldsBase`, we need to call the `_InternalParse` function, because
// there is no generated tailcall function. For tailcall parsing, this is
// done by helpers in TcParserBase.
return StrCat(TcParserBaseName(options),
(field->is_repeated() ? "Repeated" : "Singular"),
"ParseMessage<",
QualifiedClassName(field->message_type()), //
", ", TagType(field), ">");
}
Reported by FlawFinder.
Line: 104
Column: 10
CWE codes:
120
", ", TagType(field), ">");
}
// This matches macros in generated_message_tctable_impl.h:
return StrCat("PROTOBUF_TC_PARSE_",
(field->is_repeated() ? "REPEATED" : "SINGULAR"),
TagSize(field->number()), "(",
QualifiedClassName(field->message_type()), ")");
}
Reported by FlawFinder.
Line: 697
Column: 18
CWE codes:
120
std::string field_name;
field_name = "nullptr";
if (HasDescriptorMethods(field->file(), options_)) {
field_name = StrCat("\"", field->full_name(), "\"");
}
format("::$proto_ns$::internal::VerifyUTF8(str, $1$)", field_name);
switch (level) {
case Utf8CheckMode::kNone:
return;
Reported by FlawFinder.
Line: 830
Column: 34
CWE codes:
120
{{"name", FieldName(field)},
{"primitive_type", PrimitiveTypeName(options_, field->cpp_type())}});
if (field->is_repeated()) {
format.AddMap({{"put_field", StrCat("add_", FieldName(field))},
{"mutable_field", StrCat("add_", FieldName(field))}});
} else {
format.AddMap(
{{"put_field", StrCat("set_", FieldName(field))},
{"mutable_field", StrCat("mutable_", FieldName(field))}});
Reported by FlawFinder.
Line: 831
Column: 38
CWE codes:
120
{"primitive_type", PrimitiveTypeName(options_, field->cpp_type())}});
if (field->is_repeated()) {
format.AddMap({{"put_field", StrCat("add_", FieldName(field))},
{"mutable_field", StrCat("add_", FieldName(field))}});
} else {
format.AddMap(
{{"put_field", StrCat("set_", FieldName(field))},
{"mutable_field", StrCat("mutable_", FieldName(field))}});
}
Reported by FlawFinder.
Line: 834
Column: 24
CWE codes:
120
{"mutable_field", StrCat("add_", FieldName(field))}});
} else {
format.AddMap(
{{"put_field", StrCat("set_", FieldName(field))},
{"mutable_field", StrCat("mutable_", FieldName(field))}});
}
uint32_t tag = WireFormatLite::MakeTag(field->number(), wiretype);
switch (wiretype) {
case WireFormatLite::WIRETYPE_VARINT: {
Reported by FlawFinder.
Line: 835
Column: 28
CWE codes:
120
} else {
format.AddMap(
{{"put_field", StrCat("set_", FieldName(field))},
{"mutable_field", StrCat("mutable_", FieldName(field))}});
}
uint32_t tag = WireFormatLite::MakeTag(field->number(), wiretype);
switch (wiretype) {
case WireFormatLite::WIRETYPE_VARINT: {
std::string type = PrimitiveTypeName(options_, field->cpp_type());
Reported by FlawFinder.
Line: 1191
Column: 18
CWE codes:
120
break;
default:
name = StrCat("TcParser<", table_size_log2, ">::");
break;
}
}
// The field implementation functions are prefixed by cardinality:
Reported by FlawFinder.
Line: 1278
Column: 11
CWE codes:
120
case TypeFormat::kVar32:
case TypeFormat::kBool:
name.append(
StrCat(", ", TcParserBaseName(options), "kNoConversion"));
break;
case TypeFormat::kSInt64:
case TypeFormat::kSInt32:
name.append(StrCat(", ", TcParserBaseName(options), "kZigZag"));
Reported by FlawFinder.
java/core/src/test/java/com/google/protobuf/CachedFieldSizeTest.java
13 issues
Line: 46
public final class CachedFieldSizeTest {
// Regression test for b/74087933
@Test
public void testCachedFieldSize() throws Exception {
TestCachedFieldSizeMessage.Builder builder = TestCachedFieldSizeMessage.newBuilder();
builder.setProto2Child(TestUtil.getPackedSet());
builder.setProto3Child(
UnittestProto3.TestPackedTypes.parseFrom(TestUtil.getPackedSet().toByteArray()));
TestCachedFieldSizeMessage message = builder.build();
Reported by PMD.
Line: 50
TestCachedFieldSizeMessage.Builder builder = TestCachedFieldSizeMessage.newBuilder();
builder.setProto2Child(TestUtil.getPackedSet());
builder.setProto3Child(
UnittestProto3.TestPackedTypes.parseFrom(TestUtil.getPackedSet().toByteArray()));
TestCachedFieldSizeMessage message = builder.build();
// Serialize once to cache all field sizes. This will use the experimental runtime because
// the proto has optimize_for = CODE_SIZE.
message.toByteArray();
Reported by PMD.
Line: 50
TestCachedFieldSizeMessage.Builder builder = TestCachedFieldSizeMessage.newBuilder();
builder.setProto2Child(TestUtil.getPackedSet());
builder.setProto3Child(
UnittestProto3.TestPackedTypes.parseFrom(TestUtil.getPackedSet().toByteArray()));
TestCachedFieldSizeMessage message = builder.build();
// Serialize once to cache all field sizes. This will use the experimental runtime because
// the proto has optimize_for = CODE_SIZE.
message.toByteArray();
Reported by PMD.
Line: 55
// Serialize once to cache all field sizes. This will use the experimental runtime because
// the proto has optimize_for = CODE_SIZE.
message.toByteArray();
// Serialize individual submessages. This will use the generated implementation. If the
// experimental runtime hasn't set the correct cached size, this will throw an exception.
byte[] data2 = message.getProto2Child().toByteArray();
byte[] data3 = message.getProto3Child().toByteArray();
Reported by PMD.
Line: 58
message.toByteArray();
// Serialize individual submessages. This will use the generated implementation. If the
// experimental runtime hasn't set the correct cached size, this will throw an exception.
byte[] data2 = message.getProto2Child().toByteArray();
byte[] data3 = message.getProto3Child().toByteArray();
// Make sure the serialized data is correct.
assertThat(TestPackedTypes.parseFrom(data2)).isEqualTo(message.getProto2Child());
assertThat(UnittestProto3.TestPackedTypes.parseFrom(data3)).isEqualTo(message.getProto3Child());
Reported by PMD.
Line: 58
message.toByteArray();
// Serialize individual submessages. This will use the generated implementation. If the
// experimental runtime hasn't set the correct cached size, this will throw an exception.
byte[] data2 = message.getProto2Child().toByteArray();
byte[] data3 = message.getProto3Child().toByteArray();
// Make sure the serialized data is correct.
assertThat(TestPackedTypes.parseFrom(data2)).isEqualTo(message.getProto2Child());
assertThat(UnittestProto3.TestPackedTypes.parseFrom(data3)).isEqualTo(message.getProto3Child());
Reported by PMD.
Line: 59
// Serialize individual submessages. This will use the generated implementation. If the
// experimental runtime hasn't set the correct cached size, this will throw an exception.
byte[] data2 = message.getProto2Child().toByteArray();
byte[] data3 = message.getProto3Child().toByteArray();
// Make sure the serialized data is correct.
assertThat(TestPackedTypes.parseFrom(data2)).isEqualTo(message.getProto2Child());
assertThat(UnittestProto3.TestPackedTypes.parseFrom(data3)).isEqualTo(message.getProto3Child());
}
Reported by PMD.
Line: 59
// Serialize individual submessages. This will use the generated implementation. If the
// experimental runtime hasn't set the correct cached size, this will throw an exception.
byte[] data2 = message.getProto2Child().toByteArray();
byte[] data3 = message.getProto3Child().toByteArray();
// Make sure the serialized data is correct.
assertThat(TestPackedTypes.parseFrom(data2)).isEqualTo(message.getProto2Child());
assertThat(UnittestProto3.TestPackedTypes.parseFrom(data3)).isEqualTo(message.getProto3Child());
}
Reported by PMD.
Line: 62
byte[] data3 = message.getProto3Child().toByteArray();
// Make sure the serialized data is correct.
assertThat(TestPackedTypes.parseFrom(data2)).isEqualTo(message.getProto2Child());
assertThat(UnittestProto3.TestPackedTypes.parseFrom(data3)).isEqualTo(message.getProto3Child());
}
}
Reported by PMD.
Line: 62
byte[] data3 = message.getProto3Child().toByteArray();
// Make sure the serialized data is correct.
assertThat(TestPackedTypes.parseFrom(data2)).isEqualTo(message.getProto2Child());
assertThat(UnittestProto3.TestPackedTypes.parseFrom(data3)).isEqualTo(message.getProto3Child());
}
}
Reported by PMD.
java/core/src/main/java/com/google/protobuf/IterableByteBufferInputStream.java
13 issues
Line: 129
}
@Override
public int read(byte[] output, int offset, int length) throws IOException {
if (currentIndex == dataSize) {
return -1;
}
int remaining = currentByteBuffer.limit() - currentByteBufferPos;
if (length > remaining) {
Reported by PMD.
Line: 42
class IterableByteBufferInputStream extends InputStream {
/** The {@link Iterator} with type {@link ByteBuffer} of {@code input} */
private Iterator<ByteBuffer> iterator;
/** The current ByteBuffer; */
private ByteBuffer currentByteBuffer;
/** The number of ByteBuffers in the input data. */
private int dataSize;
/**
Reported by PMD.
Line: 42
class IterableByteBufferInputStream extends InputStream {
/** The {@link Iterator} with type {@link ByteBuffer} of {@code input} */
private Iterator<ByteBuffer> iterator;
/** The current ByteBuffer; */
private ByteBuffer currentByteBuffer;
/** The number of ByteBuffers in the input data. */
private int dataSize;
/**
Reported by PMD.
Line: 44
/** The {@link Iterator} with type {@link ByteBuffer} of {@code input} */
private Iterator<ByteBuffer> iterator;
/** The current ByteBuffer; */
private ByteBuffer currentByteBuffer;
/** The number of ByteBuffers in the input data. */
private int dataSize;
/**
* Current {@code ByteBuffer}'s index
*
Reported by PMD.
Line: 46
/** The current ByteBuffer; */
private ByteBuffer currentByteBuffer;
/** The number of ByteBuffers in the input data. */
private int dataSize;
/**
* Current {@code ByteBuffer}'s index
*
* <p>If index equals dataSize, then all the data in the InputStream has been consumed
*/
Reported by PMD.
Line: 52
*
* <p>If index equals dataSize, then all the data in the InputStream has been consumed
*/
private int currentIndex;
/** The current position for current ByteBuffer */
private int currentByteBufferPos;
/** Whether current ByteBuffer has an array */
private boolean hasArray;
/**
Reported by PMD.
Line: 54
*/
private int currentIndex;
/** The current position for current ByteBuffer */
private int currentByteBufferPos;
/** Whether current ByteBuffer has an array */
private boolean hasArray;
/**
* If the current ByteBuffer is unsafe-direct based, currentArray is null; otherwise should be the
* array inside ByteBuffer.
Reported by PMD.
Line: 56
/** The current position for current ByteBuffer */
private int currentByteBufferPos;
/** Whether current ByteBuffer has an array */
private boolean hasArray;
/**
* If the current ByteBuffer is unsafe-direct based, currentArray is null; otherwise should be the
* array inside ByteBuffer.
*/
private byte[] currentArray;
Reported by PMD.
Line: 61
* If the current ByteBuffer is unsafe-direct based, currentArray is null; otherwise should be the
* array inside ByteBuffer.
*/
private byte[] currentArray;
/** Current ByteBuffer's array offset */
private int currentArrayOffset;
/**
* If the current ByteBuffer is unsafe-direct based, currentAddress is the start address of this
* ByteBuffer; otherwise should be zero.
Reported by PMD.
Line: 63
*/
private byte[] currentArray;
/** Current ByteBuffer's array offset */
private int currentArrayOffset;
/**
* If the current ByteBuffer is unsafe-direct based, currentAddress is the start address of this
* ByteBuffer; otherwise should be zero.
*/
private long currentAddress;
Reported by PMD.
src/google/protobuf/descriptor.pb.cc
13 issues
Line: 10819
// @@protoc_insertion_point(namespace_scope)
PROTOBUF_NAMESPACE_CLOSE
PROTOBUF_NAMESPACE_OPEN
template<> PROTOBUF_NOINLINE ::PROTOBUF_NAMESPACE_ID::FileDescriptorSet* Arena::CreateMaybeMessage< ::PROTOBUF_NAMESPACE_ID::FileDescriptorSet >(Arena* arena) {
return Arena::CreateMessageInternal< ::PROTOBUF_NAMESPACE_ID::FileDescriptorSet >(arena);
}
template<> PROTOBUF_NOINLINE ::PROTOBUF_NAMESPACE_ID::FileDescriptorProto* Arena::CreateMaybeMessage< ::PROTOBUF_NAMESPACE_ID::FileDescriptorProto >(Arena* arena) {
return Arena::CreateMessageInternal< ::PROTOBUF_NAMESPACE_ID::FileDescriptorProto >(arena);
Reported by Cppcheck.
Line: 2156
Column: 5
CWE codes:
120
Suggestion:
Make sure destination can always hold the source data
} else {
options_ = nullptr;
}
::memcpy(&start_, &from.start_,
static_cast<size_t>(reinterpret_cast<char*>(&end_) -
reinterpret_cast<char*>(&start_)) + sizeof(end_));
// @@protoc_insertion_point(copy_constructor:google.protobuf.DescriptorProto.ExtensionRange)
}
Reported by FlawFinder.
Line: 2427
Column: 5
CWE codes:
120
Suggestion:
Make sure destination can always hold the source data
: ::PROTOBUF_NAMESPACE_ID::Message(),
_has_bits_(from._has_bits_) {
_internal_metadata_.MergeFrom<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(from._internal_metadata_);
::memcpy(&start_, &from.start_,
static_cast<size_t>(reinterpret_cast<char*>(&end_) -
reinterpret_cast<char*>(&start_)) + sizeof(end_));
// @@protoc_insertion_point(copy_constructor:google.protobuf.DescriptorProto.ReservedRange)
}
Reported by FlawFinder.
Line: 3478
Column: 5
CWE codes:
120
Suggestion:
Make sure destination can always hold the source data
} else {
options_ = nullptr;
}
::memcpy(&number_, &from.number_,
static_cast<size_t>(reinterpret_cast<char*>(&type_) -
reinterpret_cast<char*>(&number_)) + sizeof(type_));
// @@protoc_insertion_point(copy_constructor:google.protobuf.FieldDescriptorProto)
}
Reported by FlawFinder.
Line: 4327
Column: 5
CWE codes:
120
Suggestion:
Make sure destination can always hold the source data
: ::PROTOBUF_NAMESPACE_ID::Message(),
_has_bits_(from._has_bits_) {
_internal_metadata_.MergeFrom<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(from._internal_metadata_);
::memcpy(&start_, &from.start_,
static_cast<size_t>(reinterpret_cast<char*>(&end_) -
reinterpret_cast<char*>(&start_)) + sizeof(end_));
// @@protoc_insertion_point(copy_constructor:google.protobuf.EnumDescriptorProto.EnumReservedRange)
}
Reported by FlawFinder.
Line: 5586
Column: 5
CWE codes:
120
Suggestion:
Make sure destination can always hold the source data
} else {
options_ = nullptr;
}
::memcpy(&client_streaming_, &from.client_streaming_,
static_cast<size_t>(reinterpret_cast<char*>(&server_streaming_) -
reinterpret_cast<char*>(&client_streaming_)) + sizeof(server_streaming_));
// @@protoc_insertion_point(copy_constructor:google.protobuf.MethodDescriptorProto)
}
Reported by FlawFinder.
Line: 6093
Column: 5
CWE codes:
120
Suggestion:
Make sure destination can always hold the source data
ruby_package_.Set(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, from._internal_ruby_package(),
GetArenaForAllocation());
}
::memcpy(&java_multiple_files_, &from.java_multiple_files_,
static_cast<size_t>(reinterpret_cast<char*>(&cc_enable_arenas_) -
reinterpret_cast<char*>(&java_multiple_files_)) + sizeof(cc_enable_arenas_));
// @@protoc_insertion_point(copy_constructor:google.protobuf.FileOptions)
}
Reported by FlawFinder.
Line: 7026
Column: 5
CWE codes:
120
Suggestion:
Make sure destination can always hold the source data
uninterpreted_option_(from.uninterpreted_option_) {
_internal_metadata_.MergeFrom<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(from._internal_metadata_);
_extensions_.MergeFrom(from._extensions_);
::memcpy(&message_set_wire_format_, &from.message_set_wire_format_,
static_cast<size_t>(reinterpret_cast<char*>(&map_entry_) -
reinterpret_cast<char*>(&message_set_wire_format_)) + sizeof(map_entry_));
// @@protoc_insertion_point(copy_constructor:google.protobuf.MessageOptions)
}
Reported by FlawFinder.
Line: 7372
Column: 5
CWE codes:
120
Suggestion:
Make sure destination can always hold the source data
uninterpreted_option_(from.uninterpreted_option_) {
_internal_metadata_.MergeFrom<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(from._internal_metadata_);
_extensions_.MergeFrom(from._extensions_);
::memcpy(&ctype_, &from.ctype_,
static_cast<size_t>(reinterpret_cast<char*>(&jstype_) -
reinterpret_cast<char*>(&ctype_)) + sizeof(jstype_));
// @@protoc_insertion_point(copy_constructor:google.protobuf.FieldOptions)
}
Reported by FlawFinder.
Line: 7973
Column: 5
CWE codes:
120
Suggestion:
Make sure destination can always hold the source data
uninterpreted_option_(from.uninterpreted_option_) {
_internal_metadata_.MergeFrom<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(from._internal_metadata_);
_extensions_.MergeFrom(from._extensions_);
::memcpy(&allow_alias_, &from.allow_alias_,
static_cast<size_t>(reinterpret_cast<char*>(&deprecated_) -
reinterpret_cast<char*>(&allow_alias_)) + sizeof(deprecated_));
// @@protoc_insertion_point(copy_constructor:google.protobuf.EnumOptions)
}
Reported by FlawFinder.
src/google/protobuf/stubs/strutil.h
13 issues
Line: 706
Column: 29
CWE codes:
120
// be a reference into str.
// ----------------------------------------------------------------------
PROTOBUF_EXPORT std::string StrCat(const AlphaNum& a, const AlphaNum& b);
PROTOBUF_EXPORT std::string StrCat(const AlphaNum& a, const AlphaNum& b,
const AlphaNum& c);
PROTOBUF_EXPORT std::string StrCat(const AlphaNum& a, const AlphaNum& b,
const AlphaNum& c, const AlphaNum& d);
PROTOBUF_EXPORT std::string StrCat(const AlphaNum& a, const AlphaNum& b,
Reported by FlawFinder.
Line: 707
Column: 29
CWE codes:
120
// ----------------------------------------------------------------------
PROTOBUF_EXPORT std::string StrCat(const AlphaNum& a, const AlphaNum& b);
PROTOBUF_EXPORT std::string StrCat(const AlphaNum& a, const AlphaNum& b,
const AlphaNum& c);
PROTOBUF_EXPORT std::string StrCat(const AlphaNum& a, const AlphaNum& b,
const AlphaNum& c, const AlphaNum& d);
PROTOBUF_EXPORT std::string StrCat(const AlphaNum& a, const AlphaNum& b,
const AlphaNum& c, const AlphaNum& d,
Reported by FlawFinder.
Line: 709
Column: 29
CWE codes:
120
PROTOBUF_EXPORT std::string StrCat(const AlphaNum& a, const AlphaNum& b);
PROTOBUF_EXPORT std::string StrCat(const AlphaNum& a, const AlphaNum& b,
const AlphaNum& c);
PROTOBUF_EXPORT std::string StrCat(const AlphaNum& a, const AlphaNum& b,
const AlphaNum& c, const AlphaNum& d);
PROTOBUF_EXPORT std::string StrCat(const AlphaNum& a, const AlphaNum& b,
const AlphaNum& c, const AlphaNum& d,
const AlphaNum& e);
PROTOBUF_EXPORT std::string StrCat(const AlphaNum& a, const AlphaNum& b,
Reported by FlawFinder.
Line: 711
Column: 29
CWE codes:
120
const AlphaNum& c);
PROTOBUF_EXPORT std::string StrCat(const AlphaNum& a, const AlphaNum& b,
const AlphaNum& c, const AlphaNum& d);
PROTOBUF_EXPORT std::string StrCat(const AlphaNum& a, const AlphaNum& b,
const AlphaNum& c, const AlphaNum& d,
const AlphaNum& e);
PROTOBUF_EXPORT std::string StrCat(const AlphaNum& a, const AlphaNum& b,
const AlphaNum& c, const AlphaNum& d,
const AlphaNum& e, const AlphaNum& f);
Reported by FlawFinder.
Line: 714
Column: 29
CWE codes:
120
PROTOBUF_EXPORT std::string StrCat(const AlphaNum& a, const AlphaNum& b,
const AlphaNum& c, const AlphaNum& d,
const AlphaNum& e);
PROTOBUF_EXPORT std::string StrCat(const AlphaNum& a, const AlphaNum& b,
const AlphaNum& c, const AlphaNum& d,
const AlphaNum& e, const AlphaNum& f);
PROTOBUF_EXPORT std::string StrCat(const AlphaNum& a, const AlphaNum& b,
const AlphaNum& c, const AlphaNum& d,
const AlphaNum& e, const AlphaNum& f,
Reported by FlawFinder.
Line: 717
Column: 29
CWE codes:
120
PROTOBUF_EXPORT std::string StrCat(const AlphaNum& a, const AlphaNum& b,
const AlphaNum& c, const AlphaNum& d,
const AlphaNum& e, const AlphaNum& f);
PROTOBUF_EXPORT std::string StrCat(const AlphaNum& a, const AlphaNum& b,
const AlphaNum& c, const AlphaNum& d,
const AlphaNum& e, const AlphaNum& f,
const AlphaNum& g);
PROTOBUF_EXPORT std::string StrCat(const AlphaNum& a, const AlphaNum& b,
const AlphaNum& c, const AlphaNum& d,
Reported by FlawFinder.
Line: 721
Column: 29
CWE codes:
120
const AlphaNum& c, const AlphaNum& d,
const AlphaNum& e, const AlphaNum& f,
const AlphaNum& g);
PROTOBUF_EXPORT std::string StrCat(const AlphaNum& a, const AlphaNum& b,
const AlphaNum& c, const AlphaNum& d,
const AlphaNum& e, const AlphaNum& f,
const AlphaNum& g, const AlphaNum& h);
PROTOBUF_EXPORT std::string StrCat(const AlphaNum& a, const AlphaNum& b,
const AlphaNum& c, const AlphaNum& d,
Reported by FlawFinder.
Line: 725
Column: 29
CWE codes:
120
const AlphaNum& c, const AlphaNum& d,
const AlphaNum& e, const AlphaNum& f,
const AlphaNum& g, const AlphaNum& h);
PROTOBUF_EXPORT std::string StrCat(const AlphaNum& a, const AlphaNum& b,
const AlphaNum& c, const AlphaNum& d,
const AlphaNum& e, const AlphaNum& f,
const AlphaNum& g, const AlphaNum& h,
const AlphaNum& i);
Reported by FlawFinder.
Line: 731
Column: 20
CWE codes:
120
const AlphaNum& g, const AlphaNum& h,
const AlphaNum& i);
inline std::string StrCat(const AlphaNum& a) {
return std::string(a.data(), a.size());
}
// ----------------------------------------------------------------------
// StrAppend()
Reported by FlawFinder.
Line: 621
Column: 3
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
const char *piece_data_; // move these to string_ref eventually
size_t piece_size_; // move these to string_ref eventually
char digits[kFastToBufferSize];
// No bool ctor -- bools convert to an integral type.
// A bool ctor would also convert incoming pointers (bletch).
AlphaNum(int i32)
Reported by FlawFinder.