Skip to content

Commit

Permalink
Fixed issue in EvseV2G and OCPP modules. The exiResponse is a require…
Browse files Browse the repository at this point in the history
…d 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>
  • Loading branch information
Pietfried authored Nov 12, 2024
1 parent 71c0ef5 commit 5e96735
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 6 deletions.
2 changes: 1 addition & 1 deletion modules/EvseV2G/charger/ISO15118_chargerImpl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -213,7 +213,7 @@ void ISO15118_chargerImpl::handle_session_setup(std::vector<types::iso15118_char
void ISO15118_chargerImpl::handle_certificate_response(
types::iso15118_charger::ResponseExiStreamStatus& exi_stream_status) {
pthread_mutex_lock(&v2g_ctx->mqtt_lock);
if (exi_stream_status.exi_response.has_value()) {
if (exi_stream_status.exi_response.has_value() and not exi_stream_status.exi_response.value().empty()) {
v2g_ctx->evse_v2g_data.cert_install_res_b64_buffer = std::string(exi_stream_status.exi_response.value());
}
v2g_ctx->evse_v2g_data.cert_install_status =
Expand Down
6 changes: 5 additions & 1 deletion modules/OCPP/OCPP.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -761,8 +761,12 @@ void OCPP::ready() {
const ocpp::v201::CertificateActionEnum& certificate_action) {
types::iso15118_charger::ResponseExiStreamStatus response;
response.status = conversions::to_everest_iso15118_charger_status(certificate_response.status);
response.exi_response.emplace(certificate_response.exiResponse.get());
response.certificate_action = conversions::to_everest_certificate_action_enum(certificate_action);
if (not certificate_response.exiResponse.get().empty()) {
// since exi_response is an optional in the EVerest type we only set it when not empty
response.exi_response.emplace(certificate_response.exiResponse.get());
}

this->r_evse_manager.at(this->connector_evse_index_map.at(connector_id))
->call_set_get_certificate_response(response);
});
Expand Down
11 changes: 7 additions & 4 deletions modules/OCPP201/OCPP201.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -795,10 +795,13 @@ void OCPP201::ready() {
conversions::to_ocpp_get_15118_certificate_request(certificate_request));
EVLOG_debug << "Received response from get_15118_ev_certificate_request: " << ocpp_response;
// transform response, inject action, send to associated EvseManager
const auto everest_response_status =
conversions::to_everest_iso15118_charger_status(ocpp_response.status);
const types::iso15118_charger::ResponseExiStreamStatus everest_response{
everest_response_status, certificate_request.certificate_action, ocpp_response.exiResponse};
types::iso15118_charger::ResponseExiStreamStatus everest_response;
everest_response.status = conversions::to_everest_iso15118_charger_status(ocpp_response.status);
everest_response.certificate_action = certificate_request.certificate_action;
if (not ocpp_response.exiResponse.get().empty()) {
// since exi_response is an optional in the EVerest type we only set it when not empty
everest_response.exi_response = ocpp_response.exiResponse.get();
}
this->r_evse_manager.at(evse_id - 1)->call_set_get_certificate_response(everest_response);
});

Expand Down

0 comments on commit 5e96735

Please sign in to comment.