mirror of
https://github.com/Atmosphere-NX/Atmosphere.git
synced 2024-12-22 18:32:05 +00:00
Fix strncpy bugs in fusée, etc.
This commit is contained in:
parent
cae107557d
commit
172a2b679c
6 changed files with 8 additions and 6 deletions
|
@ -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
|
||||
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -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
|
||||
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
|
|
@ -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);
|
||||
|
|
Loading…
Reference in a new issue