[Openmp-commits] [openmp] 6eeb4c1 - [OpenMP] Fix incorrect parameters to sscanf_s call

via Openmp-commits openmp-commits at lists.llvm.org
Mon Aug 16 08:02:33 PDT 2021


Author: Peyton, Jonathan L
Date: 2021-08-16T09:59:21-05:00
New Revision: 6eeb4c1f3203566599c12a5f2b147c6c5a92ee1d

URL: https://github.com/llvm/llvm-project/commit/6eeb4c1f3203566599c12a5f2b147c6c5a92ee1d
DIFF: https://github.com/llvm/llvm-project/commit/6eeb4c1f3203566599c12a5f2b147c6c5a92ee1d.diff

LOG: [OpenMP] Fix incorrect parameters to sscanf_s call

On Windows, the documentation states that when using sscanf_s,
each %c and %s specifier must also have additional size parameter.
This patch adds the size parameter in the one place where %c is
used.

Differential Revision: https://reviews.llvm.org/D105931

Added: 
    

Modified: 
    openmp/runtime/src/kmp_settings.cpp

Removed: 
    


################################################################################
diff  --git a/openmp/runtime/src/kmp_settings.cpp b/openmp/runtime/src/kmp_settings.cpp
index a98a2a43b0d0..b4b8fbe1aa0a 100644
--- a/openmp/runtime/src/kmp_settings.cpp
+++ b/openmp/runtime/src/kmp_settings.cpp
@@ -164,7 +164,12 @@ int __kmp_convert_to_milliseconds(char const *data) {
     return (INT_MAX);
   value = (double)0.0;
   mult = '\0';
+#if KMP_OS_WINDOWS
+  // On Windows, each %c parameter needs additional size parameter for sscanf_s
+  nvalues = KMP_SSCANF(data, "%lf%c%c", &value, &mult, 1, &extra, 1);
+#else
   nvalues = KMP_SSCANF(data, "%lf%c%c", &value, &mult, &extra);
+#endif
   if (nvalues < 1)
     return (-1);
   if (nvalues == 1)


        


More information about the Openmp-commits mailing list