[Openmp-commits] [PATCH] D105931: [OpenMP] Fix incorrect parameters to sscanf_s call

Jonathan Peyton via Phabricator via Openmp-commits openmp-commits at lists.llvm.org
Tue Jul 13 12:46:10 PDT 2021


jlpeyton created this revision.
jlpeyton added reviewers: AndreyChurbanov, tlwilmar, hbae, Nawrin.
jlpeyton added a project: OpenMP.
Herald added subscribers: guansong, yaxunl.
jlpeyton requested review of this revision.
Herald added a reviewer: jdoerfert.
Herald added a subscriber: sstefan1.

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.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D105931

Files:
  openmp/runtime/src/kmp_settings.cpp


Index: openmp/runtime/src/kmp_settings.cpp
===================================================================
--- openmp/runtime/src/kmp_settings.cpp
+++ openmp/runtime/src/kmp_settings.cpp
@@ -164,7 +164,12 @@
     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)


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D105931.358391.patch
Type: text/x-patch
Size: 586 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/openmp-commits/attachments/20210713/3350a96d/attachment.bin>


More information about the Openmp-commits mailing list