diff --git a/fusee/fusee-primary/src/lib/ini.c b/fusee/fusee-primary/src/lib/ini.c index dcc50eb29..5b305199b 100644 --- a/fusee/fusee-primary/src/lib/ini.c +++ b/fusee/fusee-primary/src/lib/ini.c @@ -67,14 +67,6 @@ static char* find_chars_or_comment(const char* s, const char* chars) return (char*)s; } -/* 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); - dest[size - 1] = '\0'; - return dest; -} - /* See documentation in header file. */ int ini_parse_stream(ini_reader reader, void* stream, ini_handler handler, void* user) @@ -164,7 +156,7 @@ int ini_parse_stream(ini_reader reader, void* stream, ini_handler handler, end = find_chars_or_comment(start + 1, "]"); if (*end == ']') { *end = '\0'; - strncpy0(section, start + 1, sizeof(section)); + strlcpy(section, start + 1, sizeof(section)); *prev_name = '\0'; } else if (!error) { @@ -188,7 +180,7 @@ int ini_parse_stream(ini_reader reader, void* stream, ini_handler handler, rstrip(value); /* Valid name[=:]value pair found, call handler */ - strncpy0(prev_name, name, sizeof(prev_name)); + strlcpy(prev_name, name, sizeof(prev_name)); if (!HANDLER(user, section, name, value) && !error) error = lineno; } diff --git a/fusee/fusee-secondary/src/lib/ini.c b/fusee/fusee-secondary/src/lib/ini.c index dcc50eb29..5b305199b 100644 --- a/fusee/fusee-secondary/src/lib/ini.c +++ b/fusee/fusee-secondary/src/lib/ini.c @@ -67,14 +67,6 @@ static char* find_chars_or_comment(const char* s, const char* chars) return (char*)s; } -/* 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); - dest[size - 1] = '\0'; - return dest; -} - /* See documentation in header file. */ int ini_parse_stream(ini_reader reader, void* stream, ini_handler handler, void* user) @@ -164,7 +156,7 @@ int ini_parse_stream(ini_reader reader, void* stream, ini_handler handler, end = find_chars_or_comment(start + 1, "]"); if (*end == ']') { *end = '\0'; - strncpy0(section, start + 1, sizeof(section)); + strlcpy(section, start + 1, sizeof(section)); *prev_name = '\0'; } else if (!error) { @@ -188,7 +180,7 @@ int ini_parse_stream(ini_reader reader, void* stream, ini_handler handler, rstrip(value); /* Valid name[=:]value pair found, call handler */ - strncpy0(prev_name, name, sizeof(prev_name)); + strlcpy(prev_name, name, sizeof(prev_name)); if (!HANDLER(user, section, name, value) && !error) error = lineno; } diff --git a/thermosphere/src/lib/ini.c b/thermosphere/src/lib/ini.c index dcc50eb29..5b305199b 100644 --- a/thermosphere/src/lib/ini.c +++ b/thermosphere/src/lib/ini.c @@ -67,14 +67,6 @@ static char* find_chars_or_comment(const char* s, const char* chars) return (char*)s; } -/* 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); - dest[size - 1] = '\0'; - return dest; -} - /* See documentation in header file. */ int ini_parse_stream(ini_reader reader, void* stream, ini_handler handler, void* user) @@ -164,7 +156,7 @@ int ini_parse_stream(ini_reader reader, void* stream, ini_handler handler, end = find_chars_or_comment(start + 1, "]"); if (*end == ']') { *end = '\0'; - strncpy0(section, start + 1, sizeof(section)); + strlcpy(section, start + 1, sizeof(section)); *prev_name = '\0'; } else if (!error) { @@ -188,7 +180,7 @@ int ini_parse_stream(ini_reader reader, void* stream, ini_handler handler, rstrip(value); /* Valid name[=:]value pair found, call handler */ - strncpy0(prev_name, name, sizeof(prev_name)); + strlcpy(prev_name, name, sizeof(prev_name)); if (!HANDLER(user, section, name, value) && !error) error = lineno; }