aboutsummaryrefslogtreecommitdiff
path: root/python
diff options
context:
space:
mode:
authorJoshua Haberman <jhaberman@gmail.com>2016-02-17 16:09:35 -0800
committerJoshua Haberman <jhaberman@gmail.com>2016-02-17 16:09:35 -0800
commitc40f8c1f54f028b1ca73f3fb2dfdde500f94918f (patch)
treec88529bd8116f685dbb6724204d52ab308e70850 /python
parent61e8e2186f5a9149d6f05a85ce941071a2f9f0c3 (diff)
parent99a3e30bd761878631937aaf67f6206bf4d4afff (diff)
downloadprotobuf-c40f8c1f54f028b1ca73f3fb2dfdde500f94918f.tar.gz
protobuf-c40f8c1f54f028b1ca73f3fb2dfdde500f94918f.tar.bz2
protobuf-c40f8c1f54f028b1ca73f3fb2dfdde500f94918f.zip
Merge pull request #1229 from keveman/unlimited_binary_proto
Added ALLOW_UNLIMITED_BINARY_PROTO macro and setting it when
Diffstat (limited to 'python')
-rw-r--r--python/google/protobuf/pyext/message.cc9
1 files changed, 9 insertions, 0 deletions
diff --git a/python/google/protobuf/pyext/message.cc b/python/google/protobuf/pyext/message.cc
index 863cde01..60ec9c1b 100644
--- a/python/google/protobuf/pyext/message.cc
+++ b/python/google/protobuf/pyext/message.cc
@@ -1921,6 +1921,15 @@ static PyObject* MergeFromString(CMessage* self, PyObject* arg) {
AssureWritable(self);
io::CodedInputStream input(
reinterpret_cast<const uint8*>(data), data_length);
+#if PROTOBUF_PYTHON_ALLOW_OVERSIZE_PROTOS
+ // Protobuf has a 64MB limit built in, this code will override this. Please do
+ // not enable this unless you fully understand the implications: protobufs
+ // must all be kept in memory at the same time, so if they grow too big you
+ // may get OOM errors. The protobuf APIs do not provide any tools for
+ // processing protobufs in chunks. If you have protos this big you should
+ // break them up if it is at all convenient to do so.
+ input.SetTotalBytesLimit(INT_MAX, INT_MAX);
+#endif // PROTOBUF_PYTHON_ALLOW_OVERSIZE_PROTOS
PyDescriptorPool* pool = GetDescriptorPoolForMessage(self);
input.SetExtensionRegistry(pool->pool, pool->message_factory);
bool success = self->message->MergePartialFromCodedStream(&input);