pkgsrc-WIP-changes archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

coreclr-git: sprintf_s() returns null string for overflow



Module Name:	pkgsrc-wip
Committed By:	Kamil Rytarowski <n54%gmx.com@localhost>
Pushed By:	kamil
Date:		Sun Apr 24 02:28:09 2016 +0200
Changeset:	05ce1bf787ed451006465787b504b7f2af08c2b9

Modified Files:
	coreclr-git/distinfo
	coreclr-git/patches/patch-src_pal_src_thread_process.cpp

Log Message:
coreclr-git: sprintf_s() returns null string for overflow

To see a diff of this commit:
https://wip.pkgsrc.org/cgi-bin/gitweb.cgi?p=pkgsrc-wip.git;a=commitdiff;h=05ce1bf787ed451006465787b504b7f2af08c2b9

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

diffstat:
 coreclr-git/distinfo                               |  2 +-
 .../patches/patch-src_pal_src_thread_process.cpp   | 68 +++++++++++++++++++---
 2 files changed, 61 insertions(+), 9 deletions(-)

diffs:
diff --git a/coreclr-git/distinfo b/coreclr-git/distinfo
index 5e547db..32af782 100644
--- a/coreclr-git/distinfo
+++ b/coreclr-git/distinfo
@@ -1,3 +1,3 @@
 $NetBSD$
 
-SHA1 (patch-src_pal_src_thread_process.cpp) = 1d98db1f4f5aba96cd9751ff46d5b83fdeccca7c
+SHA1 (patch-src_pal_src_thread_process.cpp) = fc73a635a66ef9dbda08ceed71343c70c651893e
diff --git a/coreclr-git/patches/patch-src_pal_src_thread_process.cpp b/coreclr-git/patches/patch-src_pal_src_thread_process.cpp
index 442e65f..66ef93d 100644
--- a/coreclr-git/patches/patch-src_pal_src_thread_process.cpp
+++ b/coreclr-git/patches/patch-src_pal_src_thread_process.cpp
@@ -18,7 +18,7 @@ $NetBSD$
  
  // Function to call during PAL/process shutdown/abort
  Volatile<PSHUTDOWN_CALLBACK> g_shutdownCallback = nullptr;
-@@ -1398,9 +1403,10 @@ static bool IsCoreClrModule(const char* 
+@@ -1398,9 +1403,15 @@ static bool IsCoreClrModule(const char* 
  // to clean up its semaphore. 
  // Note to anyone modifying these names in the future: Semaphore names on OS X are limited
  // to SEM_NAME_LEN characters, including null. SEM_NAME_LEN is 31 (at least on OS X 10.11).
@@ -26,13 +26,18 @@ $NetBSD$
 -static const char* RuntimeOldContinueSemaphoreName = "/clrco%08x%016llx";
 -static const char* RuntimeContinueSemaphoreName = "/clrct%08x%016llx";
 +// NetBSD limits semaphore names to 15 characters, including null (at least up to 7.99.25).
-+static const char* RuntimeStartupSemaphoreName = "/clrst%04x%04llx";
-+static const char* RuntimeOldContinueSemaphoreName = "/clrco%04x%04llx";
-+static const char* RuntimeContinueSemaphoreName = "/clrct%04x%04llx";
++static const char* RuntimeStartupSemaphoreName = "/clrst%08llx";
++static const char* RuntimeOldContinueSemaphoreName = "/clrco%08llx";
++static const char* RuntimeContinueSemaphoreName = "/clrct%08llx";
++
++static uint64_t HashSemaphoreName(uint64_t a, uint64_t b)
++{
++	return (a ^ b) & 0xffffffff;
++}
  
  class PAL_RuntimeStartupHelper
  {
-@@ -1437,7 +1443,7 @@ public:
+@@ -1437,12 +1448,12 @@ public:
      {
          if (m_startupSem != SEM_FAILED)
          {
@@ -41,7 +46,14 @@ $NetBSD$
              sprintf_s(startupSemName,
                        sizeof(startupSemName),
                        RuntimeStartupSemaphoreName,
-@@ -1501,7 +1507,7 @@ public:
+-                      m_processId,
+-                      m_processIdDisambiguationKey);
++                      HashSemaphoreName(m_processId,
++                                        m_processIdDisambiguationKey));
+ 
+             sem_close(m_startupSem);
+             sem_unlink(startupSemName);
+@@ -1501,7 +1512,7 @@ public:
      PAL_ERROR Register()
      {
          CPalThread *pThread = InternalGetCurrentThread();
@@ -50,7 +62,18 @@ $NetBSD$
          PAL_ERROR pe = NO_ERROR;
  
          // See semaphore name format for details about this value. We store it so that
-@@ -1618,7 +1624,7 @@ public:
+@@ -1513,8 +1524,8 @@ public:
+         sprintf_s(startupSemName,
+                   sizeof(startupSemName),
+                   RuntimeStartupSemaphoreName,
+-                  m_processId,
+-                  m_processIdDisambiguationKey);
++                  HashSemaphoreName(m_processId,
++                                    m_processIdDisambiguationKey));
+ 
+         TRACE("PAL_RuntimeStartupHelper.Register startup sem '%s'\n", startupSemName);
+ 
+@@ -1618,15 +1629,15 @@ public:
  
      void StartupHelperThread()
      {
@@ -59,7 +82,17 @@ $NetBSD$
          sem_t *continueSem = SEM_FAILED;
          PAL_ERROR pe = NO_ERROR;
  
-@@ -1793,7 +1799,7 @@ BOOL
+         sprintf_s(continueSemName,
+                   sizeof(continueSemName),
+                   RuntimeContinueSemaphoreName,
+-                  m_processId,
+-                  m_processIdDisambiguationKey);
++                  HashSemaphoreName(m_processId,
++                                    m_processIdDisambiguationKey));
+ 
+         TRACE("StartupHelperThread continue sem '%s'\n", continueSemName);
+ 
+@@ -1793,15 +1804,15 @@ BOOL
  PALAPI
  PAL_NotifyRuntimeStarted()
  {
@@ -68,3 +101,22 @@ $NetBSD$
      sem_t *startupSem = SEM_FAILED;
      BOOL result = TRUE;
  
+     UINT64 processIdDisambiguationKey = 0;
+     GetProcessIdDisambiguationKey(gPID, &processIdDisambiguationKey);
+ 
+-    sprintf_s(startupSemName, sizeof(startupSemName), RuntimeStartupSemaphoreName, gPID, processIdDisambiguationKey);
+-    sprintf_s(g_continueSemName, sizeof(g_continueSemName), RuntimeOldContinueSemaphoreName, gPID, processIdDisambiguationKey);
++    sprintf_s(startupSemName, sizeof(startupSemName), RuntimeStartupSemaphoreName, HashSemaphoreName(gPID, processIdDisambiguationKey));
++    sprintf_s(g_continueSemName, sizeof(g_continueSemName), RuntimeOldContinueSemaphoreName, HashSemaphoreName(gPID, processIdDisambiguationKey));
+ 
+     TRACE("PAL_NotifyRuntimeStarted opening continue (old) '%s' startup '%s'\n", g_continueSemName, startupSemName);
+ 
+@@ -1810,7 +1821,7 @@ PAL_NotifyRuntimeStarted()
+     if (g_continueSem == SEM_FAILED)
+     {
+         // Create the new continue semaphore name "clrctXXXX"
+-        sprintf_s(g_continueSemName, sizeof(g_continueSemName), RuntimeContinueSemaphoreName, gPID, processIdDisambiguationKey);
++        sprintf_s(g_continueSemName, sizeof(g_continueSemName), RuntimeContinueSemaphoreName, HashSemaphoreName(gPID, processIdDisambiguationKey));
+ 
+         TRACE("PAL_NotifyRuntimeStarted creating continue '%s'\n", g_continueSemName);
+ 


Home | Main Index | Thread Index | Old Index