From 9da5f8409c85637361d7bc69b721f6d9d3087b7b Mon Sep 17 00:00:00 2001 From: Uros Majstorovic Date: Wed, 4 Sep 2024 21:07:29 +0200 Subject: esp32 cellular modem driver fix --- fw/esp32/components/eos/cell_pdp.c | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) (limited to 'fw/esp32/components/eos/cell_pdp.c') diff --git a/fw/esp32/components/eos/cell_pdp.c b/fw/esp32/components/eos/cell_pdp.c index fc4739a..d04b66b 100644 --- a/fw/esp32/components/eos/cell_pdp.c +++ b/fw/esp32/components/eos/cell_pdp.c @@ -13,16 +13,14 @@ void eos_cell_pdp_handler(unsigned char mtype, unsigned char *buffer, uint16_t b case EOS_CELL_MTYPE_PDP_SET_USR: case EOS_CELL_MTYPE_PDP_SET_PWD: { char *arg; - size_t arg_len; buffer++; buf_len--; arg = (char *)buffer; - arg_len = strnlen(arg, buf_len); - if (arg_len == buf_len) break; - if (arg_len >= EOS_CELL_PDP_SIZE_ARG) break; + if (buf_len > EOS_CELL_PDP_SIZE_ARG) break; + buffer[buf_len] = '\0'; switch (mtype) { case EOS_CELL_MTYPE_PDP_SET_APN: { eos_ppp_set_apn(arg); @@ -66,7 +64,7 @@ void eos_cell_pdp_handler(unsigned char mtype, unsigned char *buffer, uint16_t b } } - eos_net_reply(EOS_NET_MTYPE_CELL, buffer, 1 + strlen(arg)); + eos_net_reply(EOS_NET_MTYPE_CELL, buffer, strlen(arg) + 1); break; } -- cgit v1.2.3