loader: Rename strcpy_s() implementation to strcpy_sx()
The implementation strcpy_s() in loader is wrong (to be fixed) and limited in comparison to strcpy_s() spec. Rename it to strcpy_sx() to indicate it is not the one from standard library.
#define ATTR_FORMAT(...)
#endif
-#if !_WIN32
+#if _WIN32
+#define strcpy_sx strcpy_s
+#else
/*
- * Provide strcpy_s() for GNU libc.
+ * Limited variant of strcpy_s().
+ *
+ * Provided for C standard libraries where strcpy_s() is not available.
* The availability check might need to adjusted for other C standard library implementations.
*/
-static void strcpy_s(char* dest, size_t destsz, const char* src)
+static void strcpy_sx(char* restrict dest, size_t destsz, const char* restrict src)
{
size_t len = strlen(src);
if (len > destsz - 1)
@@ -124,7 +128,7 @@ evmc_create_fn evmc_load(const char* filename, enum evmc_loader_error_code* erro
const char prefix[] = "evmc_create_";
const size_t prefix_length = strlen(prefix);
char prefixed_name[sizeof(prefix) + PATH_MAX_LENGTH];
- strcpy_s(prefixed_name, sizeof(prefixed_name), prefix);
+ strcpy_sx(prefixed_name, sizeof(prefixed_name), prefix);
// Find filename in the path.
const char* sep_pos = strrchr(filename, '/');
@@ -142,7 +146,7 @@ evmc_create_fn evmc_load(const char* filename, enum evmc_loader_error_code* erro
name_pos += lib_prefix_length;
char* base_name = prefixed_name + prefix_length;
- strcpy_s(base_name, PATH_MAX_LENGTH, name_pos);
+ strcpy_sx(base_name, PATH_MAX_LENGTH, name_pos);
// Trim the file extension.
char* ext_pos = strrchr(prefixed_name, '.');
