From 22a79e03a60bed3df7ba24015564c4b48bb811cb Mon Sep 17 00:00:00 2001 From: Uros Majstorovic Date: Sun, 24 Nov 2019 18:25:18 +0100 Subject: fixed evt msg get; cleanup --- code/fe310/eos/sock.c | 7 +++++++ 1 file changed, 7 insertions(+) (limited to 'code/fe310/eos/sock.c') diff --git a/code/fe310/eos/sock.c b/code/fe310/eos/sock.c index b217b43..ab0fc59 100644 --- a/code/fe310/eos/sock.c +++ b/code/fe310/eos/sock.c @@ -13,6 +13,12 @@ static uint16_t sock_handler_flags_buf_free = 0; static uint16_t sock_handler_flags_buf_acq = 0; static void sock_handler_evt(unsigned char type, unsigned char *buffer, uint16_t len) { + if ((buffer == NULL) || (len < 2)) { + eos_evtq_bad_handler(type, buffer, len); + eos_net_free(buffer, 0); + return; + } + if (buffer[0] == EOS_SOCK_MTYPE_PKT) { uint8_t sock = buffer[1]; if (sock && (sock <= EOS_SOCK_MAX_SOCK)) { @@ -59,6 +65,7 @@ int eos_sock_open_udp(void) { sock = buffer[1]; eos_net_free(buffer, 1); + if (sock == 0) return EOS_ERR_NET; return sock; } -- cgit v1.2.3