From 69f09ebbb925b9ba334dee4298e0c3ca4aefb5b7 Mon Sep 17 00:00:00 2001 From: Thorsten von Eicken Date: Sat, 20 Feb 2016 11:22:25 -0800 Subject: [PATCH 1/2] fix slip protocol argument padding --- README.adoc | 4 ++-- cmd/cmd.c | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/README.adoc b/README.adoc index d6f226f..aaf1d35 100644 --- a/README.adoc +++ b/README.adoc @@ -24,8 +24,8 @@ but significantly reqritten and no longer protocol compatible, thanks to tuanpmt inspiration! Many thanks to https://github.com/brunnels for contributions in particular around the espduino -functionality. Thank you also to https://github.com/susisstrolch and https://github.com/bc547 for -additional contributions! +functionality. Thank you also to https://github.com/susisstrolch, https://github.com/bc547, +and https://github.com/katast for additional contributions! [float] Table of Contents diff --git a/cmd/cmd.c b/cmd/cmd.c index 714d185..6ebb8cb 100644 --- a/cmd/cmd.c +++ b/cmd/cmd.c @@ -63,7 +63,7 @@ cmdResponseBody(const void *data, uint16_t len) { cmdProtoWriteBuf(data, len); resp_crc = crc16_data(data, len, resp_crc); - uint16_t pad = (4-(len&3))&3; // get to multiple of 4 + uint16_t pad = (4-((len+2)&3))&3; // get to multiple of 4 if (pad > 0) { uint32_t temp = 0; cmdProtoWriteBuf((uint8_t*)&temp, pad); From 1d0f3136c50e883e29cd3a558b3a4d1735a2f43d Mon Sep 17 00:00:00 2001 From: Thorsten von Eicken Date: Sat, 27 Feb 2016 09:44:41 -0800 Subject: [PATCH 2/2] fixes #111: handle malloc failure in syslog --- syslog/syslog.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/syslog/syslog.c b/syslog/syslog.c index 20a51cb..207b678 100644 --- a/syslog/syslog.c +++ b/syslog/syslog.c @@ -380,6 +380,7 @@ syslog_compose(uint8_t facility, uint8_t severity, const char *tag, const char * { DBG("[%dµs] %s id=%lu\n", WDEV_NOW(), __FUNCTION__, syslog_msgid); syslog_entry_t *se = os_zalloc(sizeof (syslog_entry_t) + 1024); // allow up to 1k datagram + if (se == NULL) return NULL; char *p = se->datagram; se->tick = WDEV_NOW(); // 0 ... 4294.967295s se->msgid = syslog_msgid; @@ -512,6 +513,7 @@ void ICACHE_FLASH_ATTR syslog(uint8_t facility, uint8_t severity, const char *ta // compose the syslog message void *arg = __builtin_apply_args(); void *res = __builtin_apply((void*)syslog_compose, arg, 128); + if (res == NULL) return; // compose failed, probably due to malloc failure syslog_entry_t *se = *(syslog_entry_t **)res; // and append it to the message queue