From 4e69da8ab9935e55683fc4207ec93ebcbff609c1 Mon Sep 17 00:00:00 2001 From: andrew-platt Date: Fri, 13 Sep 2024 11:57:44 -0600 Subject: [PATCH] MAP: change strncpy to use macro MAP_STRNCPY Similar to how macro MAP_STRCPY works, MAP_STRNCPY points to either strncpy or strncpy_s depending on compiler used --- modules/map/src/mapapi.c | 2 +- modules/map/src/mapsys.h | 2 ++ 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/modules/map/src/mapapi.c b/modules/map/src/mapapi.c index 29ac4d3d99..ec86d8402a 100644 --- a/modules/map/src/mapapi.c +++ b/modules/map/src/mapapi.c @@ -1164,7 +1164,7 @@ MAP_EXTERNCALL void map_set_gravity(MAP_ParameterType_t* p_type, const double gr MAP_EXTERNCALL void map_set_input_text(MAP_InitInputType_t* init_type, const char* input_txt_line) { - strncpy(init_type->library_input_str, input_txt_line, 254); + MAP_STRNCPY(init_type->library_input_str, input_txt_line, 254); init_type->library_input_str[254] = '\0'; } diff --git a/modules/map/src/mapsys.h b/modules/map/src/mapsys.h index e8966d6d0e..e062fb162b 100644 --- a/modules/map/src/mapsys.h +++ b/modules/map/src/mapsys.h @@ -69,11 +69,13 @@ # define map_snprintf _snprintf # define map_strcat(a,b,c) strcat_s(a,b,c) # define MAP_STRCPY(a,b,c) strcpy_s(a,b,c) +# define MAP_STRNCPY(a,b,c) strncpy_s(a,c,b,c) #else # include # define map_snprintf snprintf # define map_strcat(a,b,c) strncat(a,c,b) # define MAP_STRCPY(a,b,c) strcpy(a,c) +# define MAP_STRNCPY(a,b,c) strncpy(a,b,c) #endif