c8c615
diff --git a/src/google/protobuf/descriptor.cc b/src/google/protobuf/descriptor.cc
c8c615
index 7af37c57f3..03c4e2b516 100644
c8c615
--- a/src/google/protobuf/descriptor.cc
c8c615
+++ b/src/google/protobuf/descriptor.cc
c8c615
@@ -1090,7 +1090,7 @@ inline void DescriptorPool::Tables::FindAllExtensions(
c8c615
 
c8c615
 bool DescriptorPool::Tables::AddSymbol(const std::string& full_name,
c8c615
                                        Symbol symbol) {
c8c615
-  if (InsertIfNotPresent(&symbols_by_name_, full_name.c_str(), symbol)) {
c8c615
+  if (InsertIfNotPresent(&symbols_by_name_, full_name, symbol)) {
c8c615
     symbols_after_checkpoint_.push_back(full_name.c_str());
c8c615
     return true;
c8c615
   } else {
c8c615
@@ -1106,7 +1106,7 @@ bool FileDescriptorTables::AddAliasUnderParent(const void* parent,
c8c615
 }
c8c615
 
c8c615
 bool DescriptorPool::Tables::AddFile(const FileDescriptor* file) {
c8c615
-  if (InsertIfNotPresent(&files_by_name_, file->name().c_str(), file)) {
c8c615
+  if (InsertIfNotPresent(&files_by_name_, file->name(), file)) {
c8c615
     files_after_checkpoint_.push_back(file->name().c_str());
c8c615
     return true;
c8c615
   } else {
c8c615
@@ -2626,6 +2626,8 @@ void Descriptor::DebugString(int depth, std::string* contents,
c8c615
       const Descriptor::ReservedRange* range = reserved_range(i);
c8c615
       if (range->end == range->start + 1) {
c8c615
         strings::SubstituteAndAppend(contents, "$0, ", range->start);
c8c615
+      } else if (range->end > FieldDescriptor::kMaxNumber) {
c8c615
+        strings::SubstituteAndAppend(contents, "$0 to max, ", range->start);
c8c615
       } else {
c8c615
         strings::SubstituteAndAppend(contents, "$0 to $1, ", range->start,
c8c615
                                   range->end - 1);
c8c615
@@ -2829,6 +2831,8 @@ void EnumDescriptor::DebugString(
c8c615
       const EnumDescriptor::ReservedRange* range = reserved_range(i);
c8c615
       if (range->end == range->start) {
c8c615
         strings::SubstituteAndAppend(contents, "$0, ", range->start);
c8c615
+      } else if (range->end == INT_MAX) {
c8c615
+        strings::SubstituteAndAppend(contents, "$0 to max, ", range->start);
c8c615
       } else {
c8c615
         strings::SubstituteAndAppend(contents, "$0 to $1, ", range->start,
c8c615
                                   range->end);
c8c615
@@ -4019,6 +4023,11 @@ bool DescriptorBuilder::AddSymbol(const std::string& full_name,
c8c615
   // Use its file as the parent instead.
c8c615
   if (parent == nullptr) parent = file_;
c8c615
 
c8c615
+  if (full_name.find('\0') != std::string::npos) {
c8c615
+    AddError(full_name, proto, DescriptorPool::ErrorCollector::NAME,
c8c615
+             "\"" + full_name + "\" contains null character.");
c8c615
+    return false;
c8c615
+  }
c8c615
   if (tables_->AddSymbol(full_name, symbol)) {
c8c615
     if (!file_tables_->AddAliasUnderParent(parent, name, symbol)) {
c8c615
       // This is only possible if there was already an error adding something of
c8c615
@@ -4059,6 +4068,11 @@ bool DescriptorBuilder::AddSymbol(const std::string& full_name,
c8c615
 void DescriptorBuilder::AddPackage(const std::string& name,
c8c615
                                    const Message& proto,
c8c615
                                    const FileDescriptor* file) {
c8c615
+  if (name.find('\0') != std::string::npos) {
c8c615
+    AddError(name, proto, DescriptorPool::ErrorCollector::NAME,
c8c615
+             "\"" + name + "\" contains null character.");
c8c615
+    return;
c8c615
+  }
c8c615
   if (tables_->AddSymbol(name, Symbol(file))) {
c8c615
     // Success.  Also add parent package, if any.
c8c615
     std::string::size_type dot_pos = name.find_last_of('.');
c8c615
@@ -4372,6 +4386,12 @@ FileDescriptor* DescriptorBuilder::BuildFileImpl(
c8c615
   }
c8c615
   result->pool_ = pool_;
c8c615
 
c8c615
+  if (result->name().find('\0') != std::string::npos) {
c8c615
+    AddError(result->name(), proto, DescriptorPool::ErrorCollector::NAME,
c8c615
+             "\"" + result->name() + "\" contains null character.");
c8c615
+    return nullptr;
c8c615
+  }
c8c615
+
c8c615
   // Add to tables.
c8c615
   if (!tables_->AddFile(result)) {
c8c615
     AddError(proto.name(), proto, DescriptorPool::ErrorCollector::OTHER,