envoyproxy/envoy

grpc async client should catch proto cast exception

Open

#5.409 geöffnet am 24. Dez. 2018

Auf GitHub ansehen
 (2 Kommentare) (0 Reaktionen) (1 zugewiesene Person)C++ (5.373 Forks)batch import
enhancementhelp wanted

Repository-Metriken

Stars
 (27.997 Stars)
PR-Merge-Metriken
 (Durchschn. Merge 8T) (378 gemergte PRs in 30 T)

Beschreibung

Title: grpc async client should catch proto cast exception

Description:

grpc async client proto cast catches no exception as follows: include\envoy\grpc\async_client.h

  void onReceiveMessageUntyped(ProtobufTypes::MessagePtr&& message) override {
    onReceiveMessage(std::unique_ptr<ResponseType>(dynamic_cast<ResponseType*>(message.release())));
  }

which may crashs the process when the received message is not standard, like 00 00 00 00 00.

And should be modified as follows:

void onReceiveMessageUntyped(ProtobufTypes::MessagePtr&& message) override {
  try {
    onReceiveMessage(std::unique_ptr<ResponseType>(dynamic_cast<ResponseType*>(message.release())));
  } catch(const std::exception& e) {
    std::cout << "wrong message received, error: " << e.what() << std::endl;
  }
}

Contributor Guide