diff --git a/fusee/fusee-primary/src/display/cfb_console.c b/fusee/fusee-primary/src/display/cfb_console.c index 65ef5462f..9d2e95b7c 100644 --- a/fusee/fusee-primary/src/display/cfb_console.c +++ b/fusee/fusee-primary/src/display/cfb_console.c @@ -555,7 +555,7 @@ static void console_scrollup (void) CONFIG_VIDEO_VISIBLE_ROWS - video_logo_height - VIDEO_FONT_HEIGHT /* frame height */ ); #else - memcpy(CONSOLE_ROW_FIRST, CONSOLE_ROW_SECOND, + memmove(CONSOLE_ROW_FIRST, CONSOLE_ROW_SECOND, CONSOLE_SCROLL_SIZE); #endif diff --git a/fusee/fusee-primary/src/lib/ini.c b/fusee/fusee-primary/src/lib/ini.c index dcc50eb29..63626c72d 100644 --- a/fusee/fusee-primary/src/lib/ini.c +++ b/fusee/fusee-primary/src/lib/ini.c @@ -70,7 +70,7 @@ static char* find_chars_or_comment(const char* s, const char* chars) /* Version of strncpy that ensures dest (size bytes) is null-terminated. */ static char* strncpy0(char* dest, const char* src, size_t size) { - strncpy(dest, src, size); + strncpy(dest, src, size - 1); dest[size - 1] = '\0'; return dest; } diff --git a/fusee/fusee-primary/src/stage2.c b/fusee/fusee-primary/src/stage2.c index b20ce7419..3321d39ea 100644 --- a/fusee/fusee-primary/src/stage2.c +++ b/fusee/fusee-primary/src/stage2.c @@ -20,7 +20,8 @@ static int stage2_ini_handler(void *user, const char *section, const char *name, uintptr_t x = 0; if (strcmp(section, "stage1") == 0) { if (strcmp(name, STAGE2_NAME_KEY) == 0) { - strncpy(config->path, value, sizeof(config->path)); + strncpy(config->path, value, sizeof(config->path) - 1); + config->path[sizeof(config->path) - 1] = '\0'; } else if (strcmp(name, STAGE2_ADDRESS_KEY) == 0) { /* Read in load address as a hex string. */ sscanf(value, "%x", &x); diff --git a/fusee/fusee-secondary/src/display/cfb_console.c b/fusee/fusee-secondary/src/display/cfb_console.c index 65ef5462f..9d2e95b7c 100644 --- a/fusee/fusee-secondary/src/display/cfb_console.c +++ b/fusee/fusee-secondary/src/display/cfb_console.c @@ -555,7 +555,7 @@ static void console_scrollup (void) CONFIG_VIDEO_VISIBLE_ROWS - video_logo_height - VIDEO_FONT_HEIGHT /* frame height */ ); #else - memcpy(CONSOLE_ROW_FIRST, CONSOLE_ROW_SECOND, + memmove(CONSOLE_ROW_FIRST, CONSOLE_ROW_SECOND, CONSOLE_SCROLL_SIZE); #endif diff --git a/fusee/fusee-secondary/src/lib/ini.c b/fusee/fusee-secondary/src/lib/ini.c index dcc50eb29..63626c72d 100644 --- a/fusee/fusee-secondary/src/lib/ini.c +++ b/fusee/fusee-secondary/src/lib/ini.c @@ -70,7 +70,7 @@ static char* find_chars_or_comment(const char* s, const char* chars) /* Version of strncpy that ensures dest (size bytes) is null-terminated. */ static char* strncpy0(char* dest, const char* src, size_t size) { - strncpy(dest, src, size); + strncpy(dest, src, size - 1); dest[size - 1] = '\0'; return dest; } diff --git a/fusee/fusee-secondary/src/loader.c b/fusee/fusee-secondary/src/loader.c index e942986d6..3d6916c5c 100644 --- a/fusee/fusee-secondary/src/loader.c +++ b/fusee/fusee-secondary/src/loader.c @@ -25,7 +25,8 @@ static int loadlist_entry_ini_handler(void *user, const char *section, const cha ext = name + strlen(load_file_ctx->key); if (strcmp(ext, "_path") == 0) { /* Copy in the path. */ - strncpy(load_file_ctx->path, value, sizeof(load_file_ctx->path)); + strncpy(load_file_ctx->path, value, sizeof(load_file_ctx->path) - 1); + load_file_ctx->path[sizeof(load_file_ctx->path) - 1] = '\0'; } else if (strcmp(ext, "_addr") == 0) { /* Read in load address as a hex string. */ sscanf(value, "%x", &x);