[promises] Fix obscure validation bug (#33947)

pull/33957/head
Craig Tiller 1 year ago committed by GitHub
parent 860167a7d0
commit 0747da86c7
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 12
      src/core/lib/surface/call.cc

@ -1930,6 +1930,9 @@ void FilterStackCall::ContextSet(grpc_context_index elem, void* value,
namespace {
bool ValidateMetadata(size_t count, grpc_metadata* metadata) {
if (count > INT_MAX) {
return false;
}
for (size_t i = 0; i < count; i++) {
grpc_metadata* md = &metadata[i];
if (!GRPC_LOG_IF_ERROR("validate_metadata",
@ -3289,9 +3292,16 @@ grpc_call_error ServerPromiseBasedCall::ValidateBatch(const grpc_op* ops,
return GRPC_CALL_ERROR_INVALID_FLAGS;
}
break;
case GRPC_OP_SEND_STATUS_FROM_SERVER:
if (op.flags != 0) return GRPC_CALL_ERROR_INVALID_FLAGS;
if (!ValidateMetadata(
op.data.send_status_from_server.trailing_metadata_count,
op.data.send_status_from_server.trailing_metadata)) {
return GRPC_CALL_ERROR_INVALID_METADATA;
}
break;
case GRPC_OP_RECV_MESSAGE:
case GRPC_OP_RECV_CLOSE_ON_SERVER:
case GRPC_OP_SEND_STATUS_FROM_SERVER:
if (op.flags != 0) return GRPC_CALL_ERROR_INVALID_FLAGS;
break;
case GRPC_OP_RECV_INITIAL_METADATA:

Loading…
Cancel
Save