From 668eda40dc503d733250ac0fe982c063856acb38 Mon Sep 17 00:00:00 2001 From: "jan.nijtmans" Date: Thu, 4 May 2017 09:35:14 +0000 Subject: Fix gcc warning: unused variable wakeEvent --- win/tclWinPipe.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/win/tclWinPipe.c b/win/tclWinPipe.c index 3e7e5eb..5246d53 100644 --- a/win/tclWinPipe.c +++ b/win/tclWinPipe.c @@ -3253,7 +3253,7 @@ TclPipeThreadStop( HANDLE hThread) { TclPipeThreadInfo *pipeTI = *pipeTIPtr; - HANDLE evControl, wakeEvent; + HANDLE evControl; int state; if (!pipeTI) { @@ -3261,7 +3261,6 @@ TclPipeThreadStop( } pipeTI = *pipeTIPtr; evControl = pipeTI->evControl; - wakeEvent = pipeTI->evWakeUp; pipeTI->evWakeUp = NULL; /* * Try to sane stop the pipe worker, corresponding its current state -- cgit v0.12 From d489f8278641d1b55d50c3800e86e567d7951153 Mon Sep 17 00:00:00 2001 From: "jan.nijtmans" Date: Thu, 4 May 2017 12:01:23 +0000 Subject: Cherry-pick/backport [65cc894ac5c24495|65cc894ac5]: fix off-by-one possible buffer overrun when looking for encodings; found by coverity Use GetModuleHandle() in stead of LoadLibrary() for ntdll, which is already loaded by Cygwin. --- unix/tclUnixInit.c | 27 ++++++++++++--------------- 1 file changed, 12 insertions(+), 15 deletions(-) diff --git a/unix/tclUnixInit.c b/unix/tclUnixInit.c index a873f6e..b1a4b24 100644 --- a/unix/tclUnixInit.c +++ b/unix/tclUnixInit.c @@ -14,11 +14,11 @@ #ifdef HAVE_LANGINFO # include # ifdef __APPLE__ -# if defined(HAVE_WEAK_IMPORT) && MAC_OS_X_VERSION_MIN_REQUIRED < 1030 +# if defined(HAVE_WEAK_IMPORT) && MAC_OS_X_VERSION_MIN_REQUIRED < 1030 /* Support for weakly importing nl_langinfo on Darwin. */ -# define WEAK_IMPORT_NL_LANGINFO +# define WEAK_IMPORT_NL_LANGINFO extern char *nl_langinfo(nl_item) WEAK_IMPORT_ATTRIBUTE; -# endif +# endif # endif #endif #include @@ -34,7 +34,7 @@ #ifdef __CYGWIN__ DLLIMPORT extern __stdcall unsigned char GetVersionExW(void *); -DLLIMPORT extern __stdcall void *LoadLibraryW(const void *); +DLLIMPORT extern __stdcall void *GetModuleHandleW(const void *); DLLIMPORT extern __stdcall void FreeLibrary(void *); DLLIMPORT extern __stdcall void *GetProcAddress(void *, const char *); DLLIMPORT extern __stdcall void GetSystemInfo(void *); @@ -45,12 +45,12 @@ static const char *const platforms[NUMPLATFORMS] = { }; #define NUMPROCESSORS 11 -static const char *const processors[NUMPROCESSORS] = { +static const char *const processors[NUMPROCESSORS] = { "intel", "mips", "alpha", "ppc", "shx", "arm", "ia64", "alpha64", "msil", "amd64", "ia32_on_win64" }; -typedef struct _SYSTEM_INFO { +typedef struct { union { DWORD dwOemId; struct { @@ -69,7 +69,7 @@ typedef struct _SYSTEM_INFO { int wProcessorRevision; } SYSTEM_INFO; -typedef struct _OSVERSIONINFOW { +typedef struct { DWORD dwOSVersionInfoSize; DWORD dwMajorVersion; DWORD dwMinorVersion; @@ -666,7 +666,7 @@ SearchKnownEncodings( int left = 0; int right = sizeof(localeTable)/sizeof(LocaleTable); - while (left <= right) { + while (left < right) { int test = (left + right)/2; int code = strcmp(localeTable[test].lang, encoding); @@ -832,7 +832,7 @@ TclpSetVariables( */ CFLocaleRef localeRef; - + if (&CFLocaleCopyCurrent != NULL && &CFLocaleGetIdentifier != NULL && (localeRef = CFLocaleCopyCurrent())) { CFStringRef locale = CFLocaleGetIdentifier(localeRef); @@ -929,16 +929,13 @@ TclpSetVariables( #ifdef __CYGWIN__ unameOK = 1; if (!osInfoInitialized) { - HANDLE handle = LoadLibraryW(L"NTDLL"); + HANDLE handle = GetModuleHandleW(L"NTDLL"); int(__stdcall *getversion)(void *) = (int(__stdcall *)(void *))GetProcAddress(handle, "RtlGetVersion"); osInfo.dwOSVersionInfoSize = sizeof(OSVERSIONINFOW); if (!getversion || getversion(&osInfo)) { GetVersionExW(&osInfo); } - if (handle) { - FreeLibrary(handle); - } osInfoInitialized = 1; } @@ -1130,7 +1127,7 @@ TclpGetCStackParams( stackGrowsDown = StackGrowsDown(NULL); } #endif - + /* * The first time through in a thread: record the "outermost" stack * frame and inquire with the OS about the stack size. @@ -1159,7 +1156,7 @@ TclpGetCStackParams( if (!stackSize) { /* * Stack failure: if we didn't already blow up, we are within the - * safety area. Recheck with the OS in case the stack was grown. + * safety area. Recheck with the OS in case the stack was grown. */ result = GetStackSize(&stackSize); if (result != TCL_OK) { -- cgit v0.12