From 6a360bad6bfb3dc1efe2d5095c58420689d5e9e7 Mon Sep 17 00:00:00 2001 From: RandySheriffH <48490400+RandySheriffH@users.noreply.github.com> Date: Mon, 17 Aug 2020 16:44:44 -0700 Subject: [PATCH] ReplaceStrncpy (#4823) * replace strncpy with strlcpy * keep strncpy to linux * cancel reseting of string ending for strlcpy Co-authored-by: Randy Co-authored-by: RandySheriffH --- onnxruntime/core/session/onnxruntime_c_api.cc | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/onnxruntime/core/session/onnxruntime_c_api.cc b/onnxruntime/core/session/onnxruntime_c_api.cc index b39bba0bb2..1e38354f8b 100644 --- a/onnxruntime/core/session/onnxruntime_c_api.cc +++ b/onnxruntime/core/session/onnxruntime_c_api.cc @@ -1602,10 +1602,13 @@ ORT_API_STATUS_IMPL(OrtApis::GetAvailableProviders, _Outptr_ char*** out_ptr, if (out[i]) { #ifdef _MSC_VER strncpy_s(out[i], MAX_LEN, providers_available[i], MAX_LEN); -#else - strncpy(out[i], providers_available[i], MAX_LEN); -#endif out[i][MAX_LEN] = '\0'; +#elif defined(__APPLE__) + strlcpy(out[i], providers_available[i], MAX_LEN); +#else + strncpy(out[i], providers_available[i], MAX_LEN); + out[i][MAX_LEN] = '\0'; +#endif } } }