aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorlonkaars <loek@pipeframe.xyz>2022-10-28 16:56:23 +0200
committerlonkaars <loek@pipeframe.xyz>2022-10-28 16:56:23 +0200
commitc429e17061d392ea4b3f73ebcc9101db8e491d8f (patch)
tree2b20528dc4e5e3600758576578bbc7e49dd21a43
parentee6d749c0fc2b4cd45e3cf8295aae892e0680c6c (diff)
another off-by-one error fixed
-rw-r--r--stm32f091/server.c4
1 files changed, 2 insertions, 2 deletions
diff --git a/stm32f091/server.c b/stm32f091/server.c
index 6225eae..46d18f0 100644
--- a/stm32f091/server.c
+++ b/stm32f091/server.c
@@ -46,7 +46,7 @@ void ws_server_req_finish(unsigned int channel, bool ignore) {
// TODO: next_few_bytes_are assumes that the complete search string is in the
// buffer, so won't work for buffer cutoffs
-#define next_few_bytes_are(code) (i + sizeof(code) - 1 < size && strncmp((char*)&data[i], code, sizeof(code) - 1) == 0)
+#define next_few_bytes_are(code) (((i + sizeof(code) - 2) < size) && (strncmp((char*)&data[i], code, sizeof(code) - 1) == 0))
void ws_server_req_incoming(uint8_t* data, size_t size) {
#ifdef WS_DBG_PRINT_ESP_OVER_USART2
ws_dbg_set_usart2_tty_color(1);
@@ -80,7 +80,7 @@ void ws_server_req_incoming(uint8_t* data, size_t size) {
if (next_few_bytes_are("+IPD,")) {
i += 4; // skip I, P, D, and comma
g_ws_server_parser.mode = WS_SERVER_LM_IPD_LISTENING;
- } else if (byte == '>') {
+ } else if (next_few_bytes_are("> ")) {
g_ws_server_parser.mode = WS_SERVER_LM_CIPSEND_LISTENING;
ws_server_buffer_send_finish();
}