grpc 1.55.0 → 1.56.0

Sign up to get free protection for your applications and to get access to all the features.

Potentially problematic release.


This version of grpc might be problematic. Click here for more details.

Files changed (374) hide show
  1. checksums.yaml +4 -4
  2. data/Makefile +100 -68
  3. data/include/grpc/event_engine/event_engine.h +4 -3
  4. data/include/grpc/grpc_audit_logging.h +96 -0
  5. data/include/grpc/module.modulemap +2 -0
  6. data/include/grpc/support/json.h +218 -0
  7. data/src/core/ext/filters/backend_metrics/backend_metric_filter.cc +5 -0
  8. data/src/core/ext/filters/client_channel/backend_metric.cc +2 -0
  9. data/src/core/ext/filters/client_channel/channel_connectivity.cc +4 -4
  10. data/src/core/ext/filters/client_channel/client_channel.cc +86 -104
  11. data/src/core/ext/filters/client_channel/client_channel.h +6 -0
  12. data/src/core/ext/filters/client_channel/client_channel_channelz.cc +19 -18
  13. data/src/core/ext/filters/client_channel/client_channel_internal.h +16 -21
  14. data/src/core/ext/filters/client_channel/config_selector.h +9 -24
  15. data/src/core/ext/filters/client_channel/lb_policy/backend_metric_data.h +3 -0
  16. data/src/core/ext/filters/client_channel/lb_policy/grpclb/grpclb.cc +5 -4
  17. data/src/core/ext/filters/client_channel/lb_policy/health_check_client.cc +455 -0
  18. data/src/core/ext/filters/client_channel/lb_policy/health_check_client.h +54 -0
  19. data/src/core/ext/filters/client_channel/lb_policy/health_check_client_internal.h +186 -0
  20. data/src/core/ext/filters/client_channel/lb_policy/oob_backend_metric.cc +2 -7
  21. data/src/core/ext/filters/client_channel/lb_policy/outlier_detection/outlier_detection.cc +52 -20
  22. data/src/core/ext/filters/client_channel/lb_policy/outlier_detection/outlier_detection.h +23 -2
  23. data/src/core/ext/filters/client_channel/lb_policy/pick_first/pick_first.cc +19 -6
  24. data/src/core/ext/filters/client_channel/lb_policy/priority/priority.cc +1 -9
  25. data/src/core/ext/filters/client_channel/lb_policy/ring_hash/ring_hash.cc +16 -7
  26. data/src/core/ext/filters/client_channel/lb_policy/ring_hash/ring_hash.h +18 -1
  27. data/src/core/ext/filters/client_channel/lb_policy/rls/rls.cc +12 -9
  28. data/src/core/ext/filters/client_channel/lb_policy/round_robin/round_robin.cc +6 -4
  29. data/src/core/ext/filters/client_channel/lb_policy/subchannel_list.h +36 -13
  30. data/src/core/ext/filters/client_channel/lb_policy/weighted_round_robin/static_stride_scheduler.cc +76 -6
  31. data/src/core/ext/filters/client_channel/lb_policy/weighted_round_robin/weighted_round_robin.cc +32 -39
  32. data/src/core/ext/filters/client_channel/lb_policy/weighted_target/weighted_target.cc +4 -10
  33. data/src/core/ext/filters/client_channel/lb_policy/xds/cds.cc +52 -47
  34. data/src/core/ext/filters/client_channel/lb_policy/xds/xds_cluster_impl.cc +1 -9
  35. data/src/core/ext/filters/client_channel/lb_policy/xds/xds_cluster_manager.cc +14 -16
  36. data/src/core/ext/filters/client_channel/lb_policy/xds/xds_cluster_resolver.cc +40 -43
  37. data/src/core/ext/filters/client_channel/lb_policy/xds/xds_override_host.cc +7 -12
  38. data/src/core/ext/filters/client_channel/lb_policy/xds/xds_wrr_locality.cc +12 -19
  39. data/src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper.cc +35 -33
  40. data/src/core/ext/filters/client_channel/resolver/dns/event_engine/event_engine_client_channel_resolver.cc +29 -4
  41. data/src/core/ext/filters/client_channel/resolver/dns/event_engine/service_config_helper.cc +1 -1
  42. data/src/core/ext/filters/client_channel/resolver/google_c2p/google_c2p_resolver.cc +28 -27
  43. data/src/core/ext/filters/client_channel/resolver/xds/xds_resolver.cc +163 -46
  44. data/src/core/ext/filters/client_channel/resolver/xds/xds_resolver.h +16 -1
  45. data/src/core/ext/filters/client_channel/retry_service_config.cc +1 -0
  46. data/src/core/ext/filters/client_channel/service_config_channel_arg_filter.cc +10 -40
  47. data/src/core/ext/filters/client_channel/subchannel.cc +10 -196
  48. data/src/core/ext/filters/client_channel/subchannel.h +3 -43
  49. data/src/core/ext/filters/http/message_compress/compression_filter.cc +5 -5
  50. data/src/core/ext/filters/rbac/rbac_service_config_parser.cc +100 -6
  51. data/src/core/ext/filters/server_config_selector/server_config_selector_filter.cc +6 -8
  52. data/src/core/ext/filters/stateful_session/stateful_session_filter.cc +3 -3
  53. data/src/core/ext/filters/stateful_session/stateful_session_filter.h +16 -1
  54. data/src/core/ext/transport/chttp2/transport/flow_control.cc +46 -95
  55. data/src/core/ext/transport/chttp2/transport/internal.h +1 -15
  56. data/src/core/ext/upb-generated/xds/data/orca/v3/orca_load_report.upb.c +11 -2
  57. data/src/core/ext/upb-generated/xds/data/orca/v3/orca_load_report.upb.h +15 -0
  58. data/src/core/ext/xds/certificate_provider_store.cc +4 -9
  59. data/src/core/ext/xds/certificate_provider_store.h +1 -1
  60. data/src/core/ext/xds/file_watcher_certificate_provider_factory.cc +30 -42
  61. data/src/core/ext/xds/file_watcher_certificate_provider_factory.h +14 -9
  62. data/src/core/ext/xds/xds_api.cc +9 -6
  63. data/src/core/ext/xds/xds_api.h +3 -2
  64. data/src/core/ext/xds/xds_audit_logger_registry.cc +122 -0
  65. data/src/core/ext/xds/xds_audit_logger_registry.h +68 -0
  66. data/src/core/ext/xds/xds_bootstrap_grpc.cc +21 -9
  67. data/src/core/ext/xds/xds_bootstrap_grpc.h +5 -0
  68. data/src/core/ext/xds/xds_client.cc +5 -4
  69. data/src/core/ext/xds/xds_client_stats.h +1 -1
  70. data/src/core/ext/xds/xds_cluster.cc +20 -19
  71. data/src/core/ext/xds/xds_cluster_specifier_plugin.cc +11 -8
  72. data/src/core/ext/xds/xds_common_types.cc +3 -1
  73. data/src/core/ext/xds/xds_http_fault_filter.cc +16 -13
  74. data/src/core/ext/xds/xds_http_fault_filter.h +2 -1
  75. data/src/core/ext/xds/xds_http_filters.h +4 -2
  76. data/src/core/ext/xds/xds_http_rbac_filter.cc +154 -67
  77. data/src/core/ext/xds/xds_http_rbac_filter.h +2 -1
  78. data/src/core/ext/xds/xds_http_stateful_session_filter.cc +15 -11
  79. data/src/core/ext/xds/xds_http_stateful_session_filter.h +2 -1
  80. data/src/core/ext/xds/xds_lb_policy_registry.cc +22 -16
  81. data/src/core/ext/xds/xds_listener.cc +1 -0
  82. data/src/core/ext/xds/xds_route_config.cc +40 -3
  83. data/src/core/ext/xds/xds_routing.cc +2 -2
  84. data/src/core/ext/xds/xds_transport_grpc.cc +3 -1
  85. data/src/core/lib/avl/avl.h +5 -0
  86. data/src/core/lib/channel/channel_args.cc +80 -22
  87. data/src/core/lib/channel/channel_args.h +34 -1
  88. data/src/core/lib/channel/channel_trace.cc +16 -12
  89. data/src/core/lib/channel/channelz.cc +159 -132
  90. data/src/core/lib/channel/channelz.h +42 -35
  91. data/src/core/lib/channel/channelz_registry.cc +23 -20
  92. data/src/core/lib/channel/connected_channel.cc +17 -6
  93. data/src/core/lib/channel/promise_based_filter.cc +0 -4
  94. data/src/core/lib/channel/promise_based_filter.h +2 -0
  95. data/src/core/lib/compression/compression_internal.cc +2 -5
  96. data/src/core/lib/config/config_vars.cc +20 -18
  97. data/src/core/lib/config/config_vars.h +4 -4
  98. data/src/core/lib/config/load_config.cc +13 -0
  99. data/src/core/lib/config/load_config.h +6 -0
  100. data/src/core/lib/debug/event_log.h +1 -1
  101. data/src/core/lib/debug/stats_data.h +1 -1
  102. data/src/core/lib/debug/trace.cc +24 -55
  103. data/src/core/lib/debug/trace.h +3 -1
  104. data/src/core/lib/event_engine/cf_engine/cf_engine.cc +211 -0
  105. data/src/core/lib/event_engine/cf_engine/cf_engine.h +86 -0
  106. data/src/core/lib/event_engine/cf_engine/cfstream_endpoint.cc +354 -0
  107. data/src/core/lib/event_engine/cf_engine/cfstream_endpoint.h +146 -0
  108. data/src/core/lib/event_engine/cf_engine/cftype_unique_ref.h +79 -0
  109. data/src/core/lib/event_engine/default_event_engine.cc +13 -1
  110. data/src/core/lib/event_engine/default_event_engine_factory.cc +14 -2
  111. data/src/core/lib/event_engine/poller.h +2 -2
  112. data/src/core/lib/event_engine/posix.h +4 -0
  113. data/src/core/lib/event_engine/posix_engine/ev_epoll1_linux.cc +1 -1
  114. data/src/core/lib/event_engine/posix_engine/lockfree_event.cc +7 -18
  115. data/src/core/lib/event_engine/posix_engine/posix_endpoint.h +9 -0
  116. data/src/core/lib/event_engine/posix_engine/posix_engine.cc +33 -19
  117. data/src/core/lib/event_engine/posix_engine/posix_engine.h +1 -1
  118. data/src/core/lib/event_engine/posix_engine/posix_engine_listener.cc +4 -4
  119. data/src/core/lib/event_engine/posix_engine/posix_engine_listener.h +7 -8
  120. data/src/core/lib/event_engine/posix_engine/timer_manager.h +1 -1
  121. data/src/core/lib/event_engine/shim.cc +7 -1
  122. data/src/core/lib/event_engine/{thread_pool.cc → thread_pool/original_thread_pool.cc} +28 -25
  123. data/src/core/lib/event_engine/{thread_pool.h → thread_pool/original_thread_pool.h} +11 -15
  124. data/src/core/lib/event_engine/thread_pool/thread_pool.h +50 -0
  125. data/src/core/lib/event_engine/{executor/executor.h → thread_pool/thread_pool_factory.cc} +17 -15
  126. data/src/core/lib/event_engine/thread_pool/work_stealing_thread_pool.cc +489 -0
  127. data/src/core/lib/event_engine/thread_pool/work_stealing_thread_pool.h +249 -0
  128. data/src/core/lib/event_engine/thready_event_engine/thready_event_engine.cc +166 -0
  129. data/src/core/lib/event_engine/thready_event_engine/thready_event_engine.h +108 -0
  130. data/src/core/lib/event_engine/windows/iocp.cc +4 -3
  131. data/src/core/lib/event_engine/windows/iocp.h +3 -3
  132. data/src/core/lib/event_engine/windows/win_socket.cc +6 -6
  133. data/src/core/lib/event_engine/windows/win_socket.h +4 -4
  134. data/src/core/lib/event_engine/windows/windows_endpoint.cc +11 -10
  135. data/src/core/lib/event_engine/windows/windows_endpoint.h +3 -2
  136. data/src/core/lib/event_engine/windows/windows_engine.cc +19 -17
  137. data/src/core/lib/event_engine/windows/windows_engine.h +6 -6
  138. data/src/core/lib/event_engine/windows/windows_listener.cc +3 -3
  139. data/src/core/lib/event_engine/windows/windows_listener.h +3 -2
  140. data/src/core/lib/event_engine/work_queue/basic_work_queue.cc +63 -0
  141. data/src/core/lib/event_engine/work_queue/basic_work_queue.h +71 -0
  142. data/src/core/lib/event_engine/work_queue/work_queue.h +62 -0
  143. data/src/core/lib/experiments/config.cc +38 -7
  144. data/src/core/lib/experiments/config.h +16 -0
  145. data/src/core/lib/experiments/experiments.cc +67 -20
  146. data/src/core/lib/experiments/experiments.h +27 -21
  147. data/src/core/lib/gpr/log_internal.h +55 -0
  148. data/src/core/lib/gprpp/crash.cc +10 -0
  149. data/src/core/lib/gprpp/crash.h +3 -0
  150. data/src/core/lib/gprpp/per_cpu.cc +33 -0
  151. data/src/core/lib/gprpp/per_cpu.h +29 -6
  152. data/src/core/lib/gprpp/time.cc +1 -0
  153. data/src/core/lib/iomgr/cfstream_handle.cc +1 -1
  154. data/src/core/lib/iomgr/endpoint_cfstream.cc +10 -8
  155. data/src/core/lib/iomgr/ev_apple.cc +12 -12
  156. data/src/core/lib/iomgr/ev_epoll1_linux.cc +10 -3
  157. data/src/core/lib/iomgr/event_engine_shims/endpoint.cc +15 -1
  158. data/src/core/lib/iomgr/iocp_windows.cc +24 -3
  159. data/src/core/lib/iomgr/iocp_windows.h +11 -0
  160. data/src/core/lib/iomgr/iomgr_posix_cfstream.cc +1 -1
  161. data/src/core/lib/iomgr/socket_utils_common_posix.cc +4 -2
  162. data/src/core/lib/iomgr/socket_windows.cc +61 -7
  163. data/src/core/lib/iomgr/socket_windows.h +9 -2
  164. data/src/core/lib/iomgr/tcp_client_cfstream.cc +14 -3
  165. data/src/core/lib/iomgr/tcp_server_posix.cc +148 -107
  166. data/src/core/lib/iomgr/tcp_server_utils_posix.h +1 -1
  167. data/src/core/lib/iomgr/tcp_server_windows.cc +1 -1
  168. data/src/core/lib/json/json.h +2 -166
  169. data/src/core/lib/json/json_object_loader.cc +8 -9
  170. data/src/core/lib/json/json_object_loader.h +25 -18
  171. data/src/core/lib/json/json_reader.cc +13 -6
  172. data/src/core/lib/json/json_util.cc +6 -11
  173. data/src/core/lib/json/json_writer.cc +7 -8
  174. data/src/core/lib/load_balancing/lb_policy.h +13 -0
  175. data/src/core/lib/load_balancing/lb_policy_registry.cc +2 -1
  176. data/src/core/lib/matchers/matchers.cc +3 -4
  177. data/src/core/lib/matchers/matchers.h +2 -1
  178. data/src/core/lib/promise/activity.cc +5 -0
  179. data/src/core/lib/promise/activity.h +10 -0
  180. data/src/core/lib/promise/detail/promise_factory.h +1 -1
  181. data/src/core/lib/promise/party.cc +31 -13
  182. data/src/core/lib/promise/party.h +11 -2
  183. data/src/core/lib/promise/pipe.h +9 -2
  184. data/src/core/lib/promise/prioritized_race.h +95 -0
  185. data/src/core/lib/promise/sleep.cc +2 -1
  186. data/src/core/lib/resolver/server_address.cc +0 -8
  187. data/src/core/lib/resolver/server_address.h +0 -6
  188. data/src/core/lib/resource_quota/memory_quota.cc +7 -7
  189. data/src/core/lib/resource_quota/memory_quota.h +1 -2
  190. data/src/core/lib/security/authorization/audit_logging.cc +98 -0
  191. data/src/core/lib/security/authorization/audit_logging.h +73 -0
  192. data/src/core/lib/security/authorization/grpc_authorization_engine.cc +47 -2
  193. data/src/core/lib/security/authorization/grpc_authorization_engine.h +18 -1
  194. data/src/core/lib/security/authorization/rbac_policy.cc +36 -4
  195. data/src/core/lib/security/authorization/rbac_policy.h +19 -2
  196. data/src/core/lib/security/authorization/stdout_logger.cc +75 -0
  197. data/src/core/lib/security/authorization/stdout_logger.h +61 -0
  198. data/src/core/lib/security/certificate_provider/certificate_provider_factory.h +8 -4
  199. data/src/core/lib/security/certificate_provider/certificate_provider_registry.cc +8 -18
  200. data/src/core/lib/security/certificate_provider/certificate_provider_registry.h +14 -8
  201. data/src/core/lib/security/credentials/external/aws_external_account_credentials.cc +19 -12
  202. data/src/core/lib/security/credentials/external/external_account_credentials.cc +4 -2
  203. data/src/core/lib/security/credentials/external/file_external_account_credentials.cc +1 -0
  204. data/src/core/lib/security/credentials/external/url_external_account_credentials.cc +1 -0
  205. data/src/core/lib/security/credentials/google_default/google_default_credentials.cc +1 -0
  206. data/src/core/lib/security/credentials/jwt/json_token.cc +15 -14
  207. data/src/core/lib/security/credentials/jwt/jwt_credentials.cc +4 -2
  208. data/src/core/lib/security/credentials/jwt/jwt_verifier.cc +1 -0
  209. data/src/core/lib/security/credentials/oauth2/oauth2_credentials.cc +1 -0
  210. data/src/core/lib/security/security_connector/alts/alts_security_connector.cc +1 -5
  211. data/src/core/lib/security/util/json_util.cc +1 -0
  212. data/src/core/lib/service_config/service_config_call_data.h +49 -20
  213. data/src/core/lib/service_config/service_config_impl.cc +2 -1
  214. data/src/core/lib/surface/call.cc +38 -23
  215. data/src/core/lib/surface/completion_queue.cc +6 -2
  216. data/src/core/lib/surface/version.cc +2 -2
  217. data/src/core/lib/transport/batch_builder.cc +15 -12
  218. data/src/core/lib/transport/batch_builder.h +39 -35
  219. data/src/core/plugin_registry/grpc_plugin_registry.cc +0 -2
  220. data/src/core/plugin_registry/grpc_plugin_registry_extra.cc +2 -0
  221. data/src/ruby/ext/grpc/extconf.rb +8 -9
  222. data/src/ruby/lib/grpc/version.rb +1 -1
  223. data/third_party/boringssl-with-bazel/src/crypto/asn1/a_mbstr.c +9 -8
  224. data/third_party/boringssl-with-bazel/src/crypto/asn1/a_strnid.c +1 -1
  225. data/third_party/boringssl-with-bazel/src/crypto/asn1/internal.h +3 -3
  226. data/third_party/boringssl-with-bazel/src/crypto/asn1/tasn_dec.c +10 -6
  227. data/third_party/boringssl-with-bazel/src/crypto/asn1/tasn_enc.c +7 -4
  228. data/third_party/boringssl-with-bazel/src/crypto/bio/bio.c +6 -4
  229. data/third_party/boringssl-with-bazel/src/crypto/bio/fd.c +2 -1
  230. data/third_party/boringssl-with-bazel/src/crypto/bio/file.c +5 -9
  231. data/third_party/boringssl-with-bazel/src/crypto/bio/pair.c +4 -2
  232. data/third_party/boringssl-with-bazel/src/crypto/blake2/blake2.c +31 -22
  233. data/third_party/boringssl-with-bazel/src/crypto/cipher_extra/e_tls.c +29 -26
  234. data/third_party/boringssl-with-bazel/src/crypto/cipher_extra/internal.h +8 -0
  235. data/third_party/boringssl-with-bazel/src/crypto/cipher_extra/tls_cbc.c +189 -13
  236. data/third_party/boringssl-with-bazel/src/crypto/cpu_aarch64_openbsd.c +62 -0
  237. data/third_party/boringssl-with-bazel/src/crypto/cpu_arm_openbsd.c +31 -0
  238. data/third_party/boringssl-with-bazel/src/crypto/curve25519/curve25519.c +6 -4
  239. data/third_party/boringssl-with-bazel/src/crypto/curve25519/curve25519_tables.h +795 -795
  240. data/third_party/boringssl-with-bazel/src/crypto/curve25519/internal.h +1 -5
  241. data/third_party/boringssl-with-bazel/src/crypto/dsa/dsa.c +4 -0
  242. data/third_party/boringssl-with-bazel/src/crypto/ec_extra/hash_to_curve.c +18 -6
  243. data/third_party/boringssl-with-bazel/src/crypto/ec_extra/internal.h +15 -7
  244. data/third_party/boringssl-with-bazel/src/crypto/ecdh_extra/ecdh_extra.c +1 -1
  245. data/third_party/boringssl-with-bazel/src/crypto/evp/p_rsa.c +1 -1
  246. data/third_party/boringssl-with-bazel/src/crypto/fipsmodule/bcm.c +1 -0
  247. data/third_party/boringssl-with-bazel/src/crypto/fipsmodule/dh/dh.c +3 -0
  248. data/third_party/boringssl-with-bazel/src/crypto/fipsmodule/ec/ec.c +24 -24
  249. data/third_party/boringssl-with-bazel/src/crypto/fipsmodule/ec/ec_key.c +1 -1
  250. data/third_party/boringssl-with-bazel/src/crypto/fipsmodule/ec/ec_montgomery.c +7 -7
  251. data/third_party/boringssl-with-bazel/src/crypto/fipsmodule/ec/internal.h +74 -74
  252. data/third_party/boringssl-with-bazel/src/crypto/fipsmodule/ec/oct.c +1 -2
  253. data/third_party/boringssl-with-bazel/src/crypto/fipsmodule/ec/p224-64.c +11 -11
  254. data/third_party/boringssl-with-bazel/src/crypto/fipsmodule/ec/p256-nistz.c +12 -12
  255. data/third_party/boringssl-with-bazel/src/crypto/fipsmodule/ec/p256.c +14 -15
  256. data/third_party/boringssl-with-bazel/src/crypto/fipsmodule/ec/p256_table.h +1 -1
  257. data/third_party/boringssl-with-bazel/src/crypto/fipsmodule/ec/simple.c +10 -10
  258. data/third_party/boringssl-with-bazel/src/crypto/fipsmodule/ec/simple_mul.c +23 -23
  259. data/third_party/boringssl-with-bazel/src/crypto/fipsmodule/ec/wnaf.c +13 -13
  260. data/third_party/boringssl-with-bazel/src/crypto/fipsmodule/ecdh/ecdh.c +1 -1
  261. data/third_party/boringssl-with-bazel/src/crypto/fipsmodule/ecdsa/ecdsa.c +2 -2
  262. data/third_party/boringssl-with-bazel/src/crypto/{hkdf → fipsmodule/hkdf}/hkdf.c +1 -1
  263. data/third_party/boringssl-with-bazel/src/crypto/fipsmodule/modes/cbc.c +2 -10
  264. data/third_party/boringssl-with-bazel/src/crypto/fipsmodule/modes/ctr.c +1 -4
  265. data/third_party/boringssl-with-bazel/src/crypto/fipsmodule/modes/gcm.c +115 -133
  266. data/third_party/boringssl-with-bazel/src/crypto/fipsmodule/modes/gcm_nohw.c +12 -14
  267. data/third_party/boringssl-with-bazel/src/crypto/fipsmodule/modes/internal.h +57 -47
  268. data/third_party/boringssl-with-bazel/src/crypto/fipsmodule/modes/ofb.c +1 -8
  269. data/third_party/boringssl-with-bazel/src/crypto/fipsmodule/modes/polyval.c +27 -28
  270. data/third_party/boringssl-with-bazel/src/crypto/fipsmodule/rand/urandom.c +11 -23
  271. data/third_party/boringssl-with-bazel/src/crypto/fipsmodule/rsa/internal.h +21 -16
  272. data/third_party/boringssl-with-bazel/src/crypto/fipsmodule/rsa/padding.c +5 -288
  273. data/third_party/boringssl-with-bazel/src/crypto/fipsmodule/rsa/rsa.c +143 -83
  274. data/third_party/boringssl-with-bazel/src/crypto/fipsmodule/rsa/rsa_impl.c +95 -183
  275. data/third_party/boringssl-with-bazel/src/crypto/fipsmodule/self_check/self_check.c +71 -0
  276. data/third_party/boringssl-with-bazel/src/crypto/fipsmodule/tls/internal.h +8 -0
  277. data/third_party/boringssl-with-bazel/src/crypto/fipsmodule/tls/kdf.c +33 -0
  278. data/third_party/boringssl-with-bazel/src/crypto/hpke/hpke.c +162 -6
  279. data/third_party/boringssl-with-bazel/src/crypto/internal.h +18 -0
  280. data/third_party/boringssl-with-bazel/src/crypto/kyber/kyber.c +18 -11
  281. data/third_party/boringssl-with-bazel/src/crypto/obj/obj_dat.h +6 -13
  282. data/third_party/boringssl-with-bazel/src/crypto/pem/pem_lib.c +18 -14
  283. data/third_party/boringssl-with-bazel/src/crypto/{refcount_lock.c → refcount_no_threads.c} +3 -13
  284. data/third_party/boringssl-with-bazel/src/crypto/refcount_win.c +89 -0
  285. data/third_party/boringssl-with-bazel/src/crypto/rsa_extra/internal.h +77 -0
  286. data/third_party/boringssl-with-bazel/src/crypto/rsa_extra/rsa_crypt.c +568 -0
  287. data/third_party/boringssl-with-bazel/src/crypto/trust_token/internal.h +62 -0
  288. data/third_party/boringssl-with-bazel/src/crypto/trust_token/pmbtoken.c +218 -44
  289. data/third_party/boringssl-with-bazel/src/crypto/trust_token/trust_token.c +35 -0
  290. data/third_party/boringssl-with-bazel/src/crypto/trust_token/voprf.c +588 -39
  291. data/third_party/boringssl-with-bazel/src/crypto/x509/a_sign.c +27 -18
  292. data/third_party/boringssl-with-bazel/src/crypto/x509/asn1_gen.c +1 -1
  293. data/third_party/boringssl-with-bazel/src/crypto/x509/name_print.c +17 -39
  294. data/third_party/boringssl-with-bazel/src/crypto/x509/t_x509.c +39 -48
  295. data/third_party/boringssl-with-bazel/src/crypto/x509/x509_att.c +0 -140
  296. data/third_party/boringssl-with-bazel/src/crypto/x509/x509_req.c +72 -23
  297. data/third_party/boringssl-with-bazel/src/crypto/x509/x509name.c +11 -14
  298. data/third_party/boringssl-with-bazel/src/crypto/x509/x509spki.c +1 -1
  299. data/third_party/boringssl-with-bazel/src/crypto/x509/x_x509a.c +2 -2
  300. data/third_party/boringssl-with-bazel/src/crypto/x509v3/internal.h +1 -1
  301. data/third_party/boringssl-with-bazel/src/crypto/x509v3/v3_conf.c +33 -46
  302. data/third_party/boringssl-with-bazel/src/crypto/x509v3/v3_cpols.c +1 -0
  303. data/third_party/boringssl-with-bazel/src/crypto/x509v3/v3_info.c +3 -5
  304. data/third_party/boringssl-with-bazel/src/crypto/x509v3/v3_lib.c +14 -46
  305. data/third_party/boringssl-with-bazel/src/crypto/x509v3/v3_prn.c +14 -26
  306. data/third_party/boringssl-with-bazel/src/crypto/x509v3/v3_skey.c +17 -10
  307. data/third_party/boringssl-with-bazel/src/crypto/x509v3/v3_utl.c +1 -1
  308. data/third_party/boringssl-with-bazel/src/include/openssl/aead.h +5 -7
  309. data/third_party/boringssl-with-bazel/src/include/openssl/asn1.h +6 -4
  310. data/third_party/boringssl-with-bazel/src/include/openssl/base.h +32 -1
  311. data/third_party/boringssl-with-bazel/src/include/openssl/bio.h +0 -4
  312. data/third_party/boringssl-with-bazel/src/include/openssl/blake2.h +1 -4
  313. data/third_party/boringssl-with-bazel/src/include/openssl/evp.h +3 -3
  314. data/third_party/boringssl-with-bazel/src/include/openssl/hpke.h +28 -0
  315. data/third_party/boringssl-with-bazel/src/include/openssl/nid.h +2 -11
  316. data/third_party/boringssl-with-bazel/src/include/openssl/pem.h +0 -3
  317. data/third_party/boringssl-with-bazel/src/include/openssl/rsa.h +91 -1
  318. data/third_party/boringssl-with-bazel/src/include/openssl/span.h +5 -0
  319. data/third_party/boringssl-with-bazel/src/include/openssl/ssl.h +149 -20
  320. data/third_party/boringssl-with-bazel/src/include/openssl/thread.h +4 -0
  321. data/third_party/boringssl-with-bazel/src/include/openssl/tls1.h +4 -0
  322. data/third_party/boringssl-with-bazel/src/include/openssl/trust_token.h +8 -0
  323. data/third_party/boringssl-with-bazel/src/include/openssl/x509.h +774 -615
  324. data/third_party/boringssl-with-bazel/src/include/openssl/x509v3.h +42 -10
  325. data/third_party/boringssl-with-bazel/src/ssl/encrypted_client_hello.cc +11 -6
  326. data/third_party/boringssl-with-bazel/src/ssl/extensions.cc +2 -4
  327. data/third_party/boringssl-with-bazel/src/ssl/handshake_client.cc +24 -16
  328. data/third_party/boringssl-with-bazel/src/ssl/internal.h +65 -18
  329. data/third_party/boringssl-with-bazel/src/ssl/s3_both.cc +37 -18
  330. data/third_party/boringssl-with-bazel/src/ssl/ssl_cipher.cc +187 -193
  331. data/third_party/boringssl-with-bazel/src/ssl/ssl_key_share.cc +13 -129
  332. data/third_party/boringssl-with-bazel/src/ssl/ssl_lib.cc +85 -10
  333. data/third_party/boringssl-with-bazel/src/ssl/ssl_privkey.cc +17 -4
  334. data/third_party/boringssl-with-bazel/src/ssl/ssl_versions.cc +27 -19
  335. data/third_party/boringssl-with-bazel/src/ssl/tls13_client.cc +1 -1
  336. data/third_party/boringssl-with-bazel/src/ssl/tls13_enc.cc +5 -21
  337. data/third_party/boringssl-with-bazel/src/ssl/tls13_server.cc +5 -2
  338. data/third_party/boringssl-with-bazel/src/third_party/fiat/curve25519_64_msvc.h +1281 -0
  339. data/third_party/boringssl-with-bazel/src/third_party/fiat/p256_64_msvc.h +2002 -0
  340. data/third_party/cares/cares/include/ares.h +23 -1
  341. data/third_party/cares/cares/{src/lib → include}/ares_nameser.h +9 -7
  342. data/third_party/cares/cares/include/ares_rules.h +2 -2
  343. data/third_party/cares/cares/include/ares_version.h +3 -3
  344. data/third_party/cares/cares/src/lib/ares__addrinfo2hostent.c +266 -0
  345. data/third_party/cares/cares/src/lib/ares__addrinfo_localhost.c +240 -0
  346. data/third_party/cares/cares/src/lib/ares__parse_into_addrinfo.c +49 -80
  347. data/third_party/cares/cares/src/lib/ares__readaddrinfo.c +37 -43
  348. data/third_party/cares/cares/src/lib/ares__sortaddrinfo.c +12 -4
  349. data/third_party/cares/cares/src/lib/ares_data.c +16 -0
  350. data/third_party/cares/cares/src/lib/ares_data.h +7 -0
  351. data/third_party/cares/cares/src/lib/ares_destroy.c +8 -0
  352. data/third_party/cares/cares/src/lib/ares_expand_name.c +17 -6
  353. data/third_party/cares/cares/src/lib/ares_freeaddrinfo.c +1 -0
  354. data/third_party/cares/cares/src/lib/ares_getaddrinfo.c +156 -78
  355. data/third_party/cares/cares/src/lib/ares_gethostbyname.c +130 -326
  356. data/third_party/cares/cares/src/lib/ares_init.c +97 -485
  357. data/third_party/cares/cares/src/lib/ares_library_init.c +2 -89
  358. data/third_party/cares/cares/src/lib/ares_parse_a_reply.c +23 -142
  359. data/third_party/cares/cares/src/lib/ares_parse_aaaa_reply.c +22 -142
  360. data/third_party/cares/cares/src/lib/ares_parse_uri_reply.c +184 -0
  361. data/third_party/cares/cares/src/lib/ares_private.h +30 -16
  362. data/third_party/cares/cares/src/lib/ares_process.c +55 -16
  363. data/third_party/cares/cares/src/lib/ares_query.c +1 -35
  364. data/third_party/cares/cares/src/lib/ares_rand.c +279 -0
  365. data/third_party/cares/cares/src/lib/ares_send.c +5 -7
  366. data/third_party/cares/cares/src/lib/ares_strdup.c +12 -19
  367. data/third_party/cares/cares/src/lib/ares_strsplit.c +44 -128
  368. data/third_party/cares/cares/src/lib/ares_strsplit.h +9 -10
  369. data/third_party/cares/cares/src/lib/inet_net_pton.c +78 -116
  370. data/third_party/cares/cares/src/tools/ares_getopt.h +53 -0
  371. metadata +48 -12
  372. data/src/core/ext/filters/client_channel/health/health_check_client.cc +0 -175
  373. data/src/core/ext/filters/client_channel/health/health_check_client.h +0 -43
  374. data/third_party/cares/cares/src/lib/ares_library_init.h +0 -43
@@ -47,9 +47,12 @@
47
47
  #include <resolv.h>
48
48
  #endif
49
49
 
50
+ #if defined(USE_WINSOCK)
51
+ # include <iphlpapi.h>
52
+ #endif
53
+
50
54
  #include "ares.h"
51
55
  #include "ares_inet_net_pton.h"
52
- #include "ares_library_init.h"
53
56
  #include "ares_nowarn.h"
54
57
  #include "ares_platform.h"
55
58
  #include "ares_private.h"
@@ -58,6 +61,7 @@
58
61
  #undef WIN32 /* Redefined in MingW/MSVC headers */
59
62
  #endif
60
63
 
64
+
61
65
  static int init_by_options(ares_channel channel,
62
66
  const struct ares_options *options,
63
67
  int optmask);
@@ -72,7 +76,6 @@ static int config_nameserver(struct server_state **servers, int *nservers,
72
76
  static int set_search(ares_channel channel, const char *str);
73
77
  static int set_options(ares_channel channel, const char *str);
74
78
  static const char *try_option(const char *p, const char *q, const char *opt);
75
- static int init_id_key(rc4_key* key,int key_data_len);
76
79
 
77
80
  static int config_sortlist(struct apattern **sortlist, int *nsort,
78
81
  const char *str);
@@ -149,6 +152,8 @@ int ares_init_options(ares_channel *channelptr, struct ares_options *options,
149
152
  channel->sock_funcs = NULL;
150
153
  channel->sock_func_cb_data = NULL;
151
154
  channel->resolvconf_path = NULL;
155
+ channel->hosts_path = NULL;
156
+ channel->rand_state = NULL;
152
157
 
153
158
  channel->last_server = 0;
154
159
  channel->last_timeout_processed = (time_t)now.tv_sec;
@@ -202,9 +207,13 @@ int ares_init_options(ares_channel *channelptr, struct ares_options *options,
202
207
  /* Generate random key */
203
208
 
204
209
  if (status == ARES_SUCCESS) {
205
- status = init_id_key(&channel->id_key, ARES_ID_KEY_LEN);
210
+ channel->rand_state = ares__init_rand_state();
211
+ if (channel->rand_state == NULL) {
212
+ status = ARES_ENOMEM;
213
+ }
214
+
206
215
  if (status == ARES_SUCCESS)
207
- channel->next_id = ares__generate_new_id(&channel->id_key);
216
+ channel->next_id = ares__generate_new_id(channel->rand_state);
208
217
  else
209
218
  DEBUGF(fprintf(stderr, "Error: init_id_key failed: %s\n",
210
219
  ares_strerror(status)));
@@ -217,13 +226,17 @@ done:
217
226
  if (channel->servers)
218
227
  ares_free(channel->servers);
219
228
  if (channel->ndomains != -1)
220
- ares_strsplit_free(channel->domains, channel->ndomains);
229
+ ares__strsplit_free(channel->domains, channel->ndomains);
221
230
  if (channel->sortlist)
222
231
  ares_free(channel->sortlist);
223
232
  if(channel->lookups)
224
233
  ares_free(channel->lookups);
225
234
  if(channel->resolvconf_path)
226
235
  ares_free(channel->resolvconf_path);
236
+ if(channel->hosts_path)
237
+ ares_free(channel->hosts_path);
238
+ if (channel->rand_state)
239
+ ares__destroy_rand_state(channel->rand_state);
227
240
  ares_free(channel);
228
241
  return status;
229
242
  }
@@ -335,6 +348,9 @@ int ares_save_options(ares_channel channel, struct ares_options *options,
335
348
  if (channel->resolvconf_path)
336
349
  (*optmask) |= ARES_OPT_RESOLVCONF;
337
350
 
351
+ if (channel->hosts_path)
352
+ (*optmask) |= ARES_OPT_HOSTS_FILE;
353
+
338
354
  /* Copy easy stuff */
339
355
  options->flags = channel->flags;
340
356
 
@@ -414,6 +430,13 @@ int ares_save_options(ares_channel channel, struct ares_options *options,
414
430
  return ARES_ENOMEM;
415
431
  }
416
432
 
433
+ /* copy path for hosts file */
434
+ if (channel->hosts_path) {
435
+ options->hosts_path = ares_strdup(channel->hosts_path);
436
+ if (!options->hosts_path)
437
+ return ARES_ENOMEM;
438
+ }
439
+
417
440
  return ARES_SUCCESS;
418
441
  }
419
442
 
@@ -530,6 +553,14 @@ static int init_by_options(ares_channel channel,
530
553
  return ARES_ENOMEM;
531
554
  }
532
555
 
556
+ /* Set path for hosts file, if given. */
557
+ if ((optmask & ARES_OPT_HOSTS_FILE) && !channel->hosts_path)
558
+ {
559
+ channel->hosts_path = ares_strdup(options->hosts_path);
560
+ if (!channel->hosts_path && options->hosts_path)
561
+ return ARES_ENOMEM;
562
+ }
563
+
533
564
  channel->optmask = optmask;
534
565
 
535
566
  return ARES_SUCCESS;
@@ -608,227 +639,6 @@ static int get_REG_SZ(HKEY hKey, const char *leafKeyName, char **outptr)
608
639
  return 1;
609
640
  }
610
641
 
611
- /*
612
- * get_REG_SZ_9X()
613
- *
614
- * Functionally identical to get_REG_SZ()
615
- *
616
- * Supported on Windows 95, 98 and ME.
617
- */
618
- static int get_REG_SZ_9X(HKEY hKey, const char *leafKeyName, char **outptr)
619
- {
620
- DWORD dataType = 0;
621
- DWORD size = 0;
622
- int res;
623
-
624
- *outptr = NULL;
625
-
626
- /* Find out size of string stored in registry */
627
- res = RegQueryValueExA(hKey, leafKeyName, 0, &dataType, NULL, &size);
628
- if ((res != ERROR_SUCCESS && res != ERROR_MORE_DATA) || !size)
629
- return 0;
630
-
631
- /* Allocate buffer of indicated size plus one given that string
632
- might have been stored without null termination */
633
- *outptr = ares_malloc(size+1);
634
- if (!*outptr)
635
- return 0;
636
-
637
- /* Get the value for real */
638
- res = RegQueryValueExA(hKey, leafKeyName, 0, &dataType,
639
- (unsigned char *)*outptr, &size);
640
- if ((res != ERROR_SUCCESS) || (size == 1))
641
- {
642
- ares_free(*outptr);
643
- *outptr = NULL;
644
- return 0;
645
- }
646
-
647
- /* Null terminate buffer allways */
648
- *(*outptr + size) = '\0';
649
-
650
- return 1;
651
- }
652
-
653
- /*
654
- * get_enum_REG_SZ()
655
- *
656
- * Given a 'hKeyParent' handle to an open registry key and a 'leafKeyName'
657
- * pointer to the name of the registry leaf key to be queried, parent key
658
- * is enumerated searching in child keys for given leaf key name and its
659
- * associated string value. When located, this returns a pointer in *outptr
660
- * to a newly allocated memory area holding it as a null-terminated string.
661
- *
662
- * Returns 0 and nullifies *outptr upon inability to return a string value.
663
- *
664
- * Returns 1 and sets *outptr when returning a dynamically allocated string.
665
- *
666
- * Supported on Windows NT 3.5 and newer.
667
- */
668
- static int get_enum_REG_SZ(HKEY hKeyParent, const char *leafKeyName,
669
- char **outptr)
670
- {
671
- char enumKeyName[256];
672
- DWORD enumKeyNameBuffSize;
673
- DWORD enumKeyIdx = 0;
674
- HKEY hKeyEnum;
675
- int gotString;
676
- int res;
677
-
678
- *outptr = NULL;
679
-
680
- for(;;)
681
- {
682
- enumKeyNameBuffSize = sizeof(enumKeyName);
683
- res = RegEnumKeyExA(hKeyParent, enumKeyIdx++, enumKeyName,
684
- &enumKeyNameBuffSize, 0, NULL, NULL, NULL);
685
- if (res != ERROR_SUCCESS)
686
- break;
687
- res = RegOpenKeyExA(hKeyParent, enumKeyName, 0, KEY_QUERY_VALUE,
688
- &hKeyEnum);
689
- if (res != ERROR_SUCCESS)
690
- continue;
691
- gotString = get_REG_SZ(hKeyEnum, leafKeyName, outptr);
692
- RegCloseKey(hKeyEnum);
693
- if (gotString)
694
- break;
695
- }
696
-
697
- if (!*outptr)
698
- return 0;
699
-
700
- return 1;
701
- }
702
-
703
- /*
704
- * get_DNS_Registry_9X()
705
- *
706
- * Functionally identical to get_DNS_Registry()
707
- *
708
- * Implementation supports Windows 95, 98 and ME.
709
- */
710
- static int get_DNS_Registry_9X(char **outptr)
711
- {
712
- HKEY hKey_VxD_MStcp;
713
- int gotString;
714
- int res;
715
-
716
- *outptr = NULL;
717
-
718
- res = RegOpenKeyExA(HKEY_LOCAL_MACHINE, WIN_NS_9X, 0, KEY_READ,
719
- &hKey_VxD_MStcp);
720
- if (res != ERROR_SUCCESS)
721
- return 0;
722
-
723
- gotString = get_REG_SZ_9X(hKey_VxD_MStcp, NAMESERVER, outptr);
724
- RegCloseKey(hKey_VxD_MStcp);
725
-
726
- if (!gotString || !*outptr)
727
- return 0;
728
-
729
- return 1;
730
- }
731
-
732
- /*
733
- * get_DNS_Registry_NT()
734
- *
735
- * Functionally identical to get_DNS_Registry()
736
- *
737
- * Refs: Microsoft Knowledge Base articles KB120642 and KB314053.
738
- *
739
- * Implementation supports Windows NT 3.5 and newer.
740
- */
741
- static int get_DNS_Registry_NT(char **outptr)
742
- {
743
- HKEY hKey_Interfaces = NULL;
744
- HKEY hKey_Tcpip_Parameters;
745
- int gotString;
746
- int res;
747
-
748
- *outptr = NULL;
749
-
750
- res = RegOpenKeyExA(HKEY_LOCAL_MACHINE, WIN_NS_NT_KEY, 0, KEY_READ,
751
- &hKey_Tcpip_Parameters);
752
- if (res != ERROR_SUCCESS)
753
- return 0;
754
-
755
- /*
756
- ** Global DNS settings override adapter specific parameters when both
757
- ** are set. Additionally static DNS settings override DHCP-configured
758
- ** parameters when both are set.
759
- */
760
-
761
- /* Global DNS static parameters */
762
- gotString = get_REG_SZ(hKey_Tcpip_Parameters, NAMESERVER, outptr);
763
- if (gotString)
764
- goto done;
765
-
766
- /* Global DNS DHCP-configured parameters */
767
- gotString = get_REG_SZ(hKey_Tcpip_Parameters, DHCPNAMESERVER, outptr);
768
- if (gotString)
769
- goto done;
770
-
771
- /* Try adapter specific parameters */
772
- res = RegOpenKeyExA(hKey_Tcpip_Parameters, "Interfaces", 0,
773
- KEY_QUERY_VALUE | KEY_ENUMERATE_SUB_KEYS,
774
- &hKey_Interfaces);
775
- if (res != ERROR_SUCCESS)
776
- {
777
- hKey_Interfaces = NULL;
778
- goto done;
779
- }
780
-
781
- /* Adapter specific DNS static parameters */
782
- gotString = get_enum_REG_SZ(hKey_Interfaces, NAMESERVER, outptr);
783
- if (gotString)
784
- goto done;
785
-
786
- /* Adapter specific DNS DHCP-configured parameters */
787
- gotString = get_enum_REG_SZ(hKey_Interfaces, DHCPNAMESERVER, outptr);
788
-
789
- done:
790
- if (hKey_Interfaces)
791
- RegCloseKey(hKey_Interfaces);
792
-
793
- RegCloseKey(hKey_Tcpip_Parameters);
794
-
795
- if (!gotString || !*outptr)
796
- return 0;
797
-
798
- return 1;
799
- }
800
-
801
- /*
802
- * get_DNS_Registry()
803
- *
804
- * Locates DNS info in the registry. When located, this returns a pointer
805
- * in *outptr to a newly allocated memory area holding a null-terminated
806
- * string with a space or comma seperated list of DNS IP addresses.
807
- *
808
- * Returns 0 and nullifies *outptr upon inability to return DNSes string.
809
- *
810
- * Returns 1 and sets *outptr when returning a dynamically allocated string.
811
- */
812
- static int get_DNS_Registry(char **outptr)
813
- {
814
- win_platform platform;
815
- int gotString = 0;
816
-
817
- *outptr = NULL;
818
-
819
- platform = ares__getplatform();
820
-
821
- if (platform == WIN_NT)
822
- gotString = get_DNS_Registry_NT(outptr);
823
- else if (platform == WIN_9X)
824
- gotString = get_DNS_Registry_9X(outptr);
825
-
826
- if (!gotString)
827
- return 0;
828
-
829
- return 1;
830
- }
831
-
832
642
  static void commanjoin(char** dst, const char* const src, const size_t len)
833
643
  {
834
644
  char *newbuf;
@@ -857,106 +667,6 @@ static void commajoin(char **dst, const char *src)
857
667
  commanjoin(dst, src, strlen(src));
858
668
  }
859
669
 
860
- /*
861
- * get_DNS_NetworkParams()
862
- *
863
- * Locates DNS info using GetNetworkParams() function from the Internet
864
- * Protocol Helper (IP Helper) API. When located, this returns a pointer
865
- * in *outptr to a newly allocated memory area holding a null-terminated
866
- * string with a space or comma seperated list of DNS IP addresses.
867
- *
868
- * Returns 0 and nullifies *outptr upon inability to return DNSes string.
869
- *
870
- * Returns 1 and sets *outptr when returning a dynamically allocated string.
871
- *
872
- * Implementation supports Windows 98 and newer.
873
- *
874
- * Note: Ancient PSDK required in order to build a W98 target.
875
- */
876
- static int get_DNS_NetworkParams(char **outptr)
877
- {
878
- FIXED_INFO *fi, *newfi;
879
- struct ares_addr namesrvr;
880
- char *txtaddr;
881
- IP_ADDR_STRING *ipAddr;
882
- int res;
883
- DWORD size = sizeof (*fi);
884
-
885
- *outptr = NULL;
886
-
887
- /* Verify run-time availability of GetNetworkParams() */
888
- if (ares_fpGetNetworkParams == ZERO_NULL)
889
- return 0;
890
-
891
- fi = ares_malloc(size);
892
- if (!fi)
893
- return 0;
894
-
895
- res = (*ares_fpGetNetworkParams) (fi, &size);
896
- if ((res != ERROR_BUFFER_OVERFLOW) && (res != ERROR_SUCCESS))
897
- goto done;
898
-
899
- newfi = ares_realloc(fi, size);
900
- if (!newfi)
901
- goto done;
902
-
903
- fi = newfi;
904
- res = (*ares_fpGetNetworkParams) (fi, &size);
905
- if (res != ERROR_SUCCESS)
906
- goto done;
907
-
908
- for (ipAddr = &fi->DnsServerList; ipAddr; ipAddr = ipAddr->Next)
909
- {
910
- txtaddr = &ipAddr->IpAddress.String[0];
911
-
912
- /* Validate converting textual address to binary format. */
913
- if (ares_inet_pton(AF_INET, txtaddr, &namesrvr.addrV4) == 1)
914
- {
915
- if ((namesrvr.addrV4.S_un.S_addr == INADDR_ANY) ||
916
- (namesrvr.addrV4.S_un.S_addr == INADDR_NONE))
917
- continue;
918
- }
919
- else if (ares_inet_pton(AF_INET6, txtaddr, &namesrvr.addrV6) == 1)
920
- {
921
- if (memcmp(&namesrvr.addrV6, &ares_in6addr_any,
922
- sizeof(namesrvr.addrV6)) == 0)
923
- continue;
924
- }
925
- else
926
- continue;
927
-
928
- commajoin(outptr, txtaddr);
929
-
930
- if (!*outptr)
931
- break;
932
- }
933
-
934
- done:
935
- if (fi)
936
- ares_free(fi);
937
-
938
- if (!*outptr)
939
- return 0;
940
-
941
- return 1;
942
- }
943
-
944
- static BOOL ares_IsWindowsVistaOrGreater(void)
945
- {
946
- OSVERSIONINFO vinfo;
947
- memset(&vinfo, 0, sizeof(vinfo));
948
- vinfo.dwOSVersionInfoSize = sizeof(vinfo);
949
- #ifdef _MSC_VER
950
- #pragma warning(push)
951
- #pragma warning(disable:4996) /* warning C4996: 'GetVersionExW': was declared deprecated */
952
- #endif
953
- if (!GetVersionEx(&vinfo) || vinfo.dwMajorVersion < 6)
954
- return FALSE;
955
- return TRUE;
956
- #ifdef _MSC_VER
957
- #pragma warning(pop)
958
- #endif
959
- }
960
670
 
961
671
  /* A structure to hold the string form of IPv4 and IPv6 addresses so we can
962
672
  * sort them by a metric.
@@ -1031,23 +741,33 @@ static ULONG getBestRouteMetric(IF_LUID * const luid, /* Can't be const :( */
1031
741
  const ULONG interfaceMetric)
1032
742
  {
1033
743
  /* On this interface, get the best route to that destination. */
744
+ #if defined(__WATCOMC__)
745
+ /* OpenWatcom's builtin Windows SDK does not have a definition for
746
+ * MIB_IPFORWARD_ROW2, and also does not allow the usage of SOCKADDR_INET
747
+ * as a variable. Let's work around this by returning the worst possible
748
+ * metric, but only when using the OpenWatcom compiler.
749
+ * It may be worth investigating using a different version of the Windows
750
+ * SDK with OpenWatcom in the future, though this may be fixed in OpenWatcom
751
+ * 2.0.
752
+ */
753
+ return (ULONG)-1;
754
+ #else
1034
755
  MIB_IPFORWARD_ROW2 row;
1035
756
  SOCKADDR_INET ignored;
1036
- if(!ares_fpGetBestRoute2 ||
1037
- ares_fpGetBestRoute2(/* The interface to use. The index is ignored since we are
1038
- * passing a LUID.
1039
- */
1040
- luid, 0,
1041
- /* No specific source address. */
1042
- NULL,
1043
- /* Our destination address. */
1044
- dest,
1045
- /* No options. */
1046
- 0,
1047
- /* The route row. */
1048
- &row,
1049
- /* The best source address, which we don't need. */
1050
- &ignored) != NO_ERROR
757
+ if(GetBestRoute2(/* The interface to use. The index is ignored since we are
758
+ * passing a LUID.
759
+ */
760
+ luid, 0,
761
+ /* No specific source address. */
762
+ NULL,
763
+ /* Our destination address. */
764
+ dest,
765
+ /* No options. */
766
+ 0,
767
+ /* The route row. */
768
+ &row,
769
+ /* The best source address, which we don't need. */
770
+ &ignored) != NO_ERROR
1051
771
  /* If the metric is "unused" (-1) or too large for us to add the two
1052
772
  * metrics, use the worst possible, thus sorting this last.
1053
773
  */
@@ -1064,10 +784,11 @@ static ULONG getBestRouteMetric(IF_LUID * const luid, /* Can't be const :( */
1064
784
  * which describes the combination as a "sum".
1065
785
  */
1066
786
  return row.Metric + interfaceMetric;
787
+ #endif /* __WATCOMC__ */
1067
788
  }
1068
789
 
1069
790
  /*
1070
- * get_DNS_AdaptersAddresses()
791
+ * get_DNS_Windows()
1071
792
  *
1072
793
  * Locates DNS info using GetAdaptersAddresses() function from the Internet
1073
794
  * Protocol Helper (IP Helper) API. When located, this returns a pointer
@@ -1082,7 +803,7 @@ static ULONG getBestRouteMetric(IF_LUID * const luid, /* Can't be const :( */
1082
803
  */
1083
804
  #define IPAA_INITIAL_BUF_SZ 15 * 1024
1084
805
  #define IPAA_MAX_TRIES 3
1085
- static int get_DNS_AdaptersAddresses(char **outptr)
806
+ static int get_DNS_Windows(char **outptr)
1086
807
  {
1087
808
  IP_ADAPTER_DNS_SERVER_ADDRESS *ipaDNSAddr;
1088
809
  IP_ADAPTER_ADDRESSES *ipaa, *newipaa, *ipaaEntry;
@@ -1107,10 +828,6 @@ static int get_DNS_AdaptersAddresses(char **outptr)
1107
828
 
1108
829
  *outptr = NULL;
1109
830
 
1110
- /* Verify run-time availability of GetAdaptersAddresses() */
1111
- if (ares_fpGetAdaptersAddresses == ZERO_NULL)
1112
- return 0;
1113
-
1114
831
  ipaa = ares_malloc(Bufsz);
1115
832
  if (!ipaa)
1116
833
  return 0;
@@ -1127,8 +844,7 @@ static int get_DNS_AdaptersAddresses(char **outptr)
1127
844
  }
1128
845
 
1129
846
  /* Usually this call suceeds with initial buffer size */
1130
- res = (*ares_fpGetAdaptersAddresses) (AF_UNSPEC, AddrFlags, NULL,
1131
- ipaa, &ReqBufsz);
847
+ res = GetAdaptersAddresses(AF_UNSPEC, AddrFlags, NULL, ipaa, &ReqBufsz);
1132
848
  if ((res != ERROR_BUFFER_OVERFLOW) && (res != ERROR_SUCCESS))
1133
849
  goto done;
1134
850
 
@@ -1142,8 +858,7 @@ static int get_DNS_AdaptersAddresses(char **outptr)
1142
858
  Bufsz = ReqBufsz;
1143
859
  ipaa = newipaa;
1144
860
  }
1145
- res = (*ares_fpGetAdaptersAddresses) (AF_UNSPEC, AddrFlags, NULL,
1146
- ipaa, &ReqBufsz);
861
+ res = GetAdaptersAddresses(AF_UNSPEC, AddrFlags, NULL, ipaa, &ReqBufsz);
1147
862
  if (res == ERROR_SUCCESS)
1148
863
  break;
1149
864
  }
@@ -1185,26 +900,17 @@ static int get_DNS_AdaptersAddresses(char **outptr)
1185
900
  addressesSize = newSize;
1186
901
  }
1187
902
 
1188
- /* Vista required for Luid or Ipv4Metric */
1189
- if (ares_IsWindowsVistaOrGreater())
1190
- {
1191
- /* Save the address as the next element in addresses. */
1192
- addresses[addressesIndex].metric =
1193
- getBestRouteMetric(&ipaaEntry->Luid,
1194
- (SOCKADDR_INET*)(namesrvr.sa),
1195
- ipaaEntry->Ipv4Metric);
1196
- }
1197
- else
1198
- {
1199
- addresses[addressesIndex].metric = (ULONG)-1;
1200
- }
903
+ addresses[addressesIndex].metric =
904
+ getBestRouteMetric(&ipaaEntry->Luid,
905
+ (SOCKADDR_INET*)(namesrvr.sa),
906
+ ipaaEntry->Ipv4Metric);
1201
907
 
1202
908
  /* Record insertion index to make qsort stable */
1203
909
  addresses[addressesIndex].orig_idx = addressesIndex;
1204
910
 
1205
- if (! ares_inet_ntop(AF_INET, &namesrvr.sa4->sin_addr,
1206
- addresses[addressesIndex].text,
1207
- sizeof(addresses[0].text))) {
911
+ if (!ares_inet_ntop(AF_INET, &namesrvr.sa4->sin_addr,
912
+ addresses[addressesIndex].text,
913
+ sizeof(addresses[0].text))) {
1208
914
  continue;
1209
915
  }
1210
916
  ++addressesIndex;
@@ -1227,26 +933,17 @@ static int get_DNS_AdaptersAddresses(char **outptr)
1227
933
  addressesSize = newSize;
1228
934
  }
1229
935
 
1230
- /* Vista required for Luid or Ipv4Metric */
1231
- if (ares_IsWindowsVistaOrGreater())
1232
- {
1233
- /* Save the address as the next element in addresses. */
1234
- addresses[addressesIndex].metric =
1235
- getBestRouteMetric(&ipaaEntry->Luid,
1236
- (SOCKADDR_INET*)(namesrvr.sa),
1237
- ipaaEntry->Ipv6Metric);
1238
- }
1239
- else
1240
- {
1241
- addresses[addressesIndex].metric = (ULONG)-1;
1242
- }
936
+ addresses[addressesIndex].metric =
937
+ getBestRouteMetric(&ipaaEntry->Luid,
938
+ (SOCKADDR_INET*)(namesrvr.sa),
939
+ ipaaEntry->Ipv6Metric);
1243
940
 
1244
941
  /* Record insertion index to make qsort stable */
1245
942
  addresses[addressesIndex].orig_idx = addressesIndex;
1246
943
 
1247
- if (! ares_inet_ntop(AF_INET6, &namesrvr.sa6->sin6_addr,
1248
- addresses[addressesIndex].text,
1249
- sizeof(addresses[0].text))) {
944
+ if (!ares_inet_ntop(AF_INET6, &namesrvr.sa6->sin6_addr,
945
+ addresses[addressesIndex].text,
946
+ sizeof(addresses[0].text))) {
1250
947
  continue;
1251
948
  }
1252
949
  ++addressesIndex;
@@ -1294,35 +991,6 @@ done:
1294
991
  return 1;
1295
992
  }
1296
993
 
1297
- /*
1298
- * get_DNS_Windows()
1299
- *
1300
- * Locates DNS info from Windows employing most suitable methods available at
1301
- * run-time no matter which Windows version it is. When located, this returns
1302
- * a pointer in *outptr to a newly allocated memory area holding a string with
1303
- * a space or comma seperated list of DNS IP addresses, null-terminated.
1304
- *
1305
- * Returns 0 and nullifies *outptr upon inability to return DNSes string.
1306
- *
1307
- * Returns 1 and sets *outptr when returning a dynamically allocated string.
1308
- *
1309
- * Implementation supports Windows 95 and newer.
1310
- */
1311
- static int get_DNS_Windows(char **outptr)
1312
- {
1313
- /* Try using IP helper API GetAdaptersAddresses(). IPv4 + IPv6, also sorts
1314
- * DNS servers by interface route metrics to try to use the best DNS server. */
1315
- if (get_DNS_AdaptersAddresses(outptr))
1316
- return 1;
1317
-
1318
- /* Try using IP helper API GetNetworkParams(). IPv4 only. */
1319
- if (get_DNS_NetworkParams(outptr))
1320
- return 1;
1321
-
1322
- /* Fall-back to registry information */
1323
- return get_DNS_Registry(outptr);
1324
- }
1325
-
1326
994
  /*
1327
995
  * get_SuffixList_Windows()
1328
996
  *
@@ -1470,7 +1138,7 @@ static int init_by_resolv_conf(ares_channel channel)
1470
1138
  struct __res_state *res = 0;
1471
1139
  int count4, count6;
1472
1140
  __STATEEXTIPV6 *v6;
1473
- struct server_state *pserver
1141
+ struct server_state *pserver;
1474
1142
  if (0 == res) {
1475
1143
  int rc = res_init();
1476
1144
  while (rc == -1 && h_errno == TRY_AGAIN) {
@@ -1686,8 +1354,12 @@ static int init_by_resolv_conf(ares_channel channel)
1686
1354
  channel->tries = res.retry;
1687
1355
  if (channel->rotate == -1)
1688
1356
  channel->rotate = res.options & RES_ROTATE;
1689
- if (channel->timeout == -1)
1357
+ if (channel->timeout == -1) {
1690
1358
  channel->timeout = res.retrans * 1000;
1359
+ #ifdef __APPLE__
1360
+ channel->timeout /= (res.retry + 1) * (res.nscount > 0 ? res.nscount : 1);
1361
+ #endif
1362
+ }
1691
1363
 
1692
1364
  res_ndestroy(&res);
1693
1365
  }
@@ -2021,6 +1693,11 @@ static int init_by_defaults(ares_channel channel)
2021
1693
  ares_free(channel->resolvconf_path);
2022
1694
  channel->resolvconf_path = NULL;
2023
1695
  }
1696
+
1697
+ if(channel->hosts_path) {
1698
+ ares_free(channel->hosts_path);
1699
+ channel->hosts_path = NULL;
1700
+ }
2024
1701
  }
2025
1702
 
2026
1703
  if(hostname)
@@ -2243,6 +1920,8 @@ static int config_sortlist(struct apattern **sortlist, int *nsort,
2243
1920
  q = str;
2244
1921
  while (*q && *q != '/' && *q != ';' && !ISSPACE(*q))
2245
1922
  q++;
1923
+ if (q-str >= 16)
1924
+ return ARES_EBADSTR;
2246
1925
  memcpy(ipbuf, str, q-str);
2247
1926
  ipbuf[q-str] = '\0';
2248
1927
  /* Find the prefix */
@@ -2251,6 +1930,8 @@ static int config_sortlist(struct apattern **sortlist, int *nsort,
2251
1930
  const char *str2 = q+1;
2252
1931
  while (*q && *q != ';' && !ISSPACE(*q))
2253
1932
  q++;
1933
+ if (q-str >= 32)
1934
+ return ARES_EBADSTR;
2254
1935
  memcpy(ipbufpfx, str, q-str);
2255
1936
  ipbufpfx[q-str] = '\0';
2256
1937
  str = str2;
@@ -2325,12 +2006,12 @@ static int set_search(ares_channel channel, const char *str)
2325
2006
  if(channel->ndomains != -1) {
2326
2007
  /* LCOV_EXCL_START: all callers check ndomains == -1 */
2327
2008
  /* if we already have some domains present, free them first */
2328
- ares_strsplit_free(channel->domains, channel->ndomains);
2009
+ ares__strsplit_free(channel->domains, channel->ndomains);
2329
2010
  channel->domains = NULL;
2330
2011
  channel->ndomains = -1;
2331
2012
  } /* LCOV_EXCL_STOP */
2332
2013
 
2333
- channel->domains = ares_strsplit(str, ", ", 1, &cnt);
2014
+ channel->domains = ares__strsplit(str, ", ", &cnt);
2334
2015
  channel->ndomains = (int)cnt;
2335
2016
  if (channel->domains == NULL || channel->ndomains == 0) {
2336
2017
  channel->domains = NULL;
@@ -2495,75 +2176,6 @@ static int sortlist_alloc(struct apattern **sortlist, int *nsort,
2495
2176
  return 1;
2496
2177
  }
2497
2178
 
2498
- /* initialize an rc4 key. If possible a cryptographically secure random key
2499
- is generated using a suitable function (for example win32's RtlGenRandom as
2500
- described in
2501
- http://blogs.msdn.com/michael_howard/archive/2005/01/14/353379.aspx
2502
- otherwise the code defaults to cross-platform albeit less secure mechanism
2503
- using rand
2504
- */
2505
- static void randomize_key(unsigned char* key,int key_data_len)
2506
- {
2507
- int randomized = 0;
2508
- int counter=0;
2509
- #ifdef WIN32
2510
- BOOLEAN res;
2511
- if (ares_fpSystemFunction036)
2512
- {
2513
- res = (*ares_fpSystemFunction036) (key, key_data_len);
2514
- if (res)
2515
- randomized = 1;
2516
- }
2517
- #else /* !WIN32 */
2518
- #ifdef CARES_RANDOM_FILE
2519
- FILE *f = fopen(CARES_RANDOM_FILE, "rb");
2520
- if(f) {
2521
- setvbuf(f, NULL, _IONBF, 0);
2522
- counter = aresx_uztosi(fread(key, 1, key_data_len, f));
2523
- fclose(f);
2524
- }
2525
- #endif
2526
- #endif /* WIN32 */
2527
-
2528
- if (!randomized) {
2529
- for (;counter<key_data_len;counter++)
2530
- key[counter]=(unsigned char)(rand() % 256); /* LCOV_EXCL_LINE */
2531
- }
2532
- }
2533
-
2534
- static int init_id_key(rc4_key* key,int key_data_len)
2535
- {
2536
- unsigned char index1;
2537
- unsigned char index2;
2538
- unsigned char* state;
2539
- short counter;
2540
- unsigned char *key_data_ptr = 0;
2541
-
2542
- key_data_ptr = ares_malloc(key_data_len);
2543
- if (!key_data_ptr)
2544
- return ARES_ENOMEM;
2545
- memset(key_data_ptr, 0, key_data_len);
2546
-
2547
- state = &key->state[0];
2548
- for(counter = 0; counter < 256; counter++)
2549
- /* unnecessary AND but it keeps some compilers happier */
2550
- state[counter] = (unsigned char)(counter & 0xff);
2551
- randomize_key(key->state,key_data_len);
2552
- key->x = 0;
2553
- key->y = 0;
2554
- index1 = 0;
2555
- index2 = 0;
2556
- for(counter = 0; counter < 256; counter++)
2557
- {
2558
- index2 = (unsigned char)((key_data_ptr[index1] + state[counter] +
2559
- index2) % 256);
2560
- ARES_SWAP_BYTE(&state[counter], &state[index2]);
2561
-
2562
- index1 = (unsigned char)((index1 + 1) % key_data_len);
2563
- }
2564
- ares_free(key_data_ptr);
2565
- return ARES_SUCCESS;
2566
- }
2567
2179
 
2568
2180
  void ares_set_local_ip4(ares_channel channel, unsigned int local_ip)
2569
2181
  {