fix buffer overrun problem with error/warning report in non-console win32 builds (popups) (#2293)
This commit is contained in:
parent
addab4c8aa
commit
1b73b3d840
@ -1,3 +1,10 @@
|
||||
2011-02-09 Frank Warmerdam <warmerdam@pobox.com>
|
||||
|
||||
* libtiff/tif_win32.c: avoid error/warning buffer overrun problem
|
||||
with non-console (popup message) builds on win32.
|
||||
|
||||
http://bugzilla.maptools.org/show_bug.cgi?id=2293
|
||||
|
||||
2011-01-24 Olivier Paquet <olivier.paquet@gmail.com>
|
||||
|
||||
* libtiff/{tif_dir.{h,c}, tif_dirinfo.c, tif_dirread.c, tif_dirwrite.c,
|
||||
|
@ -1,4 +1,4 @@
|
||||
/* $Id: tif_win32.c,v 1.37 2010-06-21 19:09:26 bfriesen Exp $ */
|
||||
/* $Id: tif_win32.c,v 1.38 2011-02-09 18:05:00 fwarmerdam Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (c) 1988-1997 Sam Leffler
|
||||
@ -364,6 +364,10 @@ _TIFFmemcmp(const void* p1, const void* p2, tmsize_t c)
|
||||
|
||||
#ifndef _WIN32_WCE
|
||||
|
||||
#if (_MSC_VER < 1500)
|
||||
# define vsnprintf _vsnprintf
|
||||
#endif
|
||||
|
||||
static void
|
||||
Win32WarningHandler(const char* module, const char* fmt, va_list ap)
|
||||
{
|
||||
@ -373,14 +377,17 @@ Win32WarningHandler(const char* module, const char* fmt, va_list ap)
|
||||
LPCTSTR szTitleText = "%s Warning";
|
||||
LPCTSTR szDefaultModule = "LIBTIFF";
|
||||
LPCTSTR szTmpModule = (module == NULL) ? szDefaultModule : module;
|
||||
if ((szTitle = (LPTSTR)LocalAlloc(LMEM_FIXED, (strlen(szTmpModule) +
|
||||
strlen(szTitleText) + strlen(fmt) + 128)*sizeof(char))) == NULL)
|
||||
int nBufSize = (strlen(szTmpModule) +
|
||||
strlen(szTitleText) + strlen(fmt) + 256)*sizeof(char);
|
||||
|
||||
if ((szTitle = (LPTSTR)LocalAlloc(LMEM_FIXED, nBufSize)) == NULL)
|
||||
return;
|
||||
sprintf(szTitle, szTitleText, szTmpModule);
|
||||
szTmp = szTitle + (strlen(szTitle)+2)*sizeof(char);
|
||||
vsprintf(szTmp, fmt, ap);
|
||||
vsnprintf(szTmp, nBufSize-(strlen(szTitle)+2)*sizeof(char), fmt, ap);
|
||||
MessageBoxA(GetFocus(), szTmp, szTitle, MB_OK | MB_ICONINFORMATION);
|
||||
LocalFree(szTitle);
|
||||
|
||||
return;
|
||||
#else
|
||||
if (module != NULL)
|
||||
@ -401,12 +408,14 @@ Win32ErrorHandler(const char* module, const char* fmt, va_list ap)
|
||||
LPCTSTR szTitleText = "%s Error";
|
||||
LPCTSTR szDefaultModule = "LIBTIFF";
|
||||
LPCTSTR szTmpModule = (module == NULL) ? szDefaultModule : module;
|
||||
if ((szTitle = (LPTSTR)LocalAlloc(LMEM_FIXED, (strlen(szTmpModule) +
|
||||
strlen(szTitleText) + strlen(fmt) + 128)*sizeof(char))) == NULL)
|
||||
int nBufSize = (strlen(szTmpModule) +
|
||||
strlen(szTitleText) + strlen(fmt) + 256)*sizeof(char);
|
||||
|
||||
if ((szTitle = (LPTSTR)LocalAlloc(LMEM_FIXED, nBufSize)) == NULL)
|
||||
return;
|
||||
sprintf(szTitle, szTitleText, szTmpModule);
|
||||
szTmp = szTitle + (strlen(szTitle)+2)*sizeof(char);
|
||||
vsprintf(szTmp, fmt, ap);
|
||||
vsnprintf(szTmp, nBufSize-(strlen(szTitle)+2)*sizeof(char), fmt, ap);
|
||||
MessageBoxA(GetFocus(), szTmp, szTitle, MB_OK | MB_ICONEXCLAMATION);
|
||||
LocalFree(szTitle);
|
||||
return;
|
||||
|
Loading…
Reference in New Issue
Block a user