zeroc-ice 3.7.11 → 3.7.12

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 (209) hide show
  1. checksums.yaml +4 -4
  2. data/dist/IceRuby/Communicator.cpp +11 -2
  3. data/dist/IceRuby/Properties.cpp +2 -2
  4. data/dist/IceRuby/Types.cpp +3 -3
  5. data/dist/ice/cpp/include/Ice/InputStream.h +7 -4
  6. data/dist/ice/cpp/include/IceDiscovery/IceDiscovery.h +2 -2
  7. data/dist/ice/cpp/include/IceLocatorDiscovery/IceLocatorDiscovery.h +2 -2
  8. data/dist/ice/cpp/include/IceUtil/Config.h +2 -2
  9. data/dist/ice/cpp/include/IceUtil/ResourceConfig.h +2 -2
  10. data/dist/ice/cpp/include/generated/Glacier2/Metrics.h +2 -2
  11. data/dist/ice/cpp/include/generated/Glacier2/PermissionsVerifier.h +2 -2
  12. data/dist/ice/cpp/include/generated/Glacier2/PermissionsVerifierF.h +2 -2
  13. data/dist/ice/cpp/include/generated/Glacier2/Router.h +2 -2
  14. data/dist/ice/cpp/include/generated/Glacier2/RouterF.h +2 -2
  15. data/dist/ice/cpp/include/generated/Glacier2/SSLInfo.h +2 -2
  16. data/dist/ice/cpp/include/generated/Glacier2/Session.h +2 -2
  17. data/dist/ice/cpp/include/generated/Ice/BuiltinSequences.h +2 -2
  18. data/dist/ice/cpp/include/generated/Ice/Communicator.h +2 -2
  19. data/dist/ice/cpp/include/generated/Ice/CommunicatorF.h +2 -2
  20. data/dist/ice/cpp/include/generated/Ice/Connection.h +2 -2
  21. data/dist/ice/cpp/include/generated/Ice/ConnectionF.h +2 -2
  22. data/dist/ice/cpp/include/generated/Ice/Current.h +2 -2
  23. data/dist/ice/cpp/include/generated/Ice/Endpoint.h +2 -2
  24. data/dist/ice/cpp/include/generated/Ice/EndpointF.h +2 -2
  25. data/dist/ice/cpp/include/generated/Ice/EndpointTypes.h +2 -2
  26. data/dist/ice/cpp/include/generated/Ice/FacetMap.h +2 -2
  27. data/dist/ice/cpp/include/generated/Ice/Identity.h +2 -2
  28. data/dist/ice/cpp/include/generated/Ice/ImplicitContext.h +2 -2
  29. data/dist/ice/cpp/include/generated/Ice/ImplicitContextF.h +2 -2
  30. data/dist/ice/cpp/include/generated/Ice/Instrumentation.h +2 -2
  31. data/dist/ice/cpp/include/generated/Ice/InstrumentationF.h +2 -2
  32. data/dist/ice/cpp/include/generated/Ice/LocalException.h +2 -2
  33. data/dist/ice/cpp/include/generated/Ice/Locator.h +2 -2
  34. data/dist/ice/cpp/include/generated/Ice/LocatorF.h +2 -2
  35. data/dist/ice/cpp/include/generated/Ice/Logger.h +2 -2
  36. data/dist/ice/cpp/include/generated/Ice/LoggerF.h +2 -2
  37. data/dist/ice/cpp/include/generated/Ice/Metrics.h +2 -2
  38. data/dist/ice/cpp/include/generated/Ice/ObjectAdapter.h +2 -2
  39. data/dist/ice/cpp/include/generated/Ice/ObjectAdapterF.h +2 -2
  40. data/dist/ice/cpp/include/generated/Ice/ObjectFactory.h +2 -2
  41. data/dist/ice/cpp/include/generated/Ice/Plugin.h +2 -2
  42. data/dist/ice/cpp/include/generated/Ice/PluginF.h +2 -2
  43. data/dist/ice/cpp/include/generated/Ice/Process.h +2 -2
  44. data/dist/ice/cpp/include/generated/Ice/ProcessF.h +2 -2
  45. data/dist/ice/cpp/include/generated/Ice/Properties.h +2 -2
  46. data/dist/ice/cpp/include/generated/Ice/PropertiesAdmin.h +2 -2
  47. data/dist/ice/cpp/include/generated/Ice/PropertiesF.h +2 -2
  48. data/dist/ice/cpp/include/generated/Ice/RemoteLogger.h +2 -2
  49. data/dist/ice/cpp/include/generated/Ice/Router.h +2 -2
  50. data/dist/ice/cpp/include/generated/Ice/RouterF.h +2 -2
  51. data/dist/ice/cpp/include/generated/Ice/ServantLocator.h +2 -2
  52. data/dist/ice/cpp/include/generated/Ice/ServantLocatorF.h +2 -2
  53. data/dist/ice/cpp/include/generated/Ice/SliceChecksumDict.h +2 -2
  54. data/dist/ice/cpp/include/generated/Ice/ValueFactory.h +2 -2
  55. data/dist/ice/cpp/include/generated/Ice/Version.h +2 -2
  56. data/dist/ice/cpp/include/generated/IceBox/IceBox.h +2 -2
  57. data/dist/ice/cpp/include/generated/IceGrid/Admin.h +2 -2
  58. data/dist/ice/cpp/include/generated/IceGrid/Descriptor.h +2 -2
  59. data/dist/ice/cpp/include/generated/IceGrid/Exception.h +2 -2
  60. data/dist/ice/cpp/include/generated/IceGrid/FileParser.h +2 -2
  61. data/dist/ice/cpp/include/generated/IceGrid/PluginFacade.h +2 -2
  62. data/dist/ice/cpp/include/generated/IceGrid/Registry.h +2 -2
  63. data/dist/ice/cpp/include/generated/IceGrid/Session.h +2 -2
  64. data/dist/ice/cpp/include/generated/IceGrid/UserAccountMapper.h +2 -2
  65. data/dist/ice/cpp/include/generated/IcePatch2/FileInfo.h +2 -2
  66. data/dist/ice/cpp/include/generated/IcePatch2/FileServer.h +2 -2
  67. data/dist/ice/cpp/include/generated/IceSSL/ConnectionInfo.h +2 -2
  68. data/dist/ice/cpp/include/generated/IceSSL/ConnectionInfoF.h +2 -2
  69. data/dist/ice/cpp/include/generated/IceSSL/EndpointInfo.h +2 -2
  70. data/dist/ice/cpp/include/generated/IceStorm/IceStorm.h +2 -2
  71. data/dist/ice/cpp/include/generated/IceStorm/Metrics.h +2 -2
  72. data/dist/ice/cpp/src/Ice/BatchRequestQueue.cpp +31 -12
  73. data/dist/ice/cpp/src/Ice/BatchRequestQueue.h +7 -0
  74. data/dist/ice/cpp/src/Ice/CommunicatorI.cpp +10 -0
  75. data/dist/ice/cpp/src/Ice/ConnectionI.cpp +45 -0
  76. data/dist/ice/cpp/src/Ice/IPEndpointI.cpp +6 -0
  77. data/dist/ice/cpp/src/Ice/InputStream.cpp +25 -8
  78. data/dist/ice/cpp/src/Ice/Network.cpp +37 -24
  79. data/dist/ice/cpp/src/Ice/NetworkProxy.cpp +15 -4
  80. data/dist/ice/cpp/src/Ice/ObjectAdapterI.cpp +1 -0
  81. data/dist/ice/cpp/src/Ice/Reference.cpp +6 -0
  82. data/dist/ice/cpp/src/Ice/ReferenceFactory.cpp +3 -1
  83. data/dist/ice/cpp/src/Ice/Selector.cpp +13 -5
  84. data/dist/ice/cpp/src/Ice/Timer.cpp +8 -2
  85. data/dist/ice/cpp/src/Ice/UdpTransceiver.cpp +52 -34
  86. data/dist/ice/cpp/src/Ice/WSTransceiver.cpp +79 -13
  87. data/dist/ice/cpp/src/Ice/generated/BuiltinSequences.cpp +2 -2
  88. data/dist/ice/cpp/src/Ice/generated/Communicator.cpp +2 -2
  89. data/dist/ice/cpp/src/Ice/generated/CommunicatorF.cpp +2 -2
  90. data/dist/ice/cpp/src/Ice/generated/Connection.cpp +2 -2
  91. data/dist/ice/cpp/src/Ice/generated/ConnectionF.cpp +2 -2
  92. data/dist/ice/cpp/src/Ice/generated/Current.cpp +2 -2
  93. data/dist/ice/cpp/src/Ice/generated/Endpoint.cpp +2 -2
  94. data/dist/ice/cpp/src/Ice/generated/EndpointF.cpp +2 -2
  95. data/dist/ice/cpp/src/Ice/generated/EndpointTypes.cpp +2 -2
  96. data/dist/ice/cpp/src/Ice/generated/FacetMap.cpp +2 -2
  97. data/dist/ice/cpp/src/Ice/generated/Identity.cpp +2 -2
  98. data/dist/ice/cpp/src/Ice/generated/ImplicitContext.cpp +2 -2
  99. data/dist/ice/cpp/src/Ice/generated/ImplicitContextF.cpp +2 -2
  100. data/dist/ice/cpp/src/Ice/generated/Instrumentation.cpp +2 -2
  101. data/dist/ice/cpp/src/Ice/generated/InstrumentationF.cpp +2 -2
  102. data/dist/ice/cpp/src/Ice/generated/LocalException.cpp +2 -2
  103. data/dist/ice/cpp/src/Ice/generated/Locator.cpp +2 -2
  104. data/dist/ice/cpp/src/Ice/generated/LocatorF.cpp +2 -2
  105. data/dist/ice/cpp/src/Ice/generated/Logger.cpp +2 -2
  106. data/dist/ice/cpp/src/Ice/generated/LoggerF.cpp +2 -2
  107. data/dist/ice/cpp/src/Ice/generated/Metrics.cpp +2 -2
  108. data/dist/ice/cpp/src/Ice/generated/ObjectAdapter.cpp +2 -2
  109. data/dist/ice/cpp/src/Ice/generated/ObjectAdapterF.cpp +2 -2
  110. data/dist/ice/cpp/src/Ice/generated/ObjectFactory.cpp +2 -2
  111. data/dist/ice/cpp/src/Ice/generated/Plugin.cpp +2 -2
  112. data/dist/ice/cpp/src/Ice/generated/PluginF.cpp +2 -2
  113. data/dist/ice/cpp/src/Ice/generated/Process.cpp +2 -2
  114. data/dist/ice/cpp/src/Ice/generated/ProcessF.cpp +2 -2
  115. data/dist/ice/cpp/src/Ice/generated/Properties.cpp +2 -2
  116. data/dist/ice/cpp/src/Ice/generated/PropertiesAdmin.cpp +2 -2
  117. data/dist/ice/cpp/src/Ice/generated/PropertiesF.cpp +2 -2
  118. data/dist/ice/cpp/src/Ice/generated/RemoteLogger.cpp +2 -2
  119. data/dist/ice/cpp/src/Ice/generated/Router.cpp +2 -2
  120. data/dist/ice/cpp/src/Ice/generated/RouterF.cpp +2 -2
  121. data/dist/ice/cpp/src/Ice/generated/ServantLocator.cpp +2 -2
  122. data/dist/ice/cpp/src/Ice/generated/ServantLocatorF.cpp +2 -2
  123. data/dist/ice/cpp/src/Ice/generated/SliceChecksumDict.cpp +2 -2
  124. data/dist/ice/cpp/src/Ice/generated/ValueFactory.cpp +2 -2
  125. data/dist/ice/cpp/src/Ice/generated/Version.cpp +2 -2
  126. data/dist/ice/cpp/src/IceDiscovery/generated/IceDiscovery/IceDiscovery.h +2 -2
  127. data/dist/ice/cpp/src/IceDiscovery/generated/IceDiscovery.cpp +2 -2
  128. data/dist/ice/cpp/src/IceLocatorDiscovery/generated/IceLocatorDiscovery/IceLocatorDiscovery.h +2 -2
  129. data/dist/ice/cpp/src/IceLocatorDiscovery/generated/IceLocatorDiscovery.cpp +2 -2
  130. data/dist/ice/cpp/src/IceSSL/OpenSSLEngine.cpp +17 -9
  131. data/dist/ice/cpp/src/IceSSL/OpenSSLTransceiverI.cpp +1 -0
  132. data/dist/ice/cpp/src/IceSSL/OpenSSLUtil.cpp +2 -0
  133. data/dist/ice/cpp/src/IceSSL/RFC2253.cpp +1 -1
  134. data/dist/ice/cpp/src/IceSSL/SChannelEngine.cpp +12 -2
  135. data/dist/ice/cpp/src/IceSSL/SChannelTransceiverI.cpp +2 -1
  136. data/dist/ice/cpp/src/IceSSL/SSLEngine.cpp +16 -1
  137. data/dist/ice/cpp/src/IceSSL/SecureTransportEngine.cpp +107 -2
  138. data/dist/ice/cpp/src/IceSSL/SecureTransportEngine.h +7 -0
  139. data/dist/ice/cpp/src/IceSSL/SecureTransportTransceiverI.cpp +2 -0
  140. data/dist/ice/cpp/src/IceSSL/SecureTransportUtil.cpp +1 -1
  141. data/dist/ice/cpp/src/IceSSL/TrustManager.cpp +12 -1
  142. data/dist/ice/cpp/src/IceSSL/generated/ConnectionInfo.cpp +2 -2
  143. data/dist/ice/cpp/src/IceSSL/generated/ConnectionInfoF.cpp +2 -2
  144. data/dist/ice/cpp/src/IceSSL/generated/EndpointInfo.cpp +2 -2
  145. data/dist/ice/cpp/src/IceUtil/ConvertUTF.cpp +4 -0
  146. data/dist/ice/cpp/src/IceUtil/FileUtil.cpp +1 -1
  147. data/dist/ice/cpp/src/IceUtil/Time.cpp +4 -4
  148. data/dist/ice/cpp/src/Slice/JavaUtil.cpp +4 -4
  149. data/dist/lib/Glacier2/Metrics.rb +1 -1
  150. data/dist/lib/Glacier2/PermissionsVerifier.rb +1 -1
  151. data/dist/lib/Glacier2/PermissionsVerifierF.rb +1 -1
  152. data/dist/lib/Glacier2/Router.rb +1 -1
  153. data/dist/lib/Glacier2/RouterF.rb +1 -1
  154. data/dist/lib/Glacier2/SSLInfo.rb +1 -1
  155. data/dist/lib/Glacier2/Session.rb +1 -1
  156. data/dist/lib/Ice/BuiltinSequences.rb +1 -1
  157. data/dist/lib/Ice/Communicator.rb +1 -1
  158. data/dist/lib/Ice/CommunicatorF.rb +1 -1
  159. data/dist/lib/Ice/Connection.rb +1 -1
  160. data/dist/lib/Ice/ConnectionF.rb +1 -1
  161. data/dist/lib/Ice/Current.rb +1 -1
  162. data/dist/lib/Ice/Endpoint.rb +1 -1
  163. data/dist/lib/Ice/EndpointF.rb +1 -1
  164. data/dist/lib/Ice/EndpointTypes.rb +1 -1
  165. data/dist/lib/Ice/FacetMap.rb +1 -1
  166. data/dist/lib/Ice/Identity.rb +1 -1
  167. data/dist/lib/Ice/ImplicitContext.rb +1 -1
  168. data/dist/lib/Ice/ImplicitContextF.rb +1 -1
  169. data/dist/lib/Ice/Instrumentation.rb +1 -1
  170. data/dist/lib/Ice/InstrumentationF.rb +1 -1
  171. data/dist/lib/Ice/LocalException.rb +1 -1
  172. data/dist/lib/Ice/Locator.rb +1 -1
  173. data/dist/lib/Ice/LocatorF.rb +1 -1
  174. data/dist/lib/Ice/Logger.rb +1 -1
  175. data/dist/lib/Ice/LoggerF.rb +1 -1
  176. data/dist/lib/Ice/Metrics.rb +1 -1
  177. data/dist/lib/Ice/ObjectAdapter.rb +1 -1
  178. data/dist/lib/Ice/ObjectAdapterF.rb +1 -1
  179. data/dist/lib/Ice/ObjectFactory.rb +1 -1
  180. data/dist/lib/Ice/Plugin.rb +1 -1
  181. data/dist/lib/Ice/PluginF.rb +1 -1
  182. data/dist/lib/Ice/Process.rb +1 -1
  183. data/dist/lib/Ice/ProcessF.rb +1 -1
  184. data/dist/lib/Ice/Properties.rb +1 -1
  185. data/dist/lib/Ice/PropertiesAdmin.rb +1 -1
  186. data/dist/lib/Ice/PropertiesF.rb +1 -1
  187. data/dist/lib/Ice/RemoteLogger.rb +1 -1
  188. data/dist/lib/Ice/Router.rb +1 -1
  189. data/dist/lib/Ice/RouterF.rb +1 -1
  190. data/dist/lib/Ice/ServantLocator.rb +1 -1
  191. data/dist/lib/Ice/ServantLocatorF.rb +1 -1
  192. data/dist/lib/Ice/SliceChecksumDict.rb +1 -1
  193. data/dist/lib/Ice/ValueFactory.rb +1 -1
  194. data/dist/lib/Ice/Version.rb +1 -1
  195. data/dist/lib/IceBox/IceBox.rb +1 -1
  196. data/dist/lib/IceGrid/Admin.rb +1 -1
  197. data/dist/lib/IceGrid/Descriptor.rb +1 -1
  198. data/dist/lib/IceGrid/Exception.rb +1 -1
  199. data/dist/lib/IceGrid/FileParser.rb +1 -1
  200. data/dist/lib/IceGrid/PluginFacade.rb +1 -1
  201. data/dist/lib/IceGrid/Registry.rb +1 -1
  202. data/dist/lib/IceGrid/Session.rb +1 -1
  203. data/dist/lib/IceGrid/UserAccountMapper.rb +1 -1
  204. data/dist/lib/IcePatch2/FileInfo.rb +1 -1
  205. data/dist/lib/IcePatch2/FileServer.rb +1 -1
  206. data/dist/lib/IceStorm/IceStorm.rb +1 -1
  207. data/dist/lib/IceStorm/Metrics.rb +1 -1
  208. data/ice.gemspec +1 -1
  209. metadata +1 -1
@@ -73,56 +73,74 @@ IceInternal::UdpTransceiver::closing(bool, const Ice::LocalException&)
73
73
  void
74
74
  IceInternal::UdpTransceiver::close()
75
75
  {
76
- assert(_fd != INVALID_SOCKET);
77
- SOCKET fd = _fd;
78
- _fd = INVALID_SOCKET;
79
- closeSocket(fd);
76
+ //
77
+ // _fd is INVALID_SOCKET when bind failed: the bind/setup helper that threw already closed the socket, and
78
+ // bind() reset _fd.
79
+ //
80
+ if(_fd != INVALID_SOCKET)
81
+ {
82
+ SOCKET fd = _fd;
83
+ _fd = INVALID_SOCKET;
84
+ closeSocket(fd);
85
+ }
80
86
  }
81
87
 
82
88
  EndpointIPtr
83
89
  IceInternal::UdpTransceiver::bind()
84
90
  {
85
- if(isMulticast(_addr))
91
+ try
86
92
  {
87
- setReuseAddress(_fd, true);
88
- _mcastAddr = _addr;
93
+ if(isMulticast(_addr))
94
+ {
95
+ setReuseAddress(_fd, true);
96
+ _mcastAddr = _addr;
89
97
 
90
98
  #ifdef _WIN32
91
- //
92
- // Windows does not allow binding to the mcast address itself
93
- // so we bind to INADDR_ANY (0.0.0.0) instead. As a result,
94
- // bi-directional connection won't work because the source
95
- // address won't be the multicast address and the client will
96
- // therefore reject the datagram.
97
- //
98
- const_cast<Address&>(_addr) = getAddressForServer("", _port, getProtocolSupport(_addr), false, false);
99
+ //
100
+ // Windows does not allow binding to the mcast address itself
101
+ // so we bind to INADDR_ANY (0.0.0.0) instead. As a result,
102
+ // bi-directional connection won't work because the source
103
+ // address won't be the multicast address and the client will
104
+ // therefore reject the datagram.
105
+ //
106
+ const_cast<Address&>(_addr) = getAddressForServer("", _port, getProtocolSupport(_addr), false, false);
99
107
  #endif
100
108
 
101
- const_cast<Address&>(_addr) = doBind(_fd, _addr, _mcastInterface);
102
- if(getPort(_mcastAddr) == 0)
109
+ const_cast<Address&>(_addr) = doBind(_fd, _addr, _mcastInterface);
110
+ if(getPort(_mcastAddr) == 0)
111
+ {
112
+ setPort(_mcastAddr, getPort(_addr));
113
+ }
114
+ setMcastGroup(_fd, _mcastAddr, _mcastInterface);
115
+ }
116
+ else
103
117
  {
104
- setPort(_mcastAddr, getPort(_addr));
118
+ #ifndef _WIN32
119
+ //
120
+ // Enable SO_REUSEADDR on Unix platforms to allow re-using
121
+ // the socket even if it's in the TIME_WAIT state. On
122
+ // Windows, this doesn't appear to be necessary and
123
+ // enabling SO_REUSEADDR would actually not be a good
124
+ // thing since it allows a second process to bind to an
125
+ // address even it's already bound by another process.
126
+ //
127
+ // TODO: using SO_EXCLUSIVEADDRUSE on Windows would
128
+ // probably be better but it's only supported by recent
129
+ // Windows versions (XP SP2, Windows Server 2003).
130
+ //
131
+ setReuseAddress(_fd, true);
132
+ #endif
133
+ const_cast<Address&>(_addr) = doBind(_fd, _addr);
105
134
  }
106
- setMcastGroup(_fd, _mcastAddr, _mcastInterface);
107
135
  }
108
- else
136
+ catch(...)
109
137
  {
110
- #ifndef _WIN32
111
- //
112
- // Enable SO_REUSEADDR on Unix platforms to allow re-using
113
- // the socket even if it's in the TIME_WAIT state. On
114
- // Windows, this doesn't appear to be necessary and
115
- // enabling SO_REUSEADDR would actually not be a good
116
- // thing since it allows a second process to bind to an
117
- // address even it's already bound by another process.
118
138
  //
119
- // TODO: using SO_EXCLUSIVEADDRUSE on Windows would
120
- // probably be better but it's only supported by recent
121
- // Windows versions (XP SP2, Windows Server 2003).
139
+ // setReuseAddress, doBind and setMcastGroup close the socket before throwing, so reset _fd to avoid a
140
+ // double close when close() runs during cleanup.
122
141
  //
123
- setReuseAddress(_fd, true);
124
- #endif
125
- const_cast<Address&>(_addr) = doBind(_fd, _addr);
142
+ _fd = INVALID_SOCKET;
143
+ throw;
126
144
  }
127
145
 
128
146
  _bound = true;
@@ -1111,6 +1111,16 @@ IceInternal::WSTransceiver::preRead(Buffer& buf)
1111
1111
  unsigned char ch = static_cast<unsigned char>(*_readI++);
1112
1112
  _readOpCode = ch & 0xf;
1113
1113
 
1114
+ //
1115
+ // No extension is negotiated, so the RSV1, RSV2, and RSV3 bits must all be 0.
1116
+ //
1117
+ if((ch & 0x70) != 0)
1118
+ {
1119
+ throw ProtocolException(__FILE__, __LINE__, "invalid WebSocket frame: RSV bits must be 0");
1120
+ }
1121
+
1122
+ const bool finalFrame = (ch & FLAG_FINAL) == FLAG_FINAL;
1123
+
1114
1124
  //
1115
1125
  // Remember if last frame if we're going to read a data or
1116
1126
  // continuation frame, this is only for protocol
@@ -1122,7 +1132,7 @@ IceInternal::WSTransceiver::preRead(Buffer& buf)
1122
1132
  {
1123
1133
  throw ProtocolException(__FILE__, __LINE__, "invalid data frame, no FIN on previous frame");
1124
1134
  }
1125
- _readLastFrame = (ch & FLAG_FINAL) == FLAG_FINAL;
1135
+ _readLastFrame = finalFrame;
1126
1136
  }
1127
1137
  else if(_readOpCode == OP_CONT)
1128
1138
  {
@@ -1130,7 +1140,7 @@ IceInternal::WSTransceiver::preRead(Buffer& buf)
1130
1140
  {
1131
1141
  throw ProtocolException(__FILE__, __LINE__, "invalid continuation frame, previous frame FIN set");
1132
1142
  }
1133
- _readLastFrame = (ch & FLAG_FINAL) == FLAG_FINAL;
1143
+ _readLastFrame = finalFrame;
1134
1144
  }
1135
1145
 
1136
1146
  ch = static_cast<unsigned char>(*_readI++);
@@ -1153,6 +1163,26 @@ IceInternal::WSTransceiver::preRead(Buffer& buf)
1153
1163
  // 127: The subsequent eight bytes contain the payload length
1154
1164
  //
1155
1165
  _readPayloadLength = (ch & 0x7f);
1166
+
1167
+ //
1168
+ // RFC 6455 section 5.5: control frames (close, ping, and pong) must not be fragmented
1169
+ // and must have a payload length of 125 bytes or less - they cannot use the 16-bit or
1170
+ // 64-bit extended length encoding. Enforce this before allocating any payload buffer.
1171
+ //
1172
+ if(_readOpCode == OP_CLOSE || _readOpCode == OP_PING || _readOpCode == OP_PONG)
1173
+ {
1174
+ if(!finalFrame)
1175
+ {
1176
+ throw ProtocolException(__FILE__, __LINE__,
1177
+ "invalid WebSocket control frame: the FIN bit is not set");
1178
+ }
1179
+ if(_readPayloadLength > 125)
1180
+ {
1181
+ throw ProtocolException(__FILE__, __LINE__,
1182
+ "invalid WebSocket control frame: the payload length exceeds 125 bytes");
1183
+ }
1184
+ }
1185
+
1156
1186
  if(_readPayloadLength < 126)
1157
1187
  {
1158
1188
  _readHeaderLength = 0;
@@ -1185,7 +1215,10 @@ IceInternal::WSTransceiver::preRead(Buffer& buf)
1185
1215
 
1186
1216
  if(_readPayloadLength == 126)
1187
1217
  {
1188
- _readPayloadLength = static_cast<size_t>(ntohs(*reinterpret_cast<uint16_t*>(_readI)));
1218
+ // memcpy avoids the alignment UB of a direct uint16_t* dereference on _readI.
1219
+ uint16_t length;
1220
+ memcpy(&length, _readI, sizeof(length));
1221
+ _readPayloadLength = static_cast<size_t>(ntohs(length));
1189
1222
  _readI += 2;
1190
1223
  }
1191
1224
  else if(_readPayloadLength == 127)
@@ -1314,6 +1347,18 @@ IceInternal::WSTransceiver::preRead(Buffer& buf)
1314
1347
  _pingPayload.clear();
1315
1348
  _pingPayload.resize(_readPayloadLength);
1316
1349
  memcpy(&_pingPayload[0], _readI, _pingPayload.size());
1350
+ if(_incoming)
1351
+ {
1352
+ //
1353
+ // A client masks its frames (RFC 6455 5.3), so unmask the ping payload here, just like the
1354
+ // data path does in postRead. Otherwise the pong we echo back carries the still-masked bytes
1355
+ // instead of the original ping payload (RFC 6455 5.5.3).
1356
+ //
1357
+ for(size_t i = 0; i < _pingPayload.size(); ++i)
1358
+ {
1359
+ _pingPayload[i] ^= _readMask[i % 4];
1360
+ }
1361
+ }
1317
1362
  }
1318
1363
 
1319
1364
  _readI += _readPayloadLength;
@@ -1438,15 +1483,33 @@ IceInternal::WSTransceiver::preWrite(Buffer& buf)
1438
1483
  else if(_state == StatePongPending)
1439
1484
  {
1440
1485
  prepareWriteHeader(OP_PONG, _pingPayload.size());
1441
- if(_pingPayload.size() > static_cast<size_t>(_writeBuffer.b.end() - _writeBuffer.i))
1486
+ if(!_pingPayload.empty())
1442
1487
  {
1443
- size_t pos = static_cast<size_t>(_writeBuffer.i - _writeBuffer.b.begin());
1444
- _writeBuffer.b.resize(pos + _pingPayload.size());
1445
- _writeBuffer.i = _writeBuffer.b.begin() + pos;
1488
+ if(_pingPayload.size() > static_cast<size_t>(_writeBuffer.b.end() - _writeBuffer.i))
1489
+ {
1490
+ size_t pos = static_cast<size_t>(_writeBuffer.i - _writeBuffer.b.begin());
1491
+ _writeBuffer.b.resize(pos + _pingPayload.size());
1492
+ _writeBuffer.i = _writeBuffer.b.begin() + pos;
1493
+ }
1494
+ if(_incoming)
1495
+ {
1496
+ // Server-to-client frames are not masked (RFC 6455 5.1).
1497
+ memcpy(_writeBuffer.i, &_pingPayload[0], _pingPayload.size());
1498
+ _writeBuffer.i += _pingPayload.size();
1499
+ }
1500
+ else
1501
+ {
1502
+ //
1503
+ // Client-to-server frames are masked with _writeMask, like the OP_DATA and OP_CLOSE paths;
1504
+ // prepareWriteHeader set FLAG_MASKED, so the payload must be masked to match (RFC 6455 5.5.3).
1505
+ //
1506
+ for(size_t i = 0; i < _pingPayload.size(); ++i)
1507
+ {
1508
+ *_writeBuffer.i++ = static_cast<Ice::Byte>(_pingPayload[i] ^ _writeMask[i % 4]);
1509
+ }
1510
+ }
1511
+ _pingPayload.clear();
1446
1512
  }
1447
- memcpy(_writeBuffer.i, &_pingPayload[0], _pingPayload.size());
1448
- _writeBuffer.i += _pingPayload.size();
1449
- _pingPayload.clear();
1450
1513
 
1451
1514
  _writeBuffer.b.resize(static_cast<size_t>(_writeBuffer.i - _writeBuffer.b.begin()));
1452
1515
  _writeState = WriteStateControlFrame;
@@ -1457,8 +1520,9 @@ IceInternal::WSTransceiver::preWrite(Buffer& buf)
1457
1520
  {
1458
1521
  prepareWriteHeader(OP_CLOSE, 2);
1459
1522
 
1460
- // Write closing reason
1461
- *reinterpret_cast<uint16_t*>(_writeBuffer.i) = htons(static_cast<uint16_t>(_closingReason));
1523
+ // Write closing reason. memcpy avoids the alignment UB of a direct uint16_t* store.
1524
+ const uint16_t reason = htons(static_cast<uint16_t>(_closingReason));
1525
+ memcpy(_writeBuffer.i, &reason, sizeof(reason));
1462
1526
  if(!_incoming)
1463
1527
  {
1464
1528
  *_writeBuffer.i++ ^= _writeMask[0];
@@ -1677,7 +1741,9 @@ IceInternal::WSTransceiver::prepareWriteHeader(Byte opCode, IceInternal::Buffer:
1677
1741
  // Use an extra 16 bits to encode the payload length.
1678
1742
  //
1679
1743
  *_writeBuffer.i++ = static_cast<Byte>(126);
1680
- *reinterpret_cast<uint16_t*>(_writeBuffer.i) = htons(static_cast<uint16_t>(payloadLength));
1744
+ // memcpy avoids the alignment UB of a direct uint16_t* store.
1745
+ const uint16_t length = htons(static_cast<uint16_t>(payloadLength));
1746
+ memcpy(_writeBuffer.i, &length, sizeof(length));
1681
1747
  _writeBuffer.i += 2;
1682
1748
  }
1683
1749
  else if(payloadLength > USHRT_MAX)
@@ -2,7 +2,7 @@
2
2
  // Copyright (c) ZeroC, Inc. All rights reserved.
3
3
  //
4
4
  //
5
- // Ice version 3.7.11
5
+ // Ice version 3.7.12
6
6
  //
7
7
  // <auto-generated>
8
8
  //
@@ -37,7 +37,7 @@
37
37
  # if ICE_INT_VERSION % 100 >= 50
38
38
  # error Beta header file detected
39
39
  # endif
40
- # if ICE_INT_VERSION % 100 < 11
40
+ # if ICE_INT_VERSION % 100 < 12
41
41
  # error Ice patch level mismatch!
42
42
  # endif
43
43
  #endif
@@ -2,7 +2,7 @@
2
2
  // Copyright (c) ZeroC, Inc. All rights reserved.
3
3
  //
4
4
  //
5
- // Ice version 3.7.11
5
+ // Ice version 3.7.12
6
6
  //
7
7
  // <auto-generated>
8
8
  //
@@ -41,7 +41,7 @@
41
41
  # if ICE_INT_VERSION % 100 >= 50
42
42
  # error Beta header file detected
43
43
  # endif
44
- # if ICE_INT_VERSION % 100 < 11
44
+ # if ICE_INT_VERSION % 100 < 12
45
45
  # error Ice patch level mismatch!
46
46
  # endif
47
47
  #endif
@@ -2,7 +2,7 @@
2
2
  // Copyright (c) ZeroC, Inc. All rights reserved.
3
3
  //
4
4
  //
5
- // Ice version 3.7.11
5
+ // Ice version 3.7.12
6
6
  //
7
7
  // <auto-generated>
8
8
  //
@@ -35,7 +35,7 @@
35
35
  # if ICE_INT_VERSION % 100 >= 50
36
36
  # error Beta header file detected
37
37
  # endif
38
- # if ICE_INT_VERSION % 100 < 11
38
+ # if ICE_INT_VERSION % 100 < 12
39
39
  # error Ice patch level mismatch!
40
40
  # endif
41
41
  #endif
@@ -2,7 +2,7 @@
2
2
  // Copyright (c) ZeroC, Inc. All rights reserved.
3
3
  //
4
4
  //
5
- // Ice version 3.7.11
5
+ // Ice version 3.7.12
6
6
  //
7
7
  // <auto-generated>
8
8
  //
@@ -37,7 +37,7 @@
37
37
  # if ICE_INT_VERSION % 100 >= 50
38
38
  # error Beta header file detected
39
39
  # endif
40
- # if ICE_INT_VERSION % 100 < 11
40
+ # if ICE_INT_VERSION % 100 < 12
41
41
  # error Ice patch level mismatch!
42
42
  # endif
43
43
  #endif
@@ -2,7 +2,7 @@
2
2
  // Copyright (c) ZeroC, Inc. All rights reserved.
3
3
  //
4
4
  //
5
- // Ice version 3.7.11
5
+ // Ice version 3.7.12
6
6
  //
7
7
  // <auto-generated>
8
8
  //
@@ -35,7 +35,7 @@
35
35
  # if ICE_INT_VERSION % 100 >= 50
36
36
  # error Beta header file detected
37
37
  # endif
38
- # if ICE_INT_VERSION % 100 < 11
38
+ # if ICE_INT_VERSION % 100 < 12
39
39
  # error Ice patch level mismatch!
40
40
  # endif
41
41
  #endif
@@ -2,7 +2,7 @@
2
2
  // Copyright (c) ZeroC, Inc. All rights reserved.
3
3
  //
4
4
  //
5
- // Ice version 3.7.11
5
+ // Ice version 3.7.12
6
6
  //
7
7
  // <auto-generated>
8
8
  //
@@ -37,7 +37,7 @@
37
37
  # if ICE_INT_VERSION % 100 >= 50
38
38
  # error Beta header file detected
39
39
  # endif
40
- # if ICE_INT_VERSION % 100 < 11
40
+ # if ICE_INT_VERSION % 100 < 12
41
41
  # error Ice patch level mismatch!
42
42
  # endif
43
43
  #endif
@@ -2,7 +2,7 @@
2
2
  // Copyright (c) ZeroC, Inc. All rights reserved.
3
3
  //
4
4
  //
5
- // Ice version 3.7.11
5
+ // Ice version 3.7.12
6
6
  //
7
7
  // <auto-generated>
8
8
  //
@@ -37,7 +37,7 @@
37
37
  # if ICE_INT_VERSION % 100 >= 50
38
38
  # error Beta header file detected
39
39
  # endif
40
- # if ICE_INT_VERSION % 100 < 11
40
+ # if ICE_INT_VERSION % 100 < 12
41
41
  # error Ice patch level mismatch!
42
42
  # endif
43
43
  #endif
@@ -2,7 +2,7 @@
2
2
  // Copyright (c) ZeroC, Inc. All rights reserved.
3
3
  //
4
4
  //
5
- // Ice version 3.7.11
5
+ // Ice version 3.7.12
6
6
  //
7
7
  // <auto-generated>
8
8
  //
@@ -35,7 +35,7 @@
35
35
  # if ICE_INT_VERSION % 100 >= 50
36
36
  # error Beta header file detected
37
37
  # endif
38
- # if ICE_INT_VERSION % 100 < 11
38
+ # if ICE_INT_VERSION % 100 < 12
39
39
  # error Ice patch level mismatch!
40
40
  # endif
41
41
  #endif
@@ -2,7 +2,7 @@
2
2
  // Copyright (c) ZeroC, Inc. All rights reserved.
3
3
  //
4
4
  //
5
- // Ice version 3.7.11
5
+ // Ice version 3.7.12
6
6
  //
7
7
  // <auto-generated>
8
8
  //
@@ -35,7 +35,7 @@
35
35
  # if ICE_INT_VERSION % 100 >= 50
36
36
  # error Beta header file detected
37
37
  # endif
38
- # if ICE_INT_VERSION % 100 < 11
38
+ # if ICE_INT_VERSION % 100 < 12
39
39
  # error Ice patch level mismatch!
40
40
  # endif
41
41
  #endif
@@ -2,7 +2,7 @@
2
2
  // Copyright (c) ZeroC, Inc. All rights reserved.
3
3
  //
4
4
  //
5
- // Ice version 3.7.11
5
+ // Ice version 3.7.12
6
6
  //
7
7
  // <auto-generated>
8
8
  //
@@ -37,7 +37,7 @@
37
37
  # if ICE_INT_VERSION % 100 >= 50
38
38
  # error Beta header file detected
39
39
  # endif
40
- # if ICE_INT_VERSION % 100 < 11
40
+ # if ICE_INT_VERSION % 100 < 12
41
41
  # error Ice patch level mismatch!
42
42
  # endif
43
43
  #endif
@@ -2,7 +2,7 @@
2
2
  // Copyright (c) ZeroC, Inc. All rights reserved.
3
3
  //
4
4
  //
5
- // Ice version 3.7.11
5
+ // Ice version 3.7.12
6
6
  //
7
7
  // <auto-generated>
8
8
  //
@@ -37,7 +37,7 @@
37
37
  # if ICE_INT_VERSION % 100 >= 50
38
38
  # error Beta header file detected
39
39
  # endif
40
- # if ICE_INT_VERSION % 100 < 11
40
+ # if ICE_INT_VERSION % 100 < 12
41
41
  # error Ice patch level mismatch!
42
42
  # endif
43
43
  #endif
@@ -2,7 +2,7 @@
2
2
  // Copyright (c) ZeroC, Inc. All rights reserved.
3
3
  //
4
4
  //
5
- // Ice version 3.7.11
5
+ // Ice version 3.7.12
6
6
  //
7
7
  // <auto-generated>
8
8
  //
@@ -37,7 +37,7 @@
37
37
  # if ICE_INT_VERSION % 100 >= 50
38
38
  # error Beta header file detected
39
39
  # endif
40
- # if ICE_INT_VERSION % 100 < 11
40
+ # if ICE_INT_VERSION % 100 < 12
41
41
  # error Ice patch level mismatch!
42
42
  # endif
43
43
  #endif
@@ -2,7 +2,7 @@
2
2
  // Copyright (c) ZeroC, Inc. All rights reserved.
3
3
  //
4
4
  //
5
- // Ice version 3.7.11
5
+ // Ice version 3.7.12
6
6
  //
7
7
  // <auto-generated>
8
8
  //
@@ -35,7 +35,7 @@
35
35
  # if ICE_INT_VERSION % 100 >= 50
36
36
  # error Beta header file detected
37
37
  # endif
38
- # if ICE_INT_VERSION % 100 < 11
38
+ # if ICE_INT_VERSION % 100 < 12
39
39
  # error Ice patch level mismatch!
40
40
  # endif
41
41
  #endif
@@ -2,7 +2,7 @@
2
2
  // Copyright (c) ZeroC, Inc. All rights reserved.
3
3
  //
4
4
  //
5
- // Ice version 3.7.11
5
+ // Ice version 3.7.12
6
6
  //
7
7
  // <auto-generated>
8
8
  //
@@ -37,7 +37,7 @@
37
37
  # if ICE_INT_VERSION % 100 >= 50
38
38
  # error Beta header file detected
39
39
  # endif
40
- # if ICE_INT_VERSION % 100 < 11
40
+ # if ICE_INT_VERSION % 100 < 12
41
41
  # error Ice patch level mismatch!
42
42
  # endif
43
43
  #endif
@@ -2,7 +2,7 @@
2
2
  // Copyright (c) ZeroC, Inc. All rights reserved.
3
3
  //
4
4
  //
5
- // Ice version 3.7.11
5
+ // Ice version 3.7.12
6
6
  //
7
7
  // <auto-generated>
8
8
  //
@@ -35,7 +35,7 @@
35
35
  # if ICE_INT_VERSION % 100 >= 50
36
36
  # error Beta header file detected
37
37
  # endif
38
- # if ICE_INT_VERSION % 100 < 11
38
+ # if ICE_INT_VERSION % 100 < 12
39
39
  # error Ice patch level mismatch!
40
40
  # endif
41
41
  #endif
@@ -2,7 +2,7 @@
2
2
  // Copyright (c) ZeroC, Inc. All rights reserved.
3
3
  //
4
4
  //
5
- // Ice version 3.7.11
5
+ // Ice version 3.7.12
6
6
  //
7
7
  // <auto-generated>
8
8
  //
@@ -37,7 +37,7 @@
37
37
  # if ICE_INT_VERSION % 100 >= 50
38
38
  # error Beta header file detected
39
39
  # endif
40
- # if ICE_INT_VERSION % 100 < 11
40
+ # if ICE_INT_VERSION % 100 < 12
41
41
  # error Ice patch level mismatch!
42
42
  # endif
43
43
  #endif
@@ -2,7 +2,7 @@
2
2
  // Copyright (c) ZeroC, Inc. All rights reserved.
3
3
  //
4
4
  //
5
- // Ice version 3.7.11
5
+ // Ice version 3.7.12
6
6
  //
7
7
  // <auto-generated>
8
8
  //
@@ -41,7 +41,7 @@
41
41
  # if ICE_INT_VERSION % 100 >= 50
42
42
  # error Beta header file detected
43
43
  # endif
44
- # if ICE_INT_VERSION % 100 < 11
44
+ # if ICE_INT_VERSION % 100 < 12
45
45
  # error Ice patch level mismatch!
46
46
  # endif
47
47
  #endif
@@ -2,7 +2,7 @@
2
2
  // Copyright (c) ZeroC, Inc. All rights reserved.
3
3
  //
4
4
  //
5
- // Ice version 3.7.11
5
+ // Ice version 3.7.12
6
6
  //
7
7
  // <auto-generated>
8
8
  //
@@ -37,7 +37,7 @@
37
37
  # if ICE_INT_VERSION % 100 >= 50
38
38
  # error Beta header file detected
39
39
  # endif
40
- # if ICE_INT_VERSION % 100 < 11
40
+ # if ICE_INT_VERSION % 100 < 12
41
41
  # error Ice patch level mismatch!
42
42
  # endif
43
43
  #endif
@@ -2,7 +2,7 @@
2
2
  // Copyright (c) ZeroC, Inc. All rights reserved.
3
3
  //
4
4
  //
5
- // Ice version 3.7.11
5
+ // Ice version 3.7.12
6
6
  //
7
7
  // <auto-generated>
8
8
  //
@@ -35,7 +35,7 @@
35
35
  # if ICE_INT_VERSION % 100 >= 50
36
36
  # error Beta header file detected
37
37
  # endif
38
- # if ICE_INT_VERSION % 100 < 11
38
+ # if ICE_INT_VERSION % 100 < 12
39
39
  # error Ice patch level mismatch!
40
40
  # endif
41
41
  #endif
@@ -2,7 +2,7 @@
2
2
  // Copyright (c) ZeroC, Inc. All rights reserved.
3
3
  //
4
4
  //
5
- // Ice version 3.7.11
5
+ // Ice version 3.7.12
6
6
  //
7
7
  // <auto-generated>
8
8
  //
@@ -35,7 +35,7 @@
35
35
  # if ICE_INT_VERSION % 100 >= 50
36
36
  # error Beta header file detected
37
37
  # endif
38
- # if ICE_INT_VERSION % 100 < 11
38
+ # if ICE_INT_VERSION % 100 < 12
39
39
  # error Ice patch level mismatch!
40
40
  # endif
41
41
  #endif
@@ -2,7 +2,7 @@
2
2
  // Copyright (c) ZeroC, Inc. All rights reserved.
3
3
  //
4
4
  //
5
- // Ice version 3.7.11
5
+ // Ice version 3.7.12
6
6
  //
7
7
  // <auto-generated>
8
8
  //
@@ -41,7 +41,7 @@
41
41
  # if ICE_INT_VERSION % 100 >= 50
42
42
  # error Beta header file detected
43
43
  # endif
44
- # if ICE_INT_VERSION % 100 < 11
44
+ # if ICE_INT_VERSION % 100 < 12
45
45
  # error Ice patch level mismatch!
46
46
  # endif
47
47
  #endif