From 698ebf8a61332479014451b0d56a0ee9e7f9f5fe Mon Sep 17 00:00:00 2001 From: xy420513 Date: Fri, 21 Apr 2023 00:47:43 +0800 Subject: [PATCH 1/4] =?UTF-8?q?Fix:=20=E5=AD=97=E7=AC=A6=E6=95=B0=E7=BB=84?= =?UTF-8?q?expect=5Fstr=E8=B6=8A=E7=95=8C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 第389行创建的字符数组str大小只有10,后续412行sprintf的字符串明显超出了10的大小,会发生数组越界,出现问题 --- devices/air724/air724.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/devices/air724/air724.c b/devices/air724/air724.c index 1bb575de..5f334dfa 100644 --- a/devices/air724/air724.c +++ b/devices/air724/air724.c @@ -386,7 +386,7 @@ static int air724_recv(int id, void *buf, size_t len) int air724_send(int id, const void *buf, size_t len) { at_echo_t echo; - char expect_str[10]; + char expect_str[30]; if (tos_at_global_lock_pend() != 0) { return -1; From e73aff466abd9303f36152642c1503b364849813 Mon Sep 17 00:00:00 2001 From: xy420513 Date: Fri, 21 Apr 2023 11:01:11 +0800 Subject: [PATCH 2/4] =?UTF-8?q?Fix:=E5=AD=97=E7=AC=A6=E6=95=B0=E7=BB=84?= =?UTF-8?q?=E8=B6=8A=E7=95=8C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- devices/air724/air724.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/devices/air724/air724.c b/devices/air724/air724.c index 5f334dfa..a4400ed2 100644 --- a/devices/air724/air724.c +++ b/devices/air724/air724.c @@ -386,7 +386,7 @@ static int air724_recv(int id, void *buf, size_t len) int air724_send(int id, const void *buf, size_t len) { at_echo_t echo; - char expect_str[30]; + char expect_str[24]; if (tos_at_global_lock_pend() != 0) { return -1; From 1961644fa4ae40e857ed4356c7da434e4d1ba0ab Mon Sep 17 00:00:00 2001 From: Eric_He Date: Sun, 23 Apr 2023 10:55:42 +0800 Subject: [PATCH 3/4] Modify the null pointer fifo to access first and then judge --- components/connectivity/mqttclient/common/log/fifo.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/components/connectivity/mqttclient/common/log/fifo.c b/components/connectivity/mqttclient/common/log/fifo.c index 059bf24f..e3f31761 100644 --- a/components/connectivity/mqttclient/common/log/fifo.c +++ b/components/connectivity/mqttclient/common/log/fifo.c @@ -98,10 +98,10 @@ unsigned int salof_fifo_read(salof_fifo_t fifo, void *buff, unsigned int len, un { int l; - salof_sem_pend(fifo->sem, timeout); - if((!fifo) || (!buff) || (!len)) return 0; + + salof_sem_pend(fifo->sem, timeout); len = FIFO_MIN(len, fifo->in - fifo->out); From 146d03916e4959f7d4d89c416aaa7bc7f05bac59 Mon Sep 17 00:00:00 2001 From: 7YZ7 <82019212+7YZ7@users.noreply.github.com> Date: Sun, 23 Apr 2023 13:41:24 +0800 Subject: [PATCH 4/4] Update mqtt_iot_explorer_esp8266.c --- .../App/mqtt_iot_explorer_esp8266.c | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/board/TencentOS_Tiny_EVB_STM32WL/KEIL/lorawan_pm25/App/mqtt_iot_explorer_esp8266.c b/board/TencentOS_Tiny_EVB_STM32WL/KEIL/lorawan_pm25/App/mqtt_iot_explorer_esp8266.c index dcdec3da..664ac13f 100644 --- a/board/TencentOS_Tiny_EVB_STM32WL/KEIL/lorawan_pm25/App/mqtt_iot_explorer_esp8266.c +++ b/board/TencentOS_Tiny_EVB_STM32WL/KEIL/lorawan_pm25/App/mqtt_iot_explorer_esp8266.c @@ -65,7 +65,7 @@ void mqtt_demo_task(void) device_info_t dev_info; memset(&dev_info, 0, sizeof(device_info_t)); - char str[16]; + char str[32]; size_t mail_size; uint8_t report_error_count = 0; char client_token[10]; @@ -103,7 +103,7 @@ void mqtt_demo_task(void) tos_sleep_ms(5000); } - /* ʼtopic */ + /* 开始订阅topic */ size = snprintf(report_reply_topic_name, TOPIC_NAME_MAX_SIZE, "$thing/down/property/%s/%s", product_id, device_name); if (size < 0 || size > sizeof(report_reply_topic_name) - 1) { @@ -122,7 +122,7 @@ void mqtt_demo_task(void) printf("pub topic content length not enough! content size:%d buf size:%d", size, (int)sizeof(report_topic_name)); } - /* */ + /* 创建邮箱 */ tos_mail_q_create(&mail_q, pm2d5_value_pool, 3, sizeof(pm2d5_data_u)); HAL_NVIC_DisableIRQ(USART2_IRQn); @@ -133,22 +133,22 @@ void mqtt_demo_task(void) } while (1) { - /* ͨʼȡ */ + /* 通过接收邮件来读取数据 */ HAL_NVIC_EnableIRQ(USART2_IRQn); tos_mail_q_pend(&mail_q, (uint8_t*)&pm2d5_value, &mail_size, TOS_TIME_FOREVER); HAL_NVIC_DisableIRQ(USART2_IRQn); - //յ֮ӡϢ + //收到之后打印信息 printf("\r\n\r\n\r\n"); for (i = 0; i < 13; i++) { printf("data[%d]:%d ug/m3\r\n", i+1, pm2d5_value.data[i]); } - /* ʾPM2.5ֵ */ + /* 显示PM2.5的值 */ sprintf(str, "PM2.5:%4d ug/m3", pm2d5_value.pm2d5_data.data2); - OLED_ShowString(0,0,(uint8_t*)str,16); + OLED_ShowString(0,0,(uint8_t*)str,32); - /* ϱֵ */ + /* 上报值 */ generate_client_token(client_token, sizeof(client_token)); memset(payload, 0, 1024); snprintf(payload, 1024, REPORT_DATA_TEMPLATE, client_token, @@ -183,7 +183,7 @@ void application_entry(void *arg) { char *str = "TencentOS-Tiny"; - /* ʼOLED */ + /* 初始化OLED */ mqtt_demo_task(); while (1) {