zeroc-ice 3.8.0 → 3.8.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (169) hide show
  1. checksums.yaml +4 -4
  2. data/dist/IceRuby/Operation.cpp +22 -6
  3. data/dist/IceRuby/Slice.cpp +1 -1
  4. data/dist/ice/cpp/include/Ice/Communicator.h +4 -4
  5. data/dist/ice/cpp/include/Ice/Config.h +2 -2
  6. data/dist/ice/cpp/include/Ice/Connection.h +3 -3
  7. data/dist/ice/cpp/include/Ice/Endpoint.h +2 -2
  8. data/dist/ice/cpp/include/Ice/Exception.h +1 -1
  9. data/dist/ice/cpp/include/Ice/Initialize.h +1 -1
  10. data/dist/ice/cpp/include/Ice/LocalExceptions.h +22 -1
  11. data/dist/ice/cpp/include/Ice/Logger.h +3 -3
  12. data/dist/ice/cpp/include/Ice/NativePropertiesAdmin.h +2 -0
  13. data/dist/ice/cpp/include/Ice/ObjectAdapter.h +3 -3
  14. data/dist/ice/cpp/include/Ice/ObserverHelper.h +1 -0
  15. data/dist/ice/cpp/include/Ice/OutputStream.h +27 -5
  16. data/dist/ice/cpp/include/Ice/Properties.h +3 -3
  17. data/dist/ice/cpp/include/Ice/Proxy.h +1 -1
  18. data/dist/ice/cpp/include/Ice/SSL/ClientAuthenticationOptions.h +10 -2
  19. data/dist/ice/cpp/include/Ice/SSL/ServerAuthenticationOptions.h +10 -2
  20. data/dist/ice/cpp/include/generated/Ice/BuiltinSequences.h +2 -2
  21. data/dist/ice/cpp/include/generated/Ice/Context.h +2 -2
  22. data/dist/ice/cpp/include/generated/Ice/EndpointTypes.h +2 -2
  23. data/dist/ice/cpp/include/generated/Ice/Identity.h +2 -2
  24. data/dist/ice/cpp/include/generated/Ice/Locator.h +9 -11
  25. data/dist/ice/cpp/include/generated/Ice/LocatorRegistry.h +2 -2
  26. data/dist/ice/cpp/include/generated/Ice/Metrics.h +7 -7
  27. data/dist/ice/cpp/include/generated/Ice/OperationMode.h +2 -2
  28. data/dist/ice/cpp/include/generated/Ice/Process.h +2 -2
  29. data/dist/ice/cpp/include/generated/Ice/PropertiesAdmin.h +2 -2
  30. data/dist/ice/cpp/include/generated/Ice/PropertyDict.h +2 -2
  31. data/dist/ice/cpp/include/generated/Ice/RemoteLogger.h +2 -2
  32. data/dist/ice/cpp/include/generated/Ice/ReplyStatus.h +8 -4
  33. data/dist/ice/cpp/include/generated/Ice/Router.h +7 -7
  34. data/dist/ice/cpp/include/generated/Ice/SliceChecksumDict.h +2 -2
  35. data/dist/ice/cpp/include/generated/Ice/Version.h +2 -2
  36. data/dist/ice/cpp/include/generated/IceDiscovery/Lookup.h +2 -2
  37. data/dist/ice/cpp/include/generated/IceLocatorDiscovery/Lookup.h +2 -2
  38. data/dist/ice/cpp/src/Ice/CollocatedRequestHandler.cpp +5 -3
  39. data/dist/ice/cpp/src/Ice/ConnectionFactory.h +8 -8
  40. data/dist/ice/cpp/src/Ice/ConnectionI.cpp +28 -11
  41. data/dist/ice/cpp/src/Ice/ConnectionI.h +1 -1
  42. data/dist/ice/cpp/src/Ice/Demangle.cpp +1 -0
  43. data/dist/ice/cpp/src/Ice/FileUtil.cpp +3 -67
  44. data/dist/ice/cpp/src/Ice/FileUtil.h +0 -3
  45. data/dist/ice/cpp/src/Ice/IPEndpointI.cpp +4 -0
  46. data/dist/ice/cpp/src/Ice/IncomingRequest.cpp +1 -1
  47. data/dist/ice/cpp/src/Ice/InputStream.cpp +28 -17
  48. data/dist/ice/cpp/src/Ice/LocalException.cpp +1 -1
  49. data/dist/ice/cpp/src/Ice/LocalExceptions.cpp +6 -0
  50. data/dist/ice/cpp/src/Ice/OutgoingAsync.cpp +1 -1
  51. data/dist/ice/cpp/src/Ice/OutgoingResponse.cpp +127 -127
  52. data/dist/ice/cpp/src/Ice/OutgoingResponseInternal.h +21 -0
  53. data/dist/ice/cpp/src/Ice/OutputStream.cpp +80 -115
  54. data/dist/ice/cpp/src/Ice/PropertyNames.cpp +3 -2
  55. data/dist/ice/cpp/src/Ice/ProxyFunctions.cpp +4 -4
  56. data/dist/ice/cpp/src/Ice/Reference.cpp +15 -15
  57. data/dist/ice/cpp/src/Ice/ReferenceFactory.cpp +16 -13
  58. data/dist/ice/cpp/src/Ice/ResourceConfig.h +2 -2
  59. data/dist/ice/cpp/src/Ice/SSL/OpenSSLEngine.cpp +29 -20
  60. data/dist/ice/cpp/src/Ice/SSL/OpenSSLEngine.h +1 -2
  61. data/dist/ice/cpp/src/Ice/SSL/OpenSSLTransceiverI.cpp +14 -3
  62. data/dist/ice/cpp/src/Ice/SSL/RFC2253.cpp +3 -3
  63. data/dist/ice/cpp/src/Ice/SSL/SSLEndpointI.cpp +1 -1
  64. data/dist/ice/cpp/src/Ice/SSL/SSLEngine.h +4 -10
  65. data/dist/ice/cpp/src/Ice/SSL/SSLUtil.cpp +21 -2
  66. data/dist/ice/cpp/src/Ice/SSL/SSLUtil.h +15 -1
  67. data/dist/ice/cpp/src/Ice/SSL/SchannelEngine.cpp +67 -48
  68. data/dist/ice/cpp/src/Ice/SSL/SchannelEngine.h +1 -5
  69. data/dist/ice/cpp/src/Ice/SSL/SchannelTransceiverI.cpp +14 -2
  70. data/dist/ice/cpp/src/Ice/SSL/SecureTransportEngine.cpp +111 -15
  71. data/dist/ice/cpp/src/Ice/SSL/SecureTransportEngine.h +7 -2
  72. data/dist/ice/cpp/src/Ice/SSL/SecureTransportTransceiverI.h +1 -1
  73. data/dist/ice/cpp/src/Ice/SSL/SecureTransportUtil.cpp +3 -16
  74. data/dist/ice/cpp/src/Ice/SSL/TrustManager.cpp +12 -1
  75. data/dist/ice/cpp/src/Ice/ServantManager.h +1 -1
  76. data/dist/ice/cpp/src/Ice/StringConverter.cpp +4 -0
  77. data/dist/ice/cpp/src/Ice/TcpEndpointI.cpp +2 -2
  78. data/dist/ice/cpp/src/Ice/UdpEndpointI.cpp +2 -2
  79. data/dist/ice/cpp/src/Ice/WSAcceptor.cpp +8 -3
  80. data/dist/ice/cpp/src/Ice/WSAcceptor.h +5 -1
  81. data/dist/ice/cpp/src/Ice/WSEndpoint.cpp +45 -2
  82. data/dist/ice/cpp/src/Ice/WSTransceiver.cpp +118 -7
  83. data/dist/ice/cpp/src/Ice/WSTransceiver.h +12 -1
  84. data/dist/ice/cpp/src/Ice/generated/BuiltinSequences.cpp +2 -2
  85. data/dist/ice/cpp/src/Ice/generated/Context.cpp +2 -2
  86. data/dist/ice/cpp/src/Ice/generated/EndpointTypes.cpp +2 -2
  87. data/dist/ice/cpp/src/Ice/generated/Identity.cpp +2 -2
  88. data/dist/ice/cpp/src/Ice/generated/Locator.cpp +2 -2
  89. data/dist/ice/cpp/src/Ice/generated/LocatorRegistry.cpp +2 -2
  90. data/dist/ice/cpp/src/Ice/generated/Metrics.cpp +2 -2
  91. data/dist/ice/cpp/src/Ice/generated/OperationMode.cpp +2 -2
  92. data/dist/ice/cpp/src/Ice/generated/Process.cpp +2 -2
  93. data/dist/ice/cpp/src/Ice/generated/PropertiesAdmin.cpp +2 -2
  94. data/dist/ice/cpp/src/Ice/generated/PropertyDict.cpp +2 -2
  95. data/dist/ice/cpp/src/Ice/generated/RemoteLogger.cpp +2 -2
  96. data/dist/ice/cpp/src/Ice/generated/ReplyStatus.cpp +4 -2
  97. data/dist/ice/cpp/src/Ice/generated/Router.cpp +2 -2
  98. data/dist/ice/cpp/src/Ice/generated/SliceChecksumDict.cpp +2 -2
  99. data/dist/ice/cpp/src/Ice/generated/Version.cpp +2 -2
  100. data/dist/ice/cpp/src/IceDiscovery/LocatorI.cpp +2 -2
  101. data/dist/ice/cpp/src/IceDiscovery/LookupI.cpp +4 -3
  102. data/dist/ice/cpp/src/IceDiscovery/LookupI.h +2 -1
  103. data/dist/ice/cpp/src/IceDiscovery/generated/Lookup.cpp +2 -2
  104. data/dist/ice/cpp/src/IceLocatorDiscovery/PluginI.cpp +6 -18
  105. data/dist/ice/cpp/src/IceLocatorDiscovery/generated/Lookup.cpp +2 -2
  106. data/dist/ice/cpp/src/Slice/DocCommentParser.cpp +6 -6
  107. data/dist/ice/cpp/src/Slice/DocCommentParser.h +4 -2
  108. data/dist/ice/cpp/src/Slice/FileTracker.h +1 -0
  109. data/dist/ice/cpp/src/Slice/Grammar.cpp +261 -264
  110. data/dist/ice/cpp/src/Slice/MetadataValidation.cpp +39 -7
  111. data/dist/ice/cpp/src/Slice/MetadataValidation.h +3 -2
  112. data/dist/ice/cpp/src/Slice/Parser.cpp +192 -155
  113. data/dist/ice/cpp/src/Slice/Parser.h +44 -9
  114. data/dist/ice/cpp/src/Slice/Preprocessor.cpp +76 -20
  115. data/dist/ice/cpp/src/Slice/Preprocessor.h +0 -1
  116. data/dist/ice/cpp/src/Slice/Scanner.cpp +1 -1
  117. data/dist/ice/cpp/src/Slice/SliceUtil.cpp +44 -58
  118. data/dist/ice/cpp/src/Slice/StringLiteralUtil.cpp +3 -10
  119. data/dist/ice/cpp/src/Slice/Util.h +7 -3
  120. data/dist/ice/cpp/src/slice2rb/Main.cpp +2 -2
  121. data/dist/ice/cpp/src/slice2rb/Ruby.cpp +1 -1
  122. data/dist/ice/cpp/src/slice2rb/RubyUtil.cpp +10 -8
  123. data/dist/ice/cpp/src/slice2rb/RubyUtil.h +10 -13
  124. data/dist/ice/mcpp/directive.c +5 -2
  125. data/dist/ice/mcpp/mcpp_main.c +1 -1
  126. data/dist/ice/mcpp/support.c +6 -6
  127. data/dist/ice/mcpp/system.c +5 -5
  128. data/dist/ice/slice/Ice/Identity.ice +3 -0
  129. data/dist/ice/slice/Ice/Locator.ice +6 -5
  130. data/dist/ice/slice/Ice/LocatorRegistry.ice +3 -0
  131. data/dist/ice/slice/Ice/Metrics.ice +1 -1
  132. data/dist/ice/slice/Ice/OperationMode.ice +8 -0
  133. data/dist/ice/slice/Ice/Process.ice +3 -0
  134. data/dist/ice/slice/Ice/ReplyStatus.ice +13 -0
  135. data/dist/lib/Glacier2/Metrics.rb +1 -1
  136. data/dist/lib/Glacier2/PermissionsVerifier.rb +3 -3
  137. data/dist/lib/Glacier2/Router.rb +8 -8
  138. data/dist/lib/Glacier2/SSLInfo.rb +1 -1
  139. data/dist/lib/Glacier2/Session.rb +15 -15
  140. data/dist/lib/Ice/BuiltinSequences.rb +1 -1
  141. data/dist/lib/Ice/Context.rb +1 -1
  142. data/dist/lib/Ice/EndpointTypes.rb +1 -1
  143. data/dist/lib/Ice/Identity.rb +1 -1
  144. data/dist/lib/Ice/LocalExceptions.rb +3 -0
  145. data/dist/lib/Ice/Locator.rb +5 -5
  146. data/dist/lib/Ice/LocatorRegistry.rb +4 -4
  147. data/dist/lib/Ice/Metrics.rb +7 -7
  148. data/dist/lib/Ice/OperationMode.rb +1 -1
  149. data/dist/lib/Ice/Process.rb +3 -3
  150. data/dist/lib/Ice/PropertiesAdmin.rb +4 -4
  151. data/dist/lib/Ice/PropertyDict.rb +1 -1
  152. data/dist/lib/Ice/ProxyFunctions.rb +8 -4
  153. data/dist/lib/Ice/RemoteLogger.rb +6 -6
  154. data/dist/lib/Ice/ReplyStatus.rb +3 -2
  155. data/dist/lib/Ice/Router.rb +5 -5
  156. data/dist/lib/Ice/SliceChecksumDict.rb +1 -1
  157. data/dist/lib/Ice/Version.rb +1 -1
  158. data/dist/lib/IceBox/ServiceManager.rb +8 -8
  159. data/dist/lib/IceGrid/Admin.rb +83 -83
  160. data/dist/lib/IceGrid/Descriptor.rb +1 -1
  161. data/dist/lib/IceGrid/Exception.rb +1 -1
  162. data/dist/lib/IceGrid/FileParser.rb +2 -2
  163. data/dist/lib/IceGrid/Registry.rb +13 -13
  164. data/dist/lib/IceGrid/Session.rb +6 -6
  165. data/dist/lib/IceGrid/UserAccountMapper.rb +2 -2
  166. data/dist/lib/IceStorm/IceStorm.rb +16 -16
  167. data/dist/lib/IceStorm/Metrics.rb +1 -1
  168. data/ice.gemspec +1 -1
  169. metadata +2 -1
@@ -68,6 +68,10 @@ Ice::OutputStream::OutputStream(
68
68
  _format(format),
69
69
  _currentEncaps(nullptr)
70
70
  {
71
+ if (!_wstringConverter)
72
+ {
73
+ _wstringConverter = getProcessWstringConverter();
74
+ }
71
75
  }
72
76
 
73
77
  Ice::OutputStream::OutputStream(
@@ -85,6 +89,11 @@ Ice::OutputStream::OutputStream(
85
89
  _currentEncaps(nullptr)
86
90
  {
87
91
  b.reset();
92
+
93
+ if (!_wstringConverter)
94
+ {
95
+ _wstringConverter = getProcessWstringConverter();
96
+ }
88
97
  }
89
98
 
90
99
  Ice::OutputStream::OutputStream(const CommunicatorPtr& communicator, EncodingVersion encoding)
@@ -104,6 +113,7 @@ Ice::OutputStream::OutputStream(Instance* instance, EncodingVersion encoding)
104
113
  instance->getStringConverter(),
105
114
  instance->getWstringConverter())
106
115
  {
116
+ assert(_wstringConverter);
107
117
  }
108
118
 
109
119
  Ice::OutputStream::OutputStream(OutputStream&& other) noexcept
@@ -116,6 +126,7 @@ Ice::OutputStream::OutputStream(OutputStream&& other) noexcept
116
126
  _currentEncaps(other._currentEncaps)
117
127
  {
118
128
  // Reset other to its default state.
129
+ other._wstringConverter = getProcessWstringConverter();
119
130
  other._closure = nullptr;
120
131
  other._encoding = Encoding_1_1;
121
132
  other._format = FormatType::CompactFormat;
@@ -140,6 +151,7 @@ Ice::OutputStream::operator=(OutputStream&& other) noexcept
140
151
  _currentEncaps = other._currentEncaps;
141
152
 
142
153
  // Reset other to its default state.
154
+ other._wstringConverter = getProcessWstringConverter();
143
155
  other._closure = nullptr;
144
156
  other._encoding = Encoding_1_1;
145
157
  other._format = FormatType::CompactFormat;
@@ -703,80 +715,54 @@ Ice::OutputStream::write(const char*)
703
715
  void
704
716
  Ice::OutputStream::writeConverted(const char* vdata, size_t vsize)
705
717
  {
718
+ if (!_stringConverter)
719
+ {
720
+ // No converter installed; write the string as-is (assumed to be UTF-8 already).
721
+ writeSize(static_cast<int32_t>(vsize));
722
+ Container::size_type position = b.size();
723
+ resize(position + vsize);
724
+ memcpy(&b[position], vdata, vsize);
725
+ return;
726
+ }
727
+
706
728
  //
707
- // What is the size of the resulting UTF-8 encoded string?
708
- // Impossible to tell, so we guess. If we don't guess correctly,
709
- // we'll have to fix the mistake afterwards
729
+ // Convert the narrow string to UTF-8 using the string converter and write the result to the stream.
730
+ //
731
+ // The worst-case expansion for converting a narrow string to UTF-8 is 3x (e.g., a single byte in Shift_JIS can
732
+ // expand to 3 bytes in UTF-8). We use this upper bound to decide the size encoding:
733
+ // - If vsize <= 254 / 3 (84), the converted string is at most 252 bytes, which always fits in a 1-byte size.
734
+ // - Otherwise, we use the 5-byte size encoding to avoid guessing and memmove fixups.
710
735
  //
711
736
  try
712
737
  {
713
- auto guessedSize = static_cast<int32_t>(vsize);
714
- writeSize(guessedSize); // writeSize() only writes the size; it does not reserve any buffer space.
715
-
716
- size_t firstIndex = b.size();
717
- StreamUTF8BufferI buffer(*this);
718
-
719
- byte* lastByte = nullptr;
720
- bool converted = false;
721
-
722
- StringConverterPtr stringConverter = _stringConverter;
723
- if (!stringConverter)
738
+ if (vsize <= 254 / 3)
724
739
  {
725
- stringConverter = getProcessStringConverter();
726
- }
727
- if (stringConverter)
728
- {
729
- lastByte = stringConverter->toUTF8(vdata, vdata + vsize, buffer);
730
- converted = true;
731
- }
740
+ // The maximum UTF-8 size is vsize * 3 <= 252, which fits in a 1-byte size encoding.
741
+ auto sizePos = startOneByteSize();
732
742
 
733
- if (!converted)
734
- {
735
- Container::size_type position = b.size();
736
- resize(position + vsize);
737
- memcpy(&b[position], vdata, vsize);
738
- return;
739
- }
743
+ StreamUTF8BufferI buffer(*this);
744
+ byte* lastByte = _stringConverter->toUTF8(vdata, vdata + vsize, buffer);
745
+ if (lastByte != b.end())
746
+ {
747
+ resize(static_cast<size_t>(lastByte - b.begin()));
748
+ }
740
749
 
741
- if (lastByte != b.end())
742
- {
743
- resize(static_cast<size_t>(lastByte - b.begin()));
750
+ endOneByteSize(sizePos);
744
751
  }
745
- size_t lastIndex = b.size();
746
-
747
- auto actualSize = static_cast<int32_t>(lastIndex - firstIndex);
748
-
749
- //
750
- // Check against the guess
751
- //
752
- if (guessedSize != actualSize)
752
+ else
753
753
  {
754
- if (guessedSize <= 254 && actualSize > 254)
755
- {
756
- //
757
- // Move the UTF-8 sequence 4 bytes further
758
- // Use memmove instead of memcpy since the source and destination typically overlap.
759
- //
760
- resize(b.size() + 4);
761
- memmove(b.begin() + firstIndex + 4, b.begin() + firstIndex, static_cast<size_t>(actualSize));
762
- }
763
- else if (guessedSize > 254 && actualSize <= 254)
764
- {
765
- //
766
- // Move the UTF-8 sequence 4 bytes back
767
- //
768
- memmove(b.begin() + firstIndex - 4, b.begin() + firstIndex, static_cast<size_t>(actualSize));
769
- resize(b.size() - 4);
770
- }
754
+ // Write the first byte of the 5-byte size encoding, followed by a 4-byte size placeholder.
755
+ write(uint8_t(255));
756
+ auto sizePos = startSize();
771
757
 
772
- if (guessedSize <= 254)
758
+ StreamUTF8BufferI buffer(*this);
759
+ byte* lastByte = _stringConverter->toUTF8(vdata, vdata + vsize, buffer);
760
+ if (lastByte != b.end())
773
761
  {
774
- rewriteSize(actualSize, b.begin() + firstIndex - 1);
775
- }
776
- else
777
- {
778
- rewriteSize(actualSize, b.begin() + firstIndex - 1 - 4);
762
+ resize(static_cast<size_t>(lastByte - b.begin()));
779
763
  }
764
+
765
+ endSize(sizePos);
780
766
  }
781
767
  }
782
768
  catch (const Ice::IllegalConversionException& ex)
@@ -808,68 +794,47 @@ Ice::OutputStream::write(wstring_view v)
808
794
  return;
809
795
  }
810
796
 
811
- //
812
- // What is the size of the resulting UTF-8 encoded string?
813
- // Impossible to tell, so we guess. If we don't guess correctly,
814
- // we'll have to fix the mistake afterwards
815
- //
816
- try
817
- {
818
- auto guessedSize = static_cast<int32_t>(v.size());
819
- writeSize(guessedSize); // writeSize() only writes the size; it does not reserve any buffer space.
797
+ assert(_wstringConverter);
820
798
 
821
- size_t firstIndex = b.size();
822
- StreamUTF8BufferI buffer(*this);
799
+ // The worst-case expansion for converting a wide string to UTF-8 is 3x or 4x depending on the platform.
800
+ const size_t factor = sizeof(wchar_t) == 2 ? 3 : 4;
823
801
 
824
- byte* lastByte = nullptr;
825
-
826
- WstringConverterPtr wstringConverter = _wstringConverter;
827
- if (!wstringConverter)
802
+ try
803
+ {
804
+ // (252 / 3 = 84, 252 / 4 = 63)
805
+ if (v.size() <= 252 / factor)
828
806
  {
829
- wstringConverter = getProcessWstringConverter();
830
- }
831
- assert(wstringConverter); // never null
832
- lastByte = wstringConverter->toUTF8(v.data(), v.data() + v.size(), buffer);
807
+ // The maximum UTF-8 size is v.size() * factor <= 252, which fits in a 1-byte size encoding.
808
+ // We use this upper bound to decide the size encoding:
809
+ // - If v.size() <= 252 / factor, the converted string is at most 252 bytes, which always fits in a 1-byte
810
+ // size.
811
+ // - Otherwise, we use the 5-byte size encoding to avoid guessing and memmove fixups.
812
+ auto sizePos = startOneByteSize();
813
+
814
+ StreamUTF8BufferI buffer(*this);
815
+ byte* lastByte = _wstringConverter->toUTF8(v.data(), v.data() + v.size(), buffer);
816
+ if (lastByte != b.end())
817
+ {
818
+ resize(static_cast<size_t>(lastByte - b.begin()));
819
+ }
833
820
 
834
- if (lastByte != b.end())
835
- {
836
- resize(static_cast<size_t>(lastByte - b.begin()));
821
+ endOneByteSize(sizePos);
822
+ return;
837
823
  }
838
- size_t lastIndex = b.size();
839
-
840
- auto actualSize = static_cast<int32_t>(lastIndex - firstIndex);
841
-
842
- //
843
- // Check against the guess
844
- //
845
- if (guessedSize != actualSize)
824
+ else
846
825
  {
847
- if (guessedSize <= 254 && actualSize > 254)
848
- {
849
- //
850
- // Move the UTF-8 sequence 4 bytes further
851
- // Use memmove instead of memcpy since the source and destination typically overlap.
852
- //
853
- resize(b.size() + 4);
854
- memmove(b.begin() + firstIndex + 4, b.begin() + firstIndex, static_cast<size_t>(actualSize));
855
- }
856
- else if (guessedSize > 254 && actualSize <= 254)
857
- {
858
- //
859
- // Move the UTF-8 sequence 4 bytes back
860
- //
861
- memmove(b.begin() + firstIndex - 4, b.begin() + firstIndex, static_cast<size_t>(actualSize));
862
- resize(b.size() - 4);
863
- }
826
+ // Write the first byte of the 5-byte size encoding, followed by a 4-byte size placeholder.
827
+ write(uint8_t(255));
828
+ auto sizePos = startSize();
864
829
 
865
- if (guessedSize <= 254)
830
+ StreamUTF8BufferI buffer(*this);
831
+ byte* lastByte = _wstringConverter->toUTF8(v.data(), v.data() + v.size(), buffer);
832
+ if (lastByte != b.end())
866
833
  {
867
- rewriteSize(actualSize, b.begin() + firstIndex - 1);
868
- }
869
- else
870
- {
871
- rewriteSize(actualSize, b.begin() + firstIndex - 1 - 4);
834
+ resize(static_cast<size_t>(lastByte - b.begin()));
872
835
  }
836
+
837
+ endSize(sizePos);
873
838
  }
874
839
  }
875
840
  catch (const Ice::IllegalConversionException& ex)
@@ -70,6 +70,7 @@ const PropertyArray PropertyNames::ThreadPoolProps
70
70
  const Property ObjectAdapterPropsData[] =
71
71
  {
72
72
  Property{"AdapterId", "", false, false, nullptr},
73
+ Property{"AllowedOrigins", "", false, false, nullptr},
73
74
  Property{"Connection", "", false, false, &PropertyNames::ConnectionProps},
74
75
  Property{"Endpoints", "", false, false, nullptr},
75
76
  Property{"Locator", "", false, false, &PropertyNames::ProxyProps},
@@ -89,7 +90,7 @@ const PropertyArray PropertyNames::ObjectAdapterProps
89
90
  .prefixOnly=true,
90
91
  .isOptIn=false,
91
92
  .properties=ObjectAdapterPropsData,
92
- .length=12
93
+ .length=13
93
94
  };
94
95
 
95
96
  const Property IcePropsData[] =
@@ -428,7 +429,7 @@ const Property IceSSLPropsData[] =
428
429
  Property{"KeyFile", "", false, false, nullptr},
429
430
  Property{"Password", "", false, false, nullptr},
430
431
  Property{"RevocationCheck", "0", false, false, nullptr},
431
- Property{"RevocationCheckCacheOnly", "0", false, false, nullptr},
432
+ Property{"RevocationCheckCacheOnly", "1", false, false, nullptr},
432
433
  Property{"Trace.Security", "0", false, false, nullptr},
433
434
  Property{"TrustOnly", "", false, false, nullptr},
434
435
  Property{"TrustOnly.Client", "", false, false, nullptr},
@@ -53,8 +53,8 @@ Ice::proxyIdentityAndFacetLess(const optional<ObjectPrx>& lhs, const optional<Ob
53
53
  {
54
54
  if (lhs && rhs)
55
55
  {
56
- Identity lhsIdentity = lhs->ice_getIdentity();
57
- Identity rhsIdentity = rhs->ice_getIdentity();
56
+ const Identity& lhsIdentity = lhs->ice_getIdentity();
57
+ const Identity& rhsIdentity = rhs->ice_getIdentity();
58
58
 
59
59
  if (lhsIdentity < rhsIdentity)
60
60
  {
@@ -65,8 +65,8 @@ Ice::proxyIdentityAndFacetLess(const optional<ObjectPrx>& lhs, const optional<Ob
65
65
  return false;
66
66
  }
67
67
 
68
- string lhsFacet = lhs->ice_getFacet();
69
- string rhsFacet = rhs->ice_getFacet();
68
+ const string& lhsFacet = lhs->ice_getFacet();
69
+ const string& rhsFacet = rhs->ice_getFacet();
70
70
 
71
71
  return lhsFacet < rhsFacet;
72
72
  }
@@ -549,7 +549,7 @@ IceInternal::FixedReference::changeConnectionId(string) const
549
549
  ReferencePtr
550
550
  IceInternal::FixedReference::changeConnection(Ice::ConnectionIPtr newConnection) const
551
551
  {
552
- FixedReferencePtr r = dynamic_pointer_cast<FixedReference>(clone());
552
+ FixedReferencePtr r = static_pointer_cast<FixedReference>(clone());
553
553
  r->_fixedConnection = std::move(newConnection);
554
554
  return r;
555
555
  }
@@ -787,7 +787,7 @@ IceInternal::RoutableReference::changeEncoding(Ice::EncodingVersion encoding) co
787
787
  ReferencePtr r = Reference::changeEncoding(encoding);
788
788
  if (r.get() != const_cast<RoutableReference*>(this))
789
789
  {
790
- LocatorInfoPtr& locInfo = dynamic_pointer_cast<RoutableReference>(r)->_locatorInfo;
790
+ LocatorInfoPtr& locInfo = static_pointer_cast<RoutableReference>(r)->_locatorInfo;
791
791
  if (locInfo && locInfo->getLocator()->ice_getEncodingVersion() != encoding)
792
792
  {
793
793
  locInfo = getInstance()->locatorManager()->get(locInfo->getLocator()->ice_encodingVersion(encoding));
@@ -809,7 +809,7 @@ IceInternal::RoutableReference::changeCompress(bool newCompress) const
809
809
  {
810
810
  newEndpoints.push_back(endpoint->compress(newCompress));
811
811
  }
812
- dynamic_pointer_cast<RoutableReference>(r)->_endpoints = newEndpoints;
812
+ static_pointer_cast<RoutableReference>(r)->_endpoints = std::move(newEndpoints);
813
813
  }
814
814
  return r;
815
815
  }
@@ -817,7 +817,7 @@ IceInternal::RoutableReference::changeCompress(bool newCompress) const
817
817
  ReferencePtr
818
818
  IceInternal::RoutableReference::changeEndpoints(vector<EndpointIPtr> newEndpoints) const
819
819
  {
820
- RoutableReferencePtr r = dynamic_pointer_cast<RoutableReference>(clone());
820
+ RoutableReferencePtr r = static_pointer_cast<RoutableReference>(clone());
821
821
  r->_endpoints = std::move(newEndpoints);
822
822
  r->applyOverrides(r->_endpoints);
823
823
  r->_adapterId.clear();
@@ -827,7 +827,7 @@ IceInternal::RoutableReference::changeEndpoints(vector<EndpointIPtr> newEndpoint
827
827
  ReferencePtr
828
828
  IceInternal::RoutableReference::changeAdapterId(string newAdapterId) const
829
829
  {
830
- RoutableReferencePtr r = dynamic_pointer_cast<RoutableReference>(clone());
830
+ RoutableReferencePtr r = static_pointer_cast<RoutableReference>(clone());
831
831
  r->_adapterId = std::move(newAdapterId);
832
832
  r->_endpoints.clear();
833
833
  return r;
@@ -837,7 +837,7 @@ ReferencePtr
837
837
  IceInternal::RoutableReference::changeLocator(optional<LocatorPrx> newLocator) const
838
838
  {
839
839
  LocatorInfoPtr newLocatorInfo = newLocator ? getInstance()->locatorManager()->get(newLocator.value()) : nullptr;
840
- RoutableReferencePtr r = dynamic_pointer_cast<RoutableReference>(clone());
840
+ RoutableReferencePtr r = static_pointer_cast<RoutableReference>(clone());
841
841
  r->_locatorInfo = std::move(newLocatorInfo);
842
842
  return r;
843
843
  }
@@ -846,7 +846,7 @@ ReferencePtr
846
846
  IceInternal::RoutableReference::changeRouter(optional<RouterPrx> newRouter) const
847
847
  {
848
848
  RouterInfoPtr newRouterInfo = newRouter ? getInstance()->routerManager()->get(newRouter.value()) : nullptr;
849
- RoutableReferencePtr r = dynamic_pointer_cast<RoutableReference>(clone());
849
+ RoutableReferencePtr r = static_pointer_cast<RoutableReference>(clone());
850
850
  r->_routerInfo = std::move(newRouterInfo);
851
851
  return r;
852
852
  }
@@ -854,7 +854,7 @@ IceInternal::RoutableReference::changeRouter(optional<RouterPrx> newRouter) cons
854
854
  ReferencePtr
855
855
  IceInternal::RoutableReference::changeCollocationOptimized(bool newCollocationOptimized) const
856
856
  {
857
- RoutableReferencePtr r = dynamic_pointer_cast<RoutableReference>(clone());
857
+ RoutableReferencePtr r = static_pointer_cast<RoutableReference>(clone());
858
858
  r->_collocationOptimized = newCollocationOptimized;
859
859
  return r;
860
860
  }
@@ -862,7 +862,7 @@ IceInternal::RoutableReference::changeCollocationOptimized(bool newCollocationOp
862
862
  ReferencePtr
863
863
  IceInternal::RoutableReference::changeCacheConnection(bool newCache) const
864
864
  {
865
- RoutableReferencePtr r = dynamic_pointer_cast<RoutableReference>(clone());
865
+ RoutableReferencePtr r = static_pointer_cast<RoutableReference>(clone());
866
866
  r->_cacheConnection = newCache;
867
867
  return r;
868
868
  }
@@ -870,7 +870,7 @@ IceInternal::RoutableReference::changeCacheConnection(bool newCache) const
870
870
  ReferencePtr
871
871
  IceInternal::RoutableReference::changeEndpointSelection(EndpointSelectionType newType) const
872
872
  {
873
- RoutableReferencePtr r = dynamic_pointer_cast<RoutableReference>(clone());
873
+ RoutableReferencePtr r = static_pointer_cast<RoutableReference>(clone());
874
874
  r->_endpointSelection = newType;
875
875
  return r;
876
876
  }
@@ -878,7 +878,7 @@ IceInternal::RoutableReference::changeEndpointSelection(EndpointSelectionType ne
878
878
  ReferencePtr
879
879
  IceInternal::RoutableReference::changeLocatorCacheTimeout(chrono::milliseconds timeout) const
880
880
  {
881
- RoutableReferencePtr r = dynamic_pointer_cast<RoutableReference>(clone());
881
+ RoutableReferencePtr r = static_pointer_cast<RoutableReference>(clone());
882
882
  r->_locatorCacheTimeout = timeout;
883
883
  return r;
884
884
  }
@@ -886,7 +886,7 @@ IceInternal::RoutableReference::changeLocatorCacheTimeout(chrono::milliseconds t
886
886
  ReferencePtr
887
887
  IceInternal::RoutableReference::changeConnectionId(string id) const
888
888
  {
889
- RoutableReferencePtr r = dynamic_pointer_cast<RoutableReference>(clone());
889
+ RoutableReferencePtr r = static_pointer_cast<RoutableReference>(clone());
890
890
  r->_connectionId = id;
891
891
  if (!_endpoints.empty()) // Also override the connection id on the endpoints.
892
892
  {
@@ -896,7 +896,7 @@ IceInternal::RoutableReference::changeConnectionId(string id) const
896
896
  {
897
897
  newEndpoints.push_back(endpoint->connectionId(id));
898
898
  }
899
- r->_endpoints = newEndpoints;
899
+ r->_endpoints = std::move(newEndpoints);
900
900
  }
901
901
  return r;
902
902
  }
@@ -1259,7 +1259,7 @@ IceInternal::RoutableReference::getConnectionAsync(
1259
1259
  if (_routerInfo)
1260
1260
  {
1261
1261
  // If we route, we send everything to the router's client proxy endpoints.
1262
- auto self = dynamic_pointer_cast<RoutableReference>(const_cast<RoutableReference*>(this)->shared_from_this());
1262
+ auto self = static_pointer_cast<RoutableReference>(const_cast<RoutableReference*>(this)->shared_from_this());
1263
1263
 
1264
1264
  _routerInfo->getClientEndpointsAsync(
1265
1265
  [self = std::move(self), response = std::move(response), exception](vector<EndpointIPtr> endpoints) mutable
@@ -1364,7 +1364,7 @@ IceInternal::RoutableReference::getConnectionNoRouterInfoAsync(
1364
1364
  if (_locatorInfo)
1365
1365
  {
1366
1366
  RoutableReferencePtr self =
1367
- dynamic_pointer_cast<RoutableReference>(const_cast<RoutableReference*>(this)->shared_from_this());
1367
+ static_pointer_cast<RoutableReference>(const_cast<RoutableReference*>(this)->shared_from_this());
1368
1368
  _locatorInfo->getEndpoints(
1369
1369
  self,
1370
1370
  _locatorCacheTimeout,
@@ -93,13 +93,14 @@ IceInternal::ReferenceFactory::create(string_view str, const string& propertyPre
93
93
  return nullptr;
94
94
  }
95
95
 
96
- const string delim = " \t\r\n";
96
+ static constexpr const char* whitespace = " \t\r\n";
97
+ static constexpr const char* whitespaceOrSeparator = " \t\r\n:@";
97
98
 
98
- string s(str);
99
+ string s{str};
99
100
  string::size_type beg;
100
101
  string::size_type end = 0;
101
102
 
102
- beg = s.find_first_not_of(delim, end);
103
+ beg = s.find_first_not_of(whitespace, end);
103
104
  if (beg == string::npos)
104
105
  {
105
106
  throw ParseException(__FILE__, __LINE__, "no non-whitespace characters found in proxy string '" + s + "'");
@@ -117,7 +118,7 @@ IceInternal::ReferenceFactory::create(string_view str, const string& propertyPre
117
118
  }
118
119
  else if (end == 0)
119
120
  {
120
- end = s.find_first_of(delim + ":@", beg);
121
+ end = s.find_first_of(whitespaceOrSeparator, beg);
121
122
  if (end == string::npos)
122
123
  {
123
124
  end = s.size();
@@ -144,7 +145,7 @@ IceInternal::ReferenceFactory::create(string_view str, const string& propertyPre
144
145
  // a null proxy, but only if nothing follows the
145
146
  // quotes.
146
147
  //
147
- if (s.find_first_not_of(delim, end) != string::npos)
148
+ if (s.find_first_not_of(whitespace, end) != string::npos)
148
149
  {
149
150
  throw ParseException(__FILE__, __LINE__, "invalid characters after identity in proxy string '" + s + "'");
150
151
  }
@@ -167,7 +168,7 @@ IceInternal::ReferenceFactory::create(string_view str, const string& propertyPre
167
168
 
168
169
  while (true)
169
170
  {
170
- beg = s.find_first_not_of(delim, end);
171
+ beg = s.find_first_not_of(whitespace, end);
171
172
  if (beg == string::npos)
172
173
  {
173
174
  break;
@@ -178,7 +179,7 @@ IceInternal::ReferenceFactory::create(string_view str, const string& propertyPre
178
179
  break;
179
180
  }
180
181
 
181
- end = s.find_first_of(delim + ":@", beg);
182
+ end = s.find_first_of(whitespaceOrSeparator, beg);
182
183
  if (end == string::npos)
183
184
  {
184
185
  end = s.length();
@@ -204,7 +205,7 @@ IceInternal::ReferenceFactory::create(string_view str, const string& propertyPre
204
205
  // quotation marks.
205
206
  //
206
207
  string argument;
207
- string::size_type argumentBeg = s.find_first_not_of(delim, end);
208
+ string::size_type argumentBeg = s.find_first_not_of(whitespace, end);
208
209
  if (argumentBeg != string::npos)
209
210
  {
210
211
  if (s[argumentBeg] != '@' && s[argumentBeg] != ':' && s[argumentBeg] != '-')
@@ -220,7 +221,7 @@ IceInternal::ReferenceFactory::create(string_view str, const string& propertyPre
220
221
  }
221
222
  else if (end == 0)
222
223
  {
223
- end = s.find_first_of(delim + ":@", beg);
224
+ end = s.find_first_of(whitespaceOrSeparator, beg);
224
225
  if (end == string::npos)
225
226
  {
226
227
  end = s.size();
@@ -493,7 +494,7 @@ IceInternal::ReferenceFactory::create(string_view str, const string& propertyPre
493
494
  }
494
495
  case '@':
495
496
  {
496
- beg = s.find_first_not_of(delim, beg + 1);
497
+ beg = s.find_first_not_of(whitespace, beg + 1);
497
498
  if (beg == string::npos)
498
499
  {
499
500
  throw ParseException(__FILE__, __LINE__, "missing adapter id in proxy string '" + s + "'");
@@ -510,7 +511,7 @@ IceInternal::ReferenceFactory::create(string_view str, const string& propertyPre
510
511
  }
511
512
  else if (end == 0)
512
513
  {
513
- end = s.find_first_of(delim, beg);
514
+ end = s.find_first_of(whitespace, beg);
514
515
  if (end == string::npos)
515
516
  {
516
517
  end = s.size();
@@ -525,7 +526,7 @@ IceInternal::ReferenceFactory::create(string_view str, const string& propertyPre
525
526
  }
526
527
 
527
528
  // Check for trailing whitespace.
528
- if (end != string::npos && s.find_first_not_of(delim, end) != string::npos)
529
+ if (end != string::npos && s.find_first_not_of(whitespace, end) != string::npos)
529
530
  {
530
531
  throw ParseException(
531
532
  __FILE__,
@@ -610,7 +611,9 @@ IceInternal::ReferenceFactory::create(Identity ident, InputStream* s)
610
611
  vector<EndpointIPtr> endpoints;
611
612
  string adapterId;
612
613
 
613
- int32_t sz = s->readSize();
614
+ // Each endpoint occupies at least 8 bytes on the wire (a 2-byte type plus a 6-byte minimum
615
+ // encapsulation), so readAndCheckSeqSize rejects an oversized count before we allocate.
616
+ int32_t sz = s->readAndCheckSeqSize(8);
614
617
 
615
618
  if (sz > 0)
616
619
  {
@@ -5,8 +5,8 @@
5
5
 
6
6
  #include "winver.h"
7
7
 
8
- #define ICE_VERSION 3, 8, 0, 0
9
- #define ICE_STRING_VERSION "3.8.0\0"
8
+ #define ICE_VERSION 3, 8, 2, 0
9
+ #define ICE_STRING_VERSION "3.8.2\0"
10
10
  #define ICE_SO_VERSION "38\0"
11
11
  #define ICE_COMPANY_NAME "ZeroC, Inc.\0"
12
12
  #define ICE_COPYRIGHT "\251 ZeroC, Inc.\0"
@@ -44,20 +44,18 @@ extern "C"
44
44
  auto* p = reinterpret_cast<OpenSSL::SSLEngine*>(userData);
45
45
  assert(p);
46
46
  string passwd = p->password();
47
- int sz = static_cast<int>(passwd.size());
48
- if (sz > size)
49
- {
50
- sz = size - 1;
51
- }
52
- strncpy(buf, passwd.c_str(), sz);
53
- buf[sz] = '\0';
47
+
48
+ // Follow the OpenSSL documentation example: copy the password into the buffer, truncating if necessary, and
49
+ // null-terminate. See https://docs.openssl.org/3.0/man3/SSL_CTX_set_default_passwd_cb/#examples
50
+ strncpy(buf, passwd.c_str(), static_cast<size_t>(size));
51
+ buf[size - 1] = '\0';
54
52
 
55
53
  for (auto& character : passwd)
56
54
  {
57
55
  character = '\0';
58
56
  }
59
57
 
60
- return sz;
58
+ return static_cast<int>(strlen(buf));
61
59
  }
62
60
  }
63
61
 
@@ -74,7 +72,14 @@ namespace
74
72
 
75
73
  OpenSSL::SSLEngine::SSLEngine(const IceInternal::InstancePtr& instance) : Ice::SSL::SSLEngine(instance) {}
76
74
 
77
- OpenSSL::SSLEngine::~SSLEngine() = default;
75
+ OpenSSL::SSLEngine::~SSLEngine()
76
+ {
77
+ if (_ctx)
78
+ {
79
+ SSL_CTX_free(_ctx);
80
+ _ctx = nullptr;
81
+ }
82
+ }
78
83
 
79
84
  void
80
85
  OpenSSL::SSLEngine::initialize()
@@ -93,6 +98,10 @@ OpenSSL::SSLEngine::initialize()
93
98
  throw InitializationException(__FILE__, __LINE__, "IceSSL: unable to create SSL context:\n" + sslErrors());
94
99
  }
95
100
 
101
+ // Reject peer-initiated TLS renegotiation: it is a CPU-asymmetric denial-of-service primitive
102
+ // on TLS 1.2 and is removed entirely in TLS 1.3.
103
+ SSL_CTX_set_options(_ctx, SSL_OP_NO_RENEGOTIATION);
104
+
96
105
  // Check for a default directory. We look in this directory for files mentioned in the configuration.
97
106
  const string defaultDir = properties->getIceProperty("IceSSL.DefaultDir");
98
107
 
@@ -154,7 +163,10 @@ OpenSSL::SSLEngine::initialize()
154
163
  }
155
164
  else if (properties->getIcePropertyAsInt("IceSSL.UsePlatformCAs") > 0)
156
165
  {
157
- SSL_CTX_set_default_verify_paths(_ctx);
166
+ if (!SSL_CTX_set_default_verify_paths(_ctx))
167
+ {
168
+ throw InitializationException(__FILE__, __LINE__, "IceSSL: unable to set default verify paths");
169
+ }
158
170
  }
159
171
  }
160
172
 
@@ -395,9 +407,16 @@ OpenSSL::SSLEngine::initialize()
395
407
  _ctx,
396
408
  reinterpret_cast<unsigned char*>(this),
397
409
  static_cast<unsigned int>(sizeof(this)));
410
+
411
+ // Scrub the password from memory now that initialization is complete.
412
+ OPENSSL_cleanse(_password.data(), _password.size());
413
+ _password.clear();
398
414
  }
399
415
  catch (...)
400
416
  {
417
+ // Scrub the password from memory even if initialization fails.
418
+ OPENSSL_cleanse(_password.data(), _password.size());
419
+ _password.clear();
401
420
  SSL_CTX_free(_ctx);
402
421
  _ctx = nullptr;
403
422
  throw;
@@ -501,13 +520,3 @@ OpenSSL::SSLEngine::sslErrors() const
501
520
  {
502
521
  return getErrors();
503
522
  }
504
-
505
- void
506
- OpenSSL::SSLEngine::destroy()
507
- {
508
- if (_ctx)
509
- {
510
- SSL_CTX_free(_ctx);
511
- _ctx = nullptr;
512
- }
513
- }
@@ -17,10 +17,9 @@ namespace Ice::SSL::OpenSSL
17
17
  {
18
18
  public:
19
19
  SSLEngine(const IceInternal::InstancePtr&);
20
- ~SSLEngine();
20
+ ~SSLEngine() override;
21
21
 
22
22
  void initialize() final;
23
- void destroy() final;
24
23
  [[nodiscard]] std::string sslErrors() const;
25
24
  [[nodiscard]] std::string password() const { return _password; }
26
25
  [[nodiscard]] Ice::SSL::ClientAuthenticationOptions