Fix issue with buffer overflow for too large screen updated too fast
This commit is contained in:
@@ -65,7 +65,7 @@ LIBS += esphttpd
|
|||||||
# compiler flags using during compilation of source files
|
# compiler flags using during compilation of source files
|
||||||
CFLAGS = -Os -ggdb -std=gnu99 -Werror -Wpointer-arith -Wundef -Wall -Wl,-EL -fno-inline-functions \
|
CFLAGS = -Os -ggdb -std=gnu99 -Werror -Wpointer-arith -Wundef -Wall -Wl,-EL -fno-inline-functions \
|
||||||
-nostdlib -mlongcalls -mtext-section-literals -D__ets__ -DICACHE_FLASH \
|
-nostdlib -mlongcalls -mtext-section-literals -D__ets__ -DICACHE_FLASH \
|
||||||
-Wno-address -Wno-unused
|
-Wno-address -Wno-unused -DHTTPD_MAX_BACKLOG_SIZE=8192
|
||||||
|
|
||||||
# linker flags used to generate the main object file
|
# linker flags used to generate the main object file
|
||||||
LDFLAGS = -nostdlib -Wl,--no-check-sections -u call_user_start -Wl,-static
|
LDFLAGS = -nostdlib -Wl,--no-check-sections -u call_user_start -Wl,-static
|
||||||
|
|||||||
+1
-1
Submodule libesphttpd updated: fba7cec0b6...a4e0fed2b2
+7
-12
@@ -6,28 +6,26 @@
|
|||||||
#include "uart_driver.h"
|
#include "uart_driver.h"
|
||||||
#include "screen.h"
|
#include "screen.h"
|
||||||
|
|
||||||
static volatile bool timer_running = false;
|
#define SOCK_BUF_LEN 2048
|
||||||
static ETSTimer notifyTim;
|
static char sock_buff[SOCK_BUF_LEN];
|
||||||
|
|
||||||
static void notifyTimCb(void *arg) {
|
static void notifyTimCb(void *arg) {
|
||||||
timer_running = false;
|
|
||||||
|
|
||||||
void *data = NULL;
|
void *data = NULL;
|
||||||
|
|
||||||
const int bufsiz = 1024;
|
|
||||||
char buff[bufsiz];
|
|
||||||
for (int i = 0; i < 20; i++) {
|
for (int i = 0; i < 20; i++) {
|
||||||
httpd_cgi_state cont = screenSerializeToBuffer(buff, bufsiz, &data);
|
httpd_cgi_state cont = screenSerializeToBuffer(sock_buff, SOCK_BUF_LEN, &data);
|
||||||
int flg = 0;
|
int flg = 0;
|
||||||
if (cont == HTTPD_CGI_MORE) flg |= WEBSOCK_FLAG_MORE;
|
if (cont == HTTPD_CGI_MORE) flg |= WEBSOCK_FLAG_MORE;
|
||||||
if (i > 0) flg |= WEBSOCK_FLAG_CONT;
|
if (i > 0) flg |= WEBSOCK_FLAG_CONT;
|
||||||
cgiWebsockBroadcast(URL_WS_UPDATE, buff, (int) strlen(buff), flg);
|
cgiWebsockBroadcast(URL_WS_UPDATE, sock_buff, (int) strlen(sock_buff), flg);
|
||||||
if (cont == HTTPD_CGI_DONE) break;
|
if (cont == HTTPD_CGI_DONE) break;
|
||||||
}
|
}
|
||||||
|
|
||||||
screenSerializeToBuffer(NULL, bufsiz, &data);
|
screenSerializeToBuffer(NULL, SOCK_BUF_LEN, &data);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static ETSTimer notifyTim;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Broadcast screen state to sockets.
|
* Broadcast screen state to sockets.
|
||||||
* This is a callback for the Screen module,
|
* This is a callback for the Screen module,
|
||||||
@@ -35,9 +33,6 @@ static void notifyTimCb(void *arg) {
|
|||||||
*/
|
*/
|
||||||
void ICACHE_FLASH_ATTR screen_notifyChange(void)
|
void ICACHE_FLASH_ATTR screen_notifyChange(void)
|
||||||
{
|
{
|
||||||
if (timer_running) return;
|
|
||||||
|
|
||||||
timer_running = true;
|
|
||||||
os_timer_disarm(¬ifyTim);
|
os_timer_disarm(¬ifyTim);
|
||||||
os_timer_setfn(¬ifyTim, notifyTimCb, NULL);
|
os_timer_setfn(¬ifyTim, notifyTimCb, NULL);
|
||||||
os_timer_arm(¬ifyTim, 20, 0);
|
os_timer_arm(¬ifyTim, 20, 0);
|
||||||
|
|||||||
Reference in New Issue
Block a user