Skip to content

Commit 5e96735

Browse files
authored
Fixed issue in EvseV2G and OCPP modules. The exiResponse is a required value in the OCPP type but its optional in the EVerest type. This could lead to the situation that the EvseV2G module receives an empty exiResponse that could lead to a segmentation fault. This commit only sets the exiResponse in OCPP when not empty and adds an additional check to EvseV2G to check if the exiResponse string is not empty (#961)
Signed-off-by: Piet Gömpel <pietgoempel@gmail.com>
1 parent 71c0ef5 commit 5e96735

File tree

3 files changed

+13
-6
lines changed

3 files changed

+13
-6
lines changed

modules/EvseV2G/charger/ISO15118_chargerImpl.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -213,7 +213,7 @@ void ISO15118_chargerImpl::handle_session_setup(std::vector<types::iso15118_char
213213
void ISO15118_chargerImpl::handle_certificate_response(
214214
types::iso15118_charger::ResponseExiStreamStatus& exi_stream_status) {
215215
pthread_mutex_lock(&v2g_ctx->mqtt_lock);
216-
if (exi_stream_status.exi_response.has_value()) {
216+
if (exi_stream_status.exi_response.has_value() and not exi_stream_status.exi_response.value().empty()) {
217217
v2g_ctx->evse_v2g_data.cert_install_res_b64_buffer = std::string(exi_stream_status.exi_response.value());
218218
}
219219
v2g_ctx->evse_v2g_data.cert_install_status =

modules/OCPP/OCPP.cpp

+5-1
Original file line numberDiff line numberDiff line change
@@ -761,8 +761,12 @@ void OCPP::ready() {
761761
const ocpp::v201::CertificateActionEnum& certificate_action) {
762762
types::iso15118_charger::ResponseExiStreamStatus response;
763763
response.status = conversions::to_everest_iso15118_charger_status(certificate_response.status);
764-
response.exi_response.emplace(certificate_response.exiResponse.get());
765764
response.certificate_action = conversions::to_everest_certificate_action_enum(certificate_action);
765+
if (not certificate_response.exiResponse.get().empty()) {
766+
// since exi_response is an optional in the EVerest type we only set it when not empty
767+
response.exi_response.emplace(certificate_response.exiResponse.get());
768+
}
769+
766770
this->r_evse_manager.at(this->connector_evse_index_map.at(connector_id))
767771
->call_set_get_certificate_response(response);
768772
});

modules/OCPP201/OCPP201.cpp

+7-4
Original file line numberDiff line numberDiff line change
@@ -795,10 +795,13 @@ void OCPP201::ready() {
795795
conversions::to_ocpp_get_15118_certificate_request(certificate_request));
796796
EVLOG_debug << "Received response from get_15118_ev_certificate_request: " << ocpp_response;
797797
// transform response, inject action, send to associated EvseManager
798-
const auto everest_response_status =
799-
conversions::to_everest_iso15118_charger_status(ocpp_response.status);
800-
const types::iso15118_charger::ResponseExiStreamStatus everest_response{
801-
everest_response_status, certificate_request.certificate_action, ocpp_response.exiResponse};
798+
types::iso15118_charger::ResponseExiStreamStatus everest_response;
799+
everest_response.status = conversions::to_everest_iso15118_charger_status(ocpp_response.status);
800+
everest_response.certificate_action = certificate_request.certificate_action;
801+
if (not ocpp_response.exiResponse.get().empty()) {
802+
// since exi_response is an optional in the EVerest type we only set it when not empty
803+
everest_response.exi_response = ocpp_response.exiResponse.get();
804+
}
802805
this->r_evse_manager.at(evse_id - 1)->call_set_get_certificate_response(everest_response);
803806
});
804807

0 commit comments

Comments
 (0)