Merge github.com:grpc/grpc into grpc_slice

pull/8532/head
Craig Tiller 8 years ago
commit 328cbccfee
  1. 4
      build.yaml
  2. 7
      src/core/lib/channel/http_server_filter.c
  3. 10
      src/core/lib/transport/metadata.c
  4. 196
      test/core/end2end/fuzzers/api_fuzzer.c
  5. BIN
      test/core/end2end/fuzzers/api_fuzzer_corpus/0077816beb340a2ef87cc57c18e0ce0d1e6e23fc
  6. BIN
      test/core/end2end/fuzzers/api_fuzzer_corpus/00a1b8e686014202baacdc052a38d392dff11432
  7. BIN
      test/core/end2end/fuzzers/api_fuzzer_corpus/00c7c2cc7f90842e766645310e4a439e7b188473
  8. BIN
      test/core/end2end/fuzzers/api_fuzzer_corpus/00f89898cb8f3e3c20e7be1d8c7a1544fb81ea5e
  9. BIN
      test/core/end2end/fuzzers/api_fuzzer_corpus/0173fb5c52d97d0d63266a529bf2f6442894b0c6
  10. BIN
      test/core/end2end/fuzzers/api_fuzzer_corpus/020d06c319b6e511021d21316ba283bca9b40dc9
  11. BIN
      test/core/end2end/fuzzers/api_fuzzer_corpus/0598f8881c26b7e9562cdc4c3f86749dd49598d6
  12. BIN
      test/core/end2end/fuzzers/api_fuzzer_corpus/071b85ef412067e7db9188bee7c92e4fd661e021
  13. BIN
      test/core/end2end/fuzzers/api_fuzzer_corpus/0768af66da5e344f21337df8eb0a1c8c955f4244
  14. BIN
      test/core/end2end/fuzzers/api_fuzzer_corpus/077202f145bfc7dff77e820cbe6ac6e4ae76e1ed
  15. BIN
      test/core/end2end/fuzzers/api_fuzzer_corpus/07e7bbb0005535e901b7f50e13cba9d5da51c2a5
  16. BIN
      test/core/end2end/fuzzers/api_fuzzer_corpus/08a6761ed9d5298fc0d0fe9e75196f7527e488d4
  17. BIN
      test/core/end2end/fuzzers/api_fuzzer_corpus/092575ab527ffb459d2e1eed593902820bb462c0
  18. BIN
      test/core/end2end/fuzzers/api_fuzzer_corpus/09985e738bf04fb7827367f2ae70f4697ff5aaf0
  19. BIN
      test/core/end2end/fuzzers/api_fuzzer_corpus/099d967555bfc237238c93f9d884c004c773b33b
  20. BIN
      test/core/end2end/fuzzers/api_fuzzer_corpus/0b08fc5a8eb4a23766be7b3082308959955d4b13
  21. BIN
      test/core/end2end/fuzzers/api_fuzzer_corpus/0c088a8261de0bf3b996cc1e7889399acb03fd5a
  22. BIN
      test/core/end2end/fuzzers/api_fuzzer_corpus/0c10483d4f5018b899483bcf23094f9119919ca4
  23. BIN
      test/core/end2end/fuzzers/api_fuzzer_corpus/0c653a4b68bd77eec050b66ff2d8eae13001c505
  24. BIN
      test/core/end2end/fuzzers/api_fuzzer_corpus/0df8bd9c41fb5d8ce8a0f2f28ca16be96bd9997e
  25. BIN
      test/core/end2end/fuzzers/api_fuzzer_corpus/0e0ecc8214b5083b75216857b967621c0648afc9
  26. BIN
      test/core/end2end/fuzzers/api_fuzzer_corpus/0e5aa755fff40b487617e01f6812d85ad310b727
  27. BIN
      test/core/end2end/fuzzers/api_fuzzer_corpus/0f10d36e818e41f1737245c2bb8cb83a69421cb1
  28. BIN
      test/core/end2end/fuzzers/api_fuzzer_corpus/10ee46dc1973472ead36ec4b8a1ea90200637c73
  29. BIN
      test/core/end2end/fuzzers/api_fuzzer_corpus/13b2e7a9d9f07a9e06ed96957c56e968f3b6070d
  30. BIN
      test/core/end2end/fuzzers/api_fuzzer_corpus/13c269dc54b84acbf75b78db730c25311a61c4ab
  31. BIN
      test/core/end2end/fuzzers/api_fuzzer_corpus/140219fcde79e1de47129172abaef4e06e72534d
  32. BIN
      test/core/end2end/fuzzers/api_fuzzer_corpus/16b69b968a140abb00dd5c79ea7d0c1b23510fe7
  33. BIN
      test/core/end2end/fuzzers/api_fuzzer_corpus/16f798191df0c173217cdcb4ec8edd3e4f7fb99b
  34. BIN
      test/core/end2end/fuzzers/api_fuzzer_corpus/17381a0515458a92bc8248051b600da4020a1207
  35. BIN
      test/core/end2end/fuzzers/api_fuzzer_corpus/17647336806cf94a0224516f3d8caa22367c7c5a
  36. BIN
      test/core/end2end/fuzzers/api_fuzzer_corpus/17c7024889cc97a8afd3133b55a147ba75d17188
  37. BIN
      test/core/end2end/fuzzers/api_fuzzer_corpus/194027acca76bf2e874aa672b4491f0b7fe32187
  38. BIN
      test/core/end2end/fuzzers/api_fuzzer_corpus/1a6119919790570e3c15bb371648fc7929c72ea2
  39. BIN
      test/core/end2end/fuzzers/api_fuzzer_corpus/1abcbb03796c6512f5b8a977532fbcf6368b45b0
  40. BIN
      test/core/end2end/fuzzers/api_fuzzer_corpus/1c1a1980a1959423766c5a26ac79d07264224278
  41. BIN
      test/core/end2end/fuzzers/api_fuzzer_corpus/1d505e827d0036b3d8eab87439d31da5f901aed1
  42. BIN
      test/core/end2end/fuzzers/api_fuzzer_corpus/1dd9698ad85c7ab577bbc9b36180ef2641d8525c
  43. BIN
      test/core/end2end/fuzzers/api_fuzzer_corpus/217785067a28a2dcdf7c5cea9ef8c10817889aa7
  44. BIN
      test/core/end2end/fuzzers/api_fuzzer_corpus/21af47d84b1aa84e8b4021765203c8951239fe41
  45. BIN
      test/core/end2end/fuzzers/api_fuzzer_corpus/22d23ae7b0a9c4ac6ffefe6b6b47bb5f54226ae1
  46. BIN
      test/core/end2end/fuzzers/api_fuzzer_corpus/2339fcca7f93814c587aba47fff2210875a41f49
  47. BIN
      test/core/end2end/fuzzers/api_fuzzer_corpus/239b03041efe9bf24982b0ecbb66d5abea4a28d0
  48. BIN
      test/core/end2end/fuzzers/api_fuzzer_corpus/24d630240f673498d784cecb66d73e9b1d981493
  49. BIN
      test/core/end2end/fuzzers/api_fuzzer_corpus/2533c4ed207eed715756142667128f6eb01309e0
  50. BIN
      test/core/end2end/fuzzers/api_fuzzer_corpus/255ab618b474a659914f5167f6e89ae3f1376788
  51. BIN
      test/core/end2end/fuzzers/api_fuzzer_corpus/2577397157d02cde4544e70fd6c3ff68704dd13b
  52. BIN
      test/core/end2end/fuzzers/api_fuzzer_corpus/25c8a5f8fbaf47c8a398a284008d90d088c652b2
  53. BIN
      test/core/end2end/fuzzers/api_fuzzer_corpus/26b6654b4efb469d4c8202dfc2ddafe4fc15e2d1
  54. BIN
      test/core/end2end/fuzzers/api_fuzzer_corpus/2806c68471ca16df5356ef6a3379ea46c73c57cc
  55. BIN
      test/core/end2end/fuzzers/api_fuzzer_corpus/2835dc7045dff8fd93a6e50bfd8775a50fce7599
  56. BIN
      test/core/end2end/fuzzers/api_fuzzer_corpus/28f73943647c3bfbd96e8d1a6188c428b15fdf12
  57. BIN
      test/core/end2end/fuzzers/api_fuzzer_corpus/29f39c36ffc68643789cd59ab9311a899fd9cfa6
  58. BIN
      test/core/end2end/fuzzers/api_fuzzer_corpus/2afc0ae3e27ba7ab7ea26d656a01da4d85e0bbea
  59. BIN
      test/core/end2end/fuzzers/api_fuzzer_corpus/2b6a001c2274e347cbfc6fe2e3bf4f7d7e79f5fe
  60. BIN
      test/core/end2end/fuzzers/api_fuzzer_corpus/2bc40826844d2232d9d36699432a30b4b1e5dd3a
  61. BIN
      test/core/end2end/fuzzers/api_fuzzer_corpus/2bcd71048dec1df45e36fde6deeb8f04bbd01cd4
  62. BIN
      test/core/end2end/fuzzers/api_fuzzer_corpus/2bfa23d5d476e4266cba3979f81a9ebdc26993e1
  63. BIN
      test/core/end2end/fuzzers/api_fuzzer_corpus/2c5b259108eb1a9735d7a89609d96bc043914cdb
  64. BIN
      test/core/end2end/fuzzers/api_fuzzer_corpus/2d742d21ecbf421506ecf19b23d6075feca4350b
  65. BIN
      test/core/end2end/fuzzers/api_fuzzer_corpus/2dd76fc710e3e78eaf4e5069fa227de678d0830d
  66. BIN
      test/core/end2end/fuzzers/api_fuzzer_corpus/2f8262de35a8314655d55f10ca46db441577ba36
  67. BIN
      test/core/end2end/fuzzers/api_fuzzer_corpus/2f9dd3b98b22bf2d4af5c2922977c8bb5699c367
  68. BIN
      test/core/end2end/fuzzers/api_fuzzer_corpus/2ff0986c252d462149597fd83bd5753926d343a0
  69. BIN
      test/core/end2end/fuzzers/api_fuzzer_corpus/3037118f9983abef4c9757742269f00cc90c0609
  70. BIN
      test/core/end2end/fuzzers/api_fuzzer_corpus/312b8910d1965fbfb09f0cb73e7e9d28316677bb
  71. BIN
      test/core/end2end/fuzzers/api_fuzzer_corpus/321e6127d6f5619c88e31037f7fdec581acf75e8
  72. BIN
      test/core/end2end/fuzzers/api_fuzzer_corpus/33306900f08f0b618c2bf4ba6f6144be9d19cb97
  73. BIN
      test/core/end2end/fuzzers/api_fuzzer_corpus/34052cc2fa2be6543184db85d0b9ad33ae17029c
  74. BIN
      test/core/end2end/fuzzers/api_fuzzer_corpus/351c6aabe840d69a16ca0f630c6c5a11d42cb85c
  75. BIN
      test/core/end2end/fuzzers/api_fuzzer_corpus/35623259c0d5d73d23ea52efc3e4bd808c119440
  76. BIN
      test/core/end2end/fuzzers/api_fuzzer_corpus/35b84f9f429e72230f0e9f6400ae5052c961fb27
  77. BIN
      test/core/end2end/fuzzers/api_fuzzer_corpus/3606c0748089f53e252b577ff7ab2df203d098ff
  78. BIN
      test/core/end2end/fuzzers/api_fuzzer_corpus/364f0605fd2d145db6ee6c7b01affb8833379db4
  79. BIN
      test/core/end2end/fuzzers/api_fuzzer_corpus/371d4ed270fb3cc3858a33fc0a857da2a21e6478
  80. BIN
      test/core/end2end/fuzzers/api_fuzzer_corpus/37b8a63d83441e64e279457d0e8318581ad3a7e6
  81. BIN
      test/core/end2end/fuzzers/api_fuzzer_corpus/37c26aa03db5daa01d7233f3c9fc474f81a724d1
  82. BIN
      test/core/end2end/fuzzers/api_fuzzer_corpus/39330aec49922885cf84803d7a5ee61d5948ee66
  83. BIN
      test/core/end2end/fuzzers/api_fuzzer_corpus/3a07fd9ba009b9a57e298343e815abab13a16f5c
  84. BIN
      test/core/end2end/fuzzers/api_fuzzer_corpus/3a74f1be7106c7dea533a34bd8a88974f69a5d71
  85. BIN
      test/core/end2end/fuzzers/api_fuzzer_corpus/3abac3ec4db280fe9b8893b5f42986508dd87201
  86. BIN
      test/core/end2end/fuzzers/api_fuzzer_corpus/3adaa0aea970123baa8ddb2560842c43bd19eb3f
  87. BIN
      test/core/end2end/fuzzers/api_fuzzer_corpus/3adc410756f3e9cb929570bd5e5107663e8eed80
  88. BIN
      test/core/end2end/fuzzers/api_fuzzer_corpus/3c2b6ebd2cd3fa2ea216ed01c4a7275ecbaa40c0
  89. BIN
      test/core/end2end/fuzzers/api_fuzzer_corpus/3c94ad60589b22d99dd03f98b37c609c180a755d
  90. BIN
      test/core/end2end/fuzzers/api_fuzzer_corpus/3d48a5c5a6188238bffee78f07b7cf6bb854258d
  91. BIN
      test/core/end2end/fuzzers/api_fuzzer_corpus/3d770d35de84de36ce4ed5b22f782edc99ecc634
  92. BIN
      test/core/end2end/fuzzers/api_fuzzer_corpus/3e0407abf398a7c40a34df7ed33ff23de02a2a6b
  93. BIN
      test/core/end2end/fuzzers/api_fuzzer_corpus/3e539f323c6ddea1bd3e34599a3c47b4457acdcf
  94. BIN
      test/core/end2end/fuzzers/api_fuzzer_corpus/3ed3fbcdae0ab5b185d6e7f1f46c2440f656e8d6
  95. BIN
      test/core/end2end/fuzzers/api_fuzzer_corpus/3ef10f7eba289d88e82f3678434ecc1218a47ee3
  96. BIN
      test/core/end2end/fuzzers/api_fuzzer_corpus/3f4ab27065d2a4fed7d011af384e03150b72eda5
  97. BIN
      test/core/end2end/fuzzers/api_fuzzer_corpus/3f4ee68f1f22eabcd01c2a7c1c6c8ccc299aa97d
  98. BIN
      test/core/end2end/fuzzers/api_fuzzer_corpus/3fbf231b2182dc58d2cdf1c62f01a8b709752505
  99. BIN
      test/core/end2end/fuzzers/api_fuzzer_corpus/40b500d38927c62c6966039b8557f810b3c19dc1
  100. BIN
      test/core/end2end/fuzzers/api_fuzzer_corpus/427392659bf3a945097c6c754a17d8c15e23816f
  101. Some files were not shown because too many files have changed in this diff Show More

@ -2088,7 +2088,7 @@ targets:
- gpr_test_util - gpr_test_util
- gpr - gpr
corpus_dirs: corpus_dirs:
- test/core/http/corpus - test/core/http/request_corpus
maxlen: 2048 maxlen: 2048
- name: http_response_fuzzer_test - name: http_response_fuzzer_test
build: fuzzer build: fuzzer
@ -2101,7 +2101,7 @@ targets:
- gpr_test_util - gpr_test_util
- gpr - gpr
corpus_dirs: corpus_dirs:
- test/core/http/corpus - test/core/http/response_corpus
maxlen: 2048 maxlen: 2048
- name: httpcli_format_request_test - name: httpcli_format_request_test
build: test build: test

@ -162,7 +162,6 @@ static grpc_mdelem *server_filter(void *user_data, grpc_mdelem *md) {
/* Retrieve the payload from the value of the 'grpc-internal-payload-bin' /* Retrieve the payload from the value of the 'grpc-internal-payload-bin'
header field */ header field */
calld->seen_payload_bin = 1; calld->seen_payload_bin = 1;
grpc_slice_buffer_init(&calld->read_slice_buffer);
grpc_slice_buffer_add(&calld->read_slice_buffer, grpc_slice_buffer_add(&calld->read_slice_buffer,
grpc_slice_ref(md->value->slice)); grpc_slice_ref(md->value->slice));
grpc_slice_buffer_stream_init(&calld->read_stream, grpc_slice_buffer_stream_init(&calld->read_stream,
@ -314,13 +313,17 @@ static grpc_error *init_call_elem(grpc_exec_ctx *exec_ctx,
grpc_closure_init(&calld->hs_on_recv, hs_on_recv, elem); grpc_closure_init(&calld->hs_on_recv, hs_on_recv, elem);
grpc_closure_init(&calld->hs_on_complete, hs_on_complete, elem); grpc_closure_init(&calld->hs_on_complete, hs_on_complete, elem);
grpc_closure_init(&calld->hs_recv_message_ready, hs_recv_message_ready, elem); grpc_closure_init(&calld->hs_recv_message_ready, hs_recv_message_ready, elem);
grpc_slice_buffer_init(&calld->read_slice_buffer);
return GRPC_ERROR_NONE; return GRPC_ERROR_NONE;
} }
/* Destructor for call_data */ /* Destructor for call_data */
static void destroy_call_elem(grpc_exec_ctx *exec_ctx, grpc_call_element *elem, static void destroy_call_elem(grpc_exec_ctx *exec_ctx, grpc_call_element *elem,
const grpc_call_final_info *final_info, const grpc_call_final_info *final_info,
void *ignored) {} void *ignored) {
call_data *calld = elem->call_data;
grpc_slice_buffer_destroy(&calld->read_slice_buffer);
}
/* Constructor for channel_data */ /* Constructor for channel_data */
static void init_channel_elem(grpc_exec_ctx *exec_ctx, static void init_channel_elem(grpc_exec_ctx *exec_ctx,

@ -687,6 +687,11 @@ size_t grpc_mdstr_length(const grpc_mdstr *s) { return GRPC_MDSTR_LENGTH(s); }
grpc_mdstr *grpc_mdstr_ref(grpc_mdstr *gs DEBUG_ARGS) { grpc_mdstr *grpc_mdstr_ref(grpc_mdstr *gs DEBUG_ARGS) {
internal_string *s = (internal_string *)gs; internal_string *s = (internal_string *)gs;
if (is_mdstr_static(gs)) return gs; if (is_mdstr_static(gs)) return gs;
#ifdef GRPC_METADATA_REFCOUNT_DEBUG
gpr_log(file, line, GPR_LOG_SEVERITY_DEBUG, "STR REF:%p:%zu->%zu: '%s'",
(void *)s, gpr_atm_no_barrier_load(&s->refcnt),
gpr_atm_no_barrier_load(&s->refcnt) + 1, grpc_mdstr_as_c_string(gs));
#endif
GPR_ASSERT(gpr_atm_full_fetch_add(&s->refcnt, 1) > 0); GPR_ASSERT(gpr_atm_full_fetch_add(&s->refcnt, 1) > 0);
return gs; return gs;
} }
@ -694,6 +699,11 @@ grpc_mdstr *grpc_mdstr_ref(grpc_mdstr *gs DEBUG_ARGS) {
void grpc_mdstr_unref(grpc_mdstr *gs DEBUG_ARGS) { void grpc_mdstr_unref(grpc_mdstr *gs DEBUG_ARGS) {
internal_string *s = (internal_string *)gs; internal_string *s = (internal_string *)gs;
if (is_mdstr_static(gs)) return; if (is_mdstr_static(gs)) return;
#ifdef GRPC_METADATA_REFCOUNT_DEBUG
gpr_log(file, line, GPR_LOG_SEVERITY_DEBUG, "STR UNREF:%p:%zu->%zu: '%s'",
(void *)s, gpr_atm_no_barrier_load(&s->refcnt),
gpr_atm_no_barrier_load(&s->refcnt) - 1, grpc_mdstr_as_c_string(gs));
#endif
if (1 == gpr_atm_full_fetch_add(&s->refcnt, -1)) { if (1 == gpr_atm_full_fetch_add(&s->refcnt, -1)) {
strtab_shard *shard = strtab_shard *shard =
&g_strtab_shard[SHARD_IDX(s->hash, LOG2_STRTAB_SHARD_COUNT)]; &g_strtab_shard[SHARD_IDX(s->hash, LOG2_STRTAB_SHARD_COUNT)];

@ -34,6 +34,7 @@
#include <string.h> #include <string.h>
#include <grpc/grpc.h> #include <grpc/grpc.h>
#include <grpc/grpc_security.h>
#include <grpc/support/alloc.h> #include <grpc/support/alloc.h>
#include <grpc/support/log.h> #include <grpc/support/log.h>
#include <grpc/support/string_util.h> #include <grpc/support/string_util.h>
@ -45,6 +46,7 @@
#include "src/core/lib/iomgr/timer.h" #include "src/core/lib/iomgr/timer.h"
#include "src/core/lib/surface/server.h" #include "src/core/lib/surface/server.h"
#include "src/core/lib/transport/metadata.h" #include "src/core/lib/transport/metadata.h"
#include "test/core/end2end/data/ssl_test_data.h"
#include "test/core/util/passthru_endpoint.h" #include "test/core/util/passthru_endpoint.h"
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
@ -55,6 +57,21 @@ bool leak_check = true;
static void dont_log(gpr_log_func_args *args) {} static void dont_log(gpr_log_func_args *args) {}
////////////////////////////////////////////////////////////////////////////////
// global state
static gpr_timespec g_now;
static grpc_server *g_server;
static grpc_channel *g_channel;
static grpc_resource_quota *g_resource_quota;
extern gpr_timespec (*gpr_now_impl)(gpr_clock_type clock_type);
static gpr_timespec now_impl(gpr_clock_type clock_type) {
GPR_ASSERT(clock_type != GPR_TIMESPAN);
return g_now;
}
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
// input_stream: allows easy access to input bytes, and allows reading a little // input_stream: allows easy access to input bytes, and allows reading a little
// past the end (avoiding needing to check everywhere) // past the end (avoiding needing to check everywhere)
@ -150,13 +167,28 @@ static grpc_channel_args *read_args(input_stream *inp) {
size_t n = next_byte(inp); size_t n = next_byte(inp);
grpc_arg *args = gpr_malloc(sizeof(*args) * n); grpc_arg *args = gpr_malloc(sizeof(*args) * n);
for (size_t i = 0; i < n; i++) { for (size_t i = 0; i < n; i++) {
bool is_string = next_byte(inp) & 1; switch (next_byte(inp)) {
args[i].type = is_string ? GRPC_ARG_STRING : GRPC_ARG_INTEGER; case 1:
args[i].type = GRPC_ARG_STRING;
args[i].key = read_string(inp); args[i].key = read_string(inp);
if (is_string) {
args[i].value.string = read_string(inp); args[i].value.string = read_string(inp);
} else { break;
case 2:
args[i].type = GRPC_ARG_INTEGER;
args[i].key = read_string(inp);
args[i].value.integer = read_int(inp); args[i].value.integer = read_int(inp);
break;
case 3:
args[i].type = GRPC_ARG_POINTER;
args[i].key = gpr_strdup(GRPC_ARG_RESOURCE_QUOTA);
args[i].value.pointer.vtable = grpc_resource_quota_arg_vtable();
args[i].value.pointer.p = g_resource_quota;
grpc_resource_quota_ref(g_resource_quota);
break;
default:
end(inp);
n = i;
break;
} }
} }
grpc_channel_args *a = gpr_malloc(sizeof(*a)); grpc_channel_args *a = gpr_malloc(sizeof(*a));
@ -165,23 +197,138 @@ static grpc_channel_args *read_args(input_stream *inp) {
return a; return a;
} }
static bool is_eof(input_stream *inp) { return inp->cur == inp->end; } typedef struct cred_artifact_ctx {
int num_release;
char *release[3];
} cred_artifact_ctx;
#define CRED_ARTIFACT_CTX_INIT \
{ \
0, { 0 } \
}
//////////////////////////////////////////////////////////////////////////////// static void cred_artifact_ctx_finish(cred_artifact_ctx *ctx) {
// global state for (int i = 0; i < ctx->num_release; i++) {
gpr_free(ctx->release[i]);
}
}
static gpr_timespec g_now; static const char *read_cred_artifact(cred_artifact_ctx *ctx, input_stream *inp,
static grpc_server *g_server; const char **builtins,
static grpc_channel *g_channel; size_t num_builtins) {
static grpc_resource_quota *g_resource_quota; uint8_t b = next_byte(inp);
if (b == 0) return NULL;
if (b == 1) return ctx->release[ctx->num_release++] = read_string(inp);
if (b >= num_builtins + 1) {
end(inp);
return NULL;
}
return builtins[b - 1];
}
extern gpr_timespec (*gpr_now_impl)(gpr_clock_type clock_type); static grpc_channel_credentials *read_ssl_channel_creds(input_stream *inp) {
cred_artifact_ctx ctx = CRED_ARTIFACT_CTX_INIT;
static const char *builtin_root_certs[] = {test_root_cert};
static const char *builtin_private_keys[] = {
test_server1_key, test_self_signed_client_key, test_signed_client_key};
static const char *builtin_cert_chains[] = {
test_server1_cert, test_self_signed_client_cert, test_signed_client_cert};
const char *root_certs = read_cred_artifact(
&ctx, inp, builtin_root_certs, GPR_ARRAY_SIZE(builtin_root_certs));
const char *private_key = read_cred_artifact(
&ctx, inp, builtin_private_keys, GPR_ARRAY_SIZE(builtin_private_keys));
const char *certs = read_cred_artifact(&ctx, inp, builtin_cert_chains,
GPR_ARRAY_SIZE(builtin_cert_chains));
grpc_ssl_pem_key_cert_pair key_cert_pair = {private_key, certs};
grpc_channel_credentials *creds = grpc_ssl_credentials_create(
root_certs, private_key != NULL && certs != NULL ? &key_cert_pair : NULL,
NULL);
cred_artifact_ctx_finish(&ctx);
return creds;
}
static gpr_timespec now_impl(gpr_clock_type clock_type) { static grpc_call_credentials *read_call_creds(input_stream *inp) {
GPR_ASSERT(clock_type != GPR_TIMESPAN); switch (next_byte(inp)) {
return g_now; default:
end(inp);
return NULL;
case 0:
return NULL;
case 1: {
grpc_call_credentials *c1 = read_call_creds(inp);
grpc_call_credentials *c2 = read_call_creds(inp);
if (c1 != NULL && c2 != NULL) {
grpc_call_credentials *out =
grpc_composite_call_credentials_create(c1, c2, NULL);
grpc_call_credentials_release(c1);
grpc_call_credentials_release(c2);
return out;
} else if (c1 != NULL) {
return c1;
} else if (c2 != NULL) {
return c2;
} else {
return NULL;
}
GPR_UNREACHABLE_CODE(return NULL);
}
case 2: {
cred_artifact_ctx ctx = CRED_ARTIFACT_CTX_INIT;
const char *access_token = read_cred_artifact(&ctx, inp, NULL, 0);
grpc_call_credentials *out =
access_token == NULL ? NULL : grpc_access_token_credentials_create(
access_token, NULL);
cred_artifact_ctx_finish(&ctx);
return out;
}
case 3: {
cred_artifact_ctx ctx = CRED_ARTIFACT_CTX_INIT;
const char *auth_token = read_cred_artifact(&ctx, inp, NULL, 0);
const char *auth_selector = read_cred_artifact(&ctx, inp, NULL, 0);
grpc_call_credentials *out = auth_token == NULL || auth_selector == NULL
? NULL
: grpc_google_iam_credentials_create(
auth_token, auth_selector, NULL);
cred_artifact_ctx_finish(&ctx);
return out;
}
/* TODO(ctiller): more cred types here */
}
} }
static grpc_channel_credentials *read_channel_creds(input_stream *inp) {
switch (next_byte(inp)) {
case 0:
return read_ssl_channel_creds(inp);
break;
case 1: {
grpc_channel_credentials *c1 = read_channel_creds(inp);
grpc_call_credentials *c2 = read_call_creds(inp);
if (c1 != NULL && c2 != NULL) {
grpc_channel_credentials *out =
grpc_composite_channel_credentials_create(c1, c2, NULL);
grpc_channel_credentials_release(c1);
grpc_call_credentials_release(c2);
return out;
} else if (c1) {
return c1;
} else if (c2) {
grpc_call_credentials_release(c2);
return NULL;
} else {
return NULL;
}
GPR_UNREACHABLE_CODE(return NULL);
}
case 2:
return NULL;
default:
end(inp);
return NULL;
}
}
static bool is_eof(input_stream *inp) { return inp->cur == inp->end; }
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
// dns resolution // dns resolution
@ -947,6 +1094,25 @@ int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size) {
grpc_resource_quota_resize(g_resource_quota, read_uint22(&inp)); grpc_resource_quota_resize(g_resource_quota, read_uint22(&inp));
break; break;
} }
// create a secure channel
case 22: {
if (g_channel == NULL) {
char *target = read_string(&inp);
char *target_uri;
gpr_asprintf(&target_uri, "dns:%s", target);
grpc_channel_args *args = read_args(&inp);
grpc_channel_credentials *creds = read_channel_creds(&inp);
g_channel = grpc_secure_channel_create(creds, target_uri, args, NULL);
GPR_ASSERT(g_channel != NULL);
grpc_channel_args_destroy(args);
gpr_free(target_uri);
gpr_free(target);
grpc_channel_credentials_release(creds);
} else {
end(&inp);
}
break;
}
} }
} }

Some files were not shown because too many files have changed in this diff Show More

Loading…
Cancel
Save