Skip to content

Commit 706a8f6

Browse files
committed
at_handler use dedicated buffer for ota
- avoid cert_buf overwriting using ota and custom ca
1 parent 9824da7 commit 706a8f6

File tree

2 files changed

+8
-5
lines changed

2 files changed

+8
-5
lines changed

UNOR4USBBridge/at_handler.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -90,6 +90,9 @@ class CAtHandler {
9090
std::vector<std::uint8_t> client_cert_pem;
9191
std::vector<std::uint8_t> client_key_pem;
9292

93+
/* Used by cmds_ota */
94+
std::vector<std::uint8_t> ota_cert_buf;
95+
9396
/* Used by cmds_preferences */
9497
std::vector<std::uint8_t> pref_buf;
9598

UNOR4USBBridge/cmds_ota.h

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -27,15 +27,15 @@ void CAtHandler::add_cmds_ota() {
2727
return chAT::CommandStatus::ERROR;
2828
}
2929

30-
cert_buf = srv.inhibit_read(ca_root_size);
31-
size_t offset = cert_buf.size();
30+
ota_cert_buf = srv.inhibit_read(ca_root_size);
31+
size_t offset = ota_cert_buf.size();
3232
if(offset < ca_root_size) {
33-
cert_buf.resize(ca_root_size);
33+
ota_cert_buf.resize(ca_root_size);
3434
do {
35-
offset += serial->read(cert_buf.data() + offset, ca_root_size - offset);
35+
offset += serial->read(ota_cert_buf.data() + offset, ca_root_size - offset);
3636
} while (offset < ca_root_size);
3737
}
38-
OTA.setCACert((const char *)cert_buf.data());
38+
OTA.setCACert((const char *)ota_cert_buf.data());
3939
srv.continue_read();
4040
return chAT::CommandStatus::OK;
4141
}

0 commit comments

Comments
 (0)