diff --git a/Sming/Arch/Host/Components/esp_hal/include/esp_systemapi.h b/Sming/Arch/Host/Components/esp_hal/include/esp_systemapi.h index ea292b0f2b..eec21f9ce3 100644 --- a/Sming/Arch/Host/Components/esp_hal/include/esp_systemapi.h +++ b/Sming/Arch/Host/Components/esp_hal/include/esp_systemapi.h @@ -44,7 +44,6 @@ struct ip_addr { #include #include "debug_progmem.h" -#define debugf debug_i #define SYSTEM_ERROR(fmt, ...) hostmsg("ERROR: " fmt "\r\n", ##__VA_ARGS__) diff --git a/Sming/Arch/Host/Components/hostlib/hostlib.c b/Sming/Arch/Host/Components/hostlib/hostlib.c index 4fc60673c8..f9553c8863 100644 --- a/Sming/Arch/Host/Components/hostlib/hostlib.c +++ b/Sming/Arch/Host/Components/hostlib/hostlib.c @@ -31,13 +31,17 @@ int msleep(unsigned ms) void getHostAppDir(char* path, size_t bufSize) { + if(path == NULL ||bufSize == 0) { + return; + } + size_t len; char sep; #ifdef __WIN32 - len = GetModuleFileName(NULL, path, bufSize); + len = GetModuleFileName(NULL, path, bufSize - 1); sep = '\\'; #else - len = readlink("/proc/self/exe", path, bufSize); + len = readlink("/proc/self/exe", path, bufSize - 1); sep = '/'; #endif path[len] = '\0'; diff --git a/Sming/Arch/Host/Components/lwip/Linux/host_lwip.c b/Sming/Arch/Host/Components/lwip/Linux/host_lwip.c index 9ec7255be3..5de4cf3891 100644 --- a/Sming/Arch/Host/Components/lwip/Linux/host_lwip.c +++ b/Sming/Arch/Host/Components/lwip/Linux/host_lwip.c @@ -47,9 +47,14 @@ static struct netif netif; static void getMacAddress(const char* ifname, uint8_t hwaddr[6]) { + if(ifname == NULL) { + return; + } + struct ifreq ifr = {0}; ifr.ifr_addr.sa_family = AF_INET; strncpy(ifr.ifr_name, ifname, IFNAMSIZ); + ifr.ifr_name[IFNAMSIZ - 1] = '\0'; int fd = socket(AF_INET, SOCK_DGRAM, 0); int res = ioctl(fd, SIOCGIFHWADDR, &ifr); @@ -131,7 +136,8 @@ bool host_lwip_init(const struct lwip_param* param) if(param->ipaddr == NULL) { // Choose a default IP address - IP4_ADDR(&netcfg.ipaddr, (uint32_t)ip4_addr1(&netcfg.gw), (uint32_t)ip4_addr2(&netcfg.gw), (uint32_t)ip4_addr3(&netcfg.gw), 10U); + IP4_ADDR(&netcfg.ipaddr, (uint32_t)ip4_addr1(&netcfg.gw), (uint32_t)ip4_addr2(&netcfg.gw), + (uint32_t)ip4_addr3(&netcfg.gw), 10U); } else if(ip4addr_aton(param->ipaddr, &netcfg.ipaddr) != 1) { hostmsg("Failed to parse provided IP address '%s'", param->ipaddr); return false; diff --git a/Sming/Arch/Host/Components/spi_flash/flashmem.cpp b/Sming/Arch/Host/Components/spi_flash/flashmem.cpp index e56480705b..4eb3374259 100644 --- a/Sming/Arch/Host/Components/spi_flash/flashmem.cpp +++ b/Sming/Arch/Host/Components/spi_flash/flashmem.cpp @@ -40,6 +40,7 @@ bool host_flashmem_init(FlashmemConfig& config) { if(config.filename != nullptr) { strncpy(flashFileName, config.filename, sizeof(flashFileName)); + flashFileName[sizeof(flashFileName) - 1] = '\0'; } else { getHostAppDir(flashFileName, sizeof(flashFileName)); strcpy(flashFileName, defaultFlashFileName);