summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorKamil Rytarowski <n54@gmx.com>2016-02-18 23:41:56 +0100
committerKamil Rytarowski <n54@gmx.com>2016-04-13 08:56:05 +0200
commitfd1f866f28c71570a7ef80dd1159a5cd755f8bf3 (patch)
treef489f5cf35f33a8527a94e19c5d1a057c34aa136 /src
parentafdce3a592e5f6f2047bed057d121225be91743d (diff)
downloadcoreclr-fd1f866f28c71570a7ef80dd1159a5cd755f8bf3.tar.gz
coreclr-fd1f866f28c71570a7ef80dd1159a5cd755f8bf3.tar.bz2
coreclr-fd1f866f28c71570a7ef80dd1159a5cd755f8bf3.zip
Fix issue unveiled on NetBSD: Add PAL__vsnprintf shadow in PAL
NetBSD's libc internally uses a function named _vsnprintf. We need to mask PAL's version of this function to remove clash with the system. With it snprintf(3) calls were jumping out of libc and landing back to PAL. It was unveiled with many PAL tests. Detailed documentation about _symbols in the NetBSD libc is documented in the NetBSD sources in a file: src/lib/libc/README Retire unneeded _vsnprintf(). Thanks Jan Vorli (Microsoft) for help with debugging. Thanks Jan Kotas (Microsoft) for suggesting the right solution. Fix #3199
Diffstat (limited to 'src')
-rw-r--r--src/ToolBox/SOS/Strike/strike.h4
-rw-r--r--src/pal/inc/pal.h1
-rw-r--r--src/pal/src/cruntime/printf.cpp38
-rw-r--r--src/pal/src/cruntime/printfcpp.cpp13
-rw-r--r--src/pal/src/cruntime/silent_printf.cpp4
5 files changed, 23 insertions, 37 deletions
diff --git a/src/ToolBox/SOS/Strike/strike.h b/src/ToolBox/SOS/Strike/strike.h
index d6bd54dc54..f2aefa08b4 100644
--- a/src/ToolBox/SOS/Strike/strike.h
+++ b/src/ToolBox/SOS/Strike/strike.h
@@ -44,6 +44,10 @@
#define _wcsstr wcsstr
#endif // !PAL_STDCPP_COMPAT
+#ifdef PLATFORM_UNIX
+#define _vsnprintf vsnprintf
+#endif
+
#define ___in _SAL1_Source_(__in, (), _In_)
#define ___out _SAL1_Source_(__out, (), _Out_)
diff --git a/src/pal/inc/pal.h b/src/pal/inc/pal.h
index 590cb64b1a..6d83e4331c 100644
--- a/src/pal/inc/pal.h
+++ b/src/pal/inc/pal.h
@@ -5790,6 +5790,7 @@ CoCreateGuid(OUT GUID * pguid);
#define _close PAL__close
#define _wcstoui64 PAL__wcstoui64
#define _flushall PAL__flushall
+#define _vsnprintf PAL__vsnprintf
#ifdef _AMD64_
#define _mm_getcsr PAL__mm_getcsr
diff --git a/src/pal/src/cruntime/printf.cpp b/src/pal/src/cruntime/printf.cpp
index d16f017ec8..2d9d6e4b94 100644
--- a/src/pal/src/cruntime/printf.cpp
+++ b/src/pal/src/cruntime/printf.cpp
@@ -295,7 +295,7 @@ wsprintfA(
ENTRY("wsprintfA (buffer=%p, format=%p (%s))\n", buffer, format, format);
va_start(ap, format);
- Length = PAL__vsnprintf(buffer, 1024, format, ap);
+ Length = InternalVsnprintf(CorUnix::InternalGetCurrentThread(), buffer, 1024, format, ap);
va_end(ap);
LOGEXIT("wsprintfA returns int %d\n", Length);
@@ -354,7 +354,7 @@ _snprintf(
buffer, (unsigned long) count, format, format);
va_start(ap, format);
- Length = PAL__vsnprintf(buffer, count, format, ap);
+ Length = InternalVsnprintf(CorUnix::InternalGetCurrentThread(), buffer, count, format, ap);
va_end(ap);
LOGEXIT("_snprintf returns int %d\n", Length);
@@ -1529,7 +1529,7 @@ PAL_sprintf(
ENTRY("PAL_sprintf (buffer=%p, format=%p (%s))\n", buffer, format, format);
va_start(ap, format);
- Length = PAL__vsnprintf(buffer, 0x7fffffff, format, ap);
+ Length = InternalVsnprintf(CorUnix::InternalGetCurrentThread(), buffer, 0x7fffffff, format, ap);
va_end(ap);
LOGEXIT("PAL_sprintf returns int %d\n", Length);
@@ -1613,7 +1613,7 @@ PAL_vsprintf(char *buffer,
ENTRY("PAL_vsprintf (buffer=%p, format=%p (%s), argptr=%p)\n",
buffer, format, format, argptr);
- Length = PAL__vsnprintf(buffer, 0x7fffffff, format, argptr);
+ Length = InternalVsnprintf(CorUnix::InternalGetCurrentThread(), buffer, 0x7fffffff, format, argptr);
LOGEXIT("PAL_vsprintf returns int %d\n", Length);
PERF_EXIT(vsprintf);
@@ -1624,35 +1624,6 @@ PAL_vsprintf(char *buffer,
/*++
Function:
- _vsnprintf
-
-See MSDN doc.
---*/
-int
-__cdecl
-_vsnprintf(char *buffer,
- size_t count,
- const char *format,
- va_list argptr)
-{
- LONG Length;
-
- PERF_ENTRY(_vsnprintf);
- ENTRY("_vsnprintf (buffer=%p, count=%d, format=%p (%s), argptr=%p)\n",
- buffer, count, format, format, argptr);
-
- Length = PAL__vsnprintf(buffer, count, format, argptr);
-
- LOGEXIT("_vsnprintf returns int %d\n", Length);
- PERF_EXIT(_vsnprintf);
-
- return Length;
-}
-
-
-
-/*++
-Function:
PAL_vswprintf
See MSDN doc.
@@ -1785,4 +1756,3 @@ static int SscanfFloatCheckExponent(LPCSTR buff, LPCSTR floatFmt,
return ret;
}
#endif // SSCANF_CANNOT_HANDLE_MISSING_EXPONENT
-
diff --git a/src/pal/src/cruntime/printfcpp.cpp b/src/pal/src/cruntime/printfcpp.cpp
index 84c003bc3d..c0824ab261 100644
--- a/src/pal/src/cruntime/printfcpp.cpp
+++ b/src/pal/src/cruntime/printfcpp.cpp
@@ -1068,7 +1068,18 @@ Parameters:
int __cdecl PAL__vsnprintf(LPSTR Buffer, size_t Count, LPCSTR Format, va_list ap)
{
- return CoreVsnprintf(InternalGetCurrentThread(), Buffer, Count, Format, ap);
+ LONG Length;
+
+ PERF_ENTRY(PAL__vsnprintf);
+ ENTRY("PAL__vsnprintf (buffer=%p, count=%d, format=%p (%s), argptr=%p)\n",
+ Buffer, Count, Format, Format, ap);
+
+ Length = CoreVsnprintf(InternalGetCurrentThread(), Buffer, Count, Format, ap);
+
+ LOGEXIT("PAL__vsnprintf returns int %d\n", Length);
+ PERF_EXIT(PAL__vsnprintf);
+
+ return Length;
}
/*******************************************************************************
diff --git a/src/pal/src/cruntime/silent_printf.cpp b/src/pal/src/cruntime/silent_printf.cpp
index a170cc41e5..1d10963973 100644
--- a/src/pal/src/cruntime/silent_printf.cpp
+++ b/src/pal/src/cruntime/silent_printf.cpp
@@ -26,6 +26,7 @@ Revision History:
#include "pal/cruntime.h"
#include "pal/locale.h"
#include "pal/printfcpp.hpp"
+#include "pal/thread.hpp"
/* clip strings (%s, %S) at this number of characters */
#define MAX_STR_LEN 300
@@ -280,7 +281,7 @@ INT Silent_PAL_vsnprintf(LPSTR Buffer, INT Count, LPCSTR Format, va_list aparg)
}
va_list apcopy;
va_copy(apcopy, ap);
- TempInt = PAL__vsnprintf(BufferPtr, TempCount, TempBuff, apcopy);
+ TempInt = InternalVsnprintf(CorUnix::InternalGetCurrentThread(), BufferPtr, TempCount, TempBuff, apcopy);
va_end(apcopy);
PAL_printf_arg_remover(&ap, Width, Precision, Type, Prefix);
}
@@ -987,4 +988,3 @@ size_t Silent_PAL_wcslen(const wchar_16 *string)
return nChar;
}
-