Skip to content

Commit 4008d22

Browse files
committed
Sync from Piper @366297034
PROTOBUF_SYNC_PIPER
1 parent 4a6dc34 commit 4008d22

File tree

15 files changed

+151
-86
lines changed

15 files changed

+151
-86
lines changed

.github/mergeable.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ mergeable:
1111
regex: 'release notes: yes'
1212
message: 'Please include release notes: yes'
1313
- must_include:
14-
regex: '^(autotools|bazel|c#|c\+\+|cleanup|cmake|conformance tests|integration|go|java|javascript|objective-c|php|protoc|python|ruby)'
14+
regex: '^(autotools|bazel|c#|c\+\+|cleanup|cmake|conformance tests|integration|go|java|javascript|objective-c|php|protoc|python|ruby|kotlin)'
1515
message: 'Please include at least a language label (e.g., c++, java, python). Or apply one of the following labels: autotools, bazel, cmake, cleanup, conformance tests, integration, protoc.'
1616
- must_include:
1717
regex: 'release notes: no'

.github/workflows/codespell.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,4 +13,4 @@ jobs:
1313
with:
1414
check_filenames: true
1515
skip: ./.git,./conformance/third_party,*.snk,*.pb,*.pb.cc,*.pb.h,./src/google/protobuf/testdata,./objectivec/Tests,./python/compatibility_tests/v2.5.0/tests/google/protobuf/internal
16-
ignore_words_list: "alow,alse,ba,cleare,copyable,cloneable,dedup,dur,errorprone,files',fo,fundementals,hel,importd,inout,leapyear,nd,nin,ois,ons,parseable,process',te,testof,ue,unparseable,wasn,wee,gae,keyserver,objext,od"
16+
ignore_words_list: "alow,alse,ba,cleare,copyable,cloneable,dedup,dur,errorprone,files',fo,fundementals,hel,importd,inout,leapyear,nd,nin,ois,ons,parseable,process',te,testof,ue,unparseable,wasn,wee,gae,keyserver,objext,od,OptIn"

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,7 @@ src/**/*.trs
8383

8484
# JavaBuild output.
8585
java/core/target
86+
java/lite/target
8687
java/util/target
8788
javanano/target
8889
java/.idea

CHANGES.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
Unreleased Changes (C++/Java/Python/PHP/Objective-C/C#/Ruby/JavaScript)
22

33
C++
4+
* The ::pb namespace is no longer exposed due to conflicts.
45
* Allow MessageDifferencer::TreatAsSet() (and friends) to override previous
56
calls instead of crashing.
67
* Reduce the size of generated proto headers for protos with `string` or
53 Bytes
Binary file not shown.

csharp/src/Google.Protobuf/Reflection/Descriptor.cs

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -4796,11 +4796,11 @@ public void ClearJavaPackage() {
47964796

47974797
private string javaOuterClassname_;
47984798
/// <summary>
4799-
/// If set, all the classes from the .proto file are wrapped in a single
4800-
/// outer class with the given name. This applies to both Proto1
4801-
/// (equivalent to the old "--one_java_file" option) and Proto2 (where
4802-
/// a .proto always translates to a single class, but you may want to
4803-
/// explicitly choose the class name).
4799+
/// Controls the name of the wrapper Java class generated for the .proto file.
4800+
/// That class will always contain the .proto file's getDescriptor() method as
4801+
/// well as any top-level extensions defined in the .proto file.
4802+
/// If java_multiple_files is disabled, then all the other classes from the
4803+
/// .proto file will be nested inside the single wrapper outer class.
48044804
/// </summary>
48054805
[global::System.Diagnostics.DebuggerNonUserCodeAttribute]
48064806
public string JavaOuterClassname {
@@ -4826,10 +4826,10 @@ public void ClearJavaOuterClassname() {
48264826

48274827
private bool javaMultipleFiles_;
48284828
/// <summary>
4829-
/// If set true, then the Java code generator will generate a separate .java
4829+
/// If enabled, then the Java code generator will generate a separate .java
48304830
/// file for each top-level message, enum, and service defined in the .proto
4831-
/// file. Thus, these types will *not* be nested inside the outer class
4832-
/// named by java_outer_classname. However, the outer class will still be
4831+
/// file. Thus, these types will *not* be nested inside the wrapper class
4832+
/// named by java_outer_classname. However, the wrapper class will still be
48334833
/// generated to contain the file's getDescriptor() method as well as any
48344834
/// top-level extensions defined in the file.
48354835
/// </summary>

java/core/src/main/java/com/google/protobuf/CodedInputStream.java

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1185,6 +1185,9 @@ public int pushLimit(int byteLimit) throws InvalidProtocolBufferException {
11851185
throw InvalidProtocolBufferException.negativeSize();
11861186
}
11871187
byteLimit += getTotalBytesRead();
1188+
if (byteLimit < 0) {
1189+
throw InvalidProtocolBufferException.parseFailure();
1190+
}
11881191
final int oldLimit = currentLimit;
11891192
if (byteLimit > oldLimit) {
11901193
throw InvalidProtocolBufferException.truncatedMessage();

java/core/src/test/java/com/google/protobuf/CodedInputStreamTest.java

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1284,4 +1284,33 @@ public synchronized int read(byte[] b, int off, int len) {
12841284
maliciousCapture.get(1)[0] = 0x9;
12851285
assertEquals(0x9, byteArray[0]); // MODIFICATION! Should we fix?
12861286
}
1287+
1288+
public void testInvalidInputYieldsInvalidProtocolBufferException_readTag() throws Exception {
1289+
byte[] input = new byte[] {0x0a, (byte) 0xff, (byte) 0xff, (byte) 0xff, (byte) 0xff, 0x77};
1290+
CodedInputStream inputStream = CodedInputStream.newInstance(input);
1291+
try {
1292+
inputStream.readTag();
1293+
int size = inputStream.readRawVarint32();
1294+
inputStream.pushLimit(size);
1295+
inputStream.readTag();
1296+
fail();
1297+
} catch (InvalidProtocolBufferException ex) {
1298+
// Expected.
1299+
}
1300+
}
1301+
1302+
public void testInvalidInputYieldsInvalidProtocolBufferException_readBytes() throws Exception {
1303+
byte[] input =
1304+
new byte[] {0x0a, (byte) 0xff, (byte) 0xff, (byte) 0xff, (byte) 0xff, 0x67, 0x1a, 0x1a};
1305+
CodedInputStream inputStream = CodedInputStream.newInstance(input);
1306+
try {
1307+
inputStream.readTag();
1308+
int size = inputStream.readRawVarint32();
1309+
inputStream.pushLimit(size);
1310+
inputStream.readBytes();
1311+
fail();
1312+
} catch (InvalidProtocolBufferException ex) {
1313+
// Expected.
1314+
}
1315+
}
12871316
}

php/src/Google/Protobuf/Internal/FileOptions.php

Lines changed: 32 additions & 32 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

protoc-artifacts/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ the following files:
2020
## Maven Location
2121
The published protoc artifacts are available on Maven here:
2222

23-
http://central.maven.org/maven2/com/google/protobuf/protoc/
23+
https://repo.maven.apache.org/maven2/com/google/protobuf/protoc/
2424

2525
## Versioning
2626
The version of the ``protoc`` artifact must be the same as the version of the

src/google/protobuf/descriptor.proto

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -348,17 +348,17 @@ message FileOptions {
348348
optional string java_package = 1;
349349

350350

351-
// If set, all the classes from the .proto file are wrapped in a single
352-
// outer class with the given name. This applies to both Proto1
353-
// (equivalent to the old "--one_java_file" option) and Proto2 (where
354-
// a .proto always translates to a single class, but you may want to
355-
// explicitly choose the class name).
351+
// Controls the name of the wrapper Java class generated for the .proto file.
352+
// That class will always contain the .proto file's getDescriptor() method as
353+
// well as any top-level extensions defined in the .proto file.
354+
// If java_multiple_files is disabled, then all the other classes from the
355+
// .proto file will be nested inside the single wrapper outer class.
356356
optional string java_outer_classname = 8;
357357

358-
// If set true, then the Java code generator will generate a separate .java
358+
// If enabled, then the Java code generator will generate a separate .java
359359
// file for each top-level message, enum, and service defined in the .proto
360-
// file. Thus, these types will *not* be nested inside the outer class
361-
// named by java_outer_classname. However, the outer class will still be
360+
// file. Thus, these types will *not* be nested inside the wrapper class
361+
// named by java_outer_classname. However, the wrapper class will still be
362362
// generated to contain the file's getDescriptor() method as well as any
363363
// top-level extensions defined in the file.
364364
optional bool java_multiple_files = 10 [default = false];

src/google/protobuf/port_undef.inc

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,10 @@
7979
#undef PROTOBUF_ATTRIBUTE_INIT_PRIORITY
8080
#undef PROTOBUF_PRAGMA_INIT_SEG
8181

82+
#ifdef PROTOBUF_FUTURE_BREAKING_CHANGES
83+
#undef PROTOBUF_FUTURE_BREAKING_CHANGES
84+
#endif
85+
8286
// Restore macro that may have been #undef'd in port_def.inc.
8387
#ifdef _MSC_VER
8488
#pragma pop_macro("CREATE_NEW")

src/google/protobuf/util/field_comparator.h

Lines changed: 7 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -146,15 +146,6 @@ class PROTOBUF_EXPORT SimpleFieldComparator : public FieldComparator {
146146
void SetDefaultFractionAndMargin(double fraction, double margin);
147147

148148
protected:
149-
// NOTE: this will go away.
150-
ComparisonResult Compare(const Message& message_1, const Message& message_2,
151-
const FieldDescriptor* field, int index_1,
152-
int index_2,
153-
const util::FieldContext* field_context) override {
154-
return SimpleCompare(message_1, message_2, field, index_1, index_2,
155-
field_context);
156-
}
157-
158149
// Returns the comparison result for the given field in two messages.
159150
//
160151
// This function is called directly by DefaultFieldComparator::Compare.
@@ -268,7 +259,13 @@ class PROTOBUF_EXPORT SimpleFieldComparator : public FieldComparator {
268259
};
269260

270261
// Default field comparison: use the basic implementation of FieldComparator.
271-
class PROTOBUF_EXPORT DefaultFieldComparator : public SimpleFieldComparator {
262+
#ifdef PROTOBUF_FUTURE_BREAKING_CHANGES
263+
class PROTOBUF_EXPORT DefaultFieldComparator final
264+
: public SimpleFieldComparator
265+
#else // PROTOBUF_FUTURE_BREAKING_CHANGES
266+
class PROTOBUF_EXPORT DefaultFieldComparator : public SimpleFieldComparator
267+
#endif // PROTOBUF_FUTURE_BREAKING_CHANGES
268+
{
272269
public:
273270
ComparisonResult Compare(const Message& message_1, const Message& message_2,
274271
const FieldDescriptor* field, int index_1,

0 commit comments

Comments
 (0)