diff --git a/src/java.desktop/windows/native/libawt/windows/awt_Font.cpp b/src/java.desktop/windows/native/libawt/windows/awt_Font.cpp index cef2e3d1046..3a63408294e 100644 --- a/src/java.desktop/windows/native/libawt/windows/awt_Font.cpp +++ b/src/java.desktop/windows/native/libawt/windows/awt_Font.cpp @@ -25,6 +25,7 @@ #include "awt.h" #include +#include #include "jlong.h" #include "awt_Font.h" #include "awt_Toolkit.h" @@ -287,7 +288,6 @@ AwtFont* AwtFont::Create(JNIEnv *env, jobject font, jint angle, jfloat awScale) return NULL; } LPCWSTR textComponentFontName = JNU_GetStringPlatformChars(env, jTextComponentFontName, NULL); - awtFont->m_textInput = -1; for (int i = 0; i < cfnum; i++) { // nativeName is a pair of platform fontname and its charset @@ -463,7 +463,7 @@ static HFONT CreateHFont_sub(LPCWSTR name, int style, int height, // Set font name WCHAR tmpname[80]; - wcscpy(tmpname, name); + StringCchCopy(tmpname, 80, name); WCHAR* delimit = wcschr(tmpname, L','); if (delimit != NULL) *delimit = L'\0'; // terminate the string after the font name. @@ -471,7 +471,7 @@ static HFONT CreateHFont_sub(LPCWSTR name, int style, int height, strip_tail(tmpname,L""); //strip possible trailing whitespace strip_tail(tmpname,L"Italic"); strip_tail(tmpname,L"Bold"); - wcscpy(&(logFont.lfFaceName[0]), tmpname); + StringCchCopy(&(logFont.lfFaceName[0]), LF_FACESIZE, tmpname); HFONT hFont = ::CreateFontIndirect(&logFont); DASSERT(hFont != NULL); // get a expanded or condensed version if its specified. @@ -502,7 +502,7 @@ HFONT AwtFont::CreateHFont(WCHAR* name, int style, int height, // 80 > (max face name(=30) + strlen("CHINESEBIG5_CHARSET")) // longName doesn't have to be printable. So, it is OK not to convert. - wsprintf(longName, L"%ls-%d-%d", name, style, height); + StringCchPrintf(longName, 80, L"%ls-%d-%d", name, style, height); HFONT hFont = NULL; @@ -1750,12 +1750,12 @@ LPSTR CCombinedSegTable::GetCodePageSubkey() lpszCP++; // cf lpszCP = "932" char szSubKey[KEYLEN]; - strcpy(szSubKey, "EUDC\\"); + StringCchCopyA(szSubKey, KEYLEN, "EUDC\\"); if ((strlen(szSubKey) + strlen(lpszCP)) >= KEYLEN) { return NULL; } - strcpy(&(szSubKey[strlen(szSubKey)]), lpszCP); - strcpy(m_szCodePageSubkey, szSubKey); + StringCchCatA(szSubKey, KEYLEN, lpszCP); + StringCchCopyA(m_szCodePageSubkey, KEYLEN, szSubKey); return m_szCodePageSubkey; } @@ -1780,7 +1780,7 @@ void CCombinedSegTable::GetEUDCFileName(LPWSTR lpszFileName, int cchFileName) // get EUDC font file name WCHAR szFamilyName[80]; - wcscpy(szFamilyName, GetFontName()); + StringCchCopy(szFamilyName, 80, GetFontName()); WCHAR* delimit = wcschr(szFamilyName, L','); if (delimit != NULL) *delimit = L'\0'; @@ -1799,7 +1799,7 @@ void CCombinedSegTable::GetEUDCFileName(LPWSTR lpszFileName, int cchFileName) if (m_fTTEUDCFileExist == FALSE) return; if (wcslen(m_szDefaultEUDCFile) > 0) { - wcscpy(lpszFileName, m_szDefaultEUDCFile); + StringCchCopy(lpszFileName, cchFileName, m_szDefaultEUDCFile); return; } char szDefault[] = "SystemDefaultEUDCFont"; @@ -1825,7 +1825,7 @@ void CCombinedSegTable::GetEUDCFileName(LPWSTR lpszFileName, int cchFileName) VERIFY(::MultiByteToWideChar(CP_ACP, 0, (LPCSTR)szFileName, -1, lpszFileName, cchFileName) != 0); if (fUseDefault) - wcscpy(m_szDefaultEUDCFile, lpszFileName); + StringCchCopy(m_szDefaultEUDCFile, _MAX_PATH, lpszFileName); } void CCombinedSegTable::Create(LPCWSTR name) diff --git a/src/java.desktop/windows/native/libawt/windows/awt_PrintJob.cpp b/src/java.desktop/windows/native/libawt/windows/awt_PrintJob.cpp index 618ae9e1a82..c8f864d0252 100644 --- a/src/java.desktop/windows/native/libawt/windows/awt_PrintJob.cpp +++ b/src/java.desktop/windows/native/libawt/windows/awt_PrintJob.cpp @@ -24,6 +24,7 @@ */ #include "awt.h" +#include #include #include #include @@ -2298,7 +2299,7 @@ static jboolean jFontToWFontW(JNIEnv *env, HDC printDC, jstring fontName, size_t nameLen = wcslen(fontNameW); if (nameLen < (sizeof(lf.lfFaceName) / sizeof(lf.lfFaceName[0]))) { - wcscpy(lf.lfFaceName, fontNameW); + StringCchCopyW(lf.lfFaceName, LF_FACESIZE, fontNameW); lf.lfCharSet = DEFAULT_CHARSET; lf.lfPitchAndFamily = 0; diff --git a/src/java.desktop/windows/native/libfontmanager/fontpath.c b/src/java.desktop/windows/native/libfontmanager/fontpath.c index e4e7f944012..38925d71ca8 100644 --- a/src/java.desktop/windows/native/libfontmanager/fontpath.c +++ b/src/java.desktop/windows/native/libfontmanager/fontpath.c @@ -24,6 +24,7 @@ */ #include +#include #include #include @@ -63,20 +64,20 @@ JNIEXPORT jstring JNICALL Java_sun_awt_Win32FontManager_getFontPath(JNIEnv *env, end = strrchr(sysdir,'\\'); if (end && (stricmp(end,"\\System") || stricmp(end,"\\System32"))) { *end = 0; - strcat(sysdir, "\\Fonts"); + StringCchCatA(sysdir, BSIZE, "\\Fonts"); } GetWindowsDirectory(windir, BSIZE); if (strlen(windir) > BSIZE-7) { *windir = 0; } else { - strcat(windir, "\\Fonts"); + StringCchCatA(windir, BSIZE, "\\Fonts"); } - strcpy(fontpath,sysdir); + StringCchCopyA(fontpath, BSIZE*2, sysdir); if (stricmp(sysdir,windir)) { - strcat(fontpath,";"); - strcat(fontpath,windir); + StringCchCatA(fontpath, BSIZE*2, ";"); + StringCchCatA(fontpath, BSIZE*2, windir); } return JNU_NewStringPlatform(env, fontpath); @@ -152,7 +153,7 @@ static int DifferentFamily(wchar_t *family, wchar_t* fullName) { info.isDifferent = 0; memset(&lfw, 0, sizeof(lfw)); - wcscpy(lfw.lfFaceName, fullName); + StringCchCopyW(lfw.lfFaceName, LF_FACESIZE, fullName); lfw.lfCharSet = DEFAULT_CHARSET; EnumFontFamiliesExW(screenDC, &lfw, (FONTENUMPROCW)CheckFontFamilyProcW, @@ -349,7 +350,7 @@ static int CALLBACK EnumFamilyNamesW( } memset(&lfw, 0, sizeof(lfw)); - wcscpy(lfw.lfFaceName, lpelfe->elfLogFont.lfFaceName); + StringCchCopyW(lfw.lfFaceName, LF_FACESIZE, lpelfe->elfLogFont.lfFaceName); lfw.lfCharSet = lpelfe->elfLogFont.lfCharSet; EnumFontFamiliesExW(screenDC, &lfw, (FONTENUMPROCW)EnumFontFacesInFamilyProcW, @@ -653,7 +654,7 @@ Java_sun_awt_Win32FontManager_populateFontFileNameMap0 /* Enumerate fonts via GDI to build maps of fonts and families */ memset(&lfw, 0, sizeof(lfw)); lfw.lfCharSet = DEFAULT_CHARSET; /* all charsets */ - wcscpy(lfw.lfFaceName, L""); /* one face per family (CHECK) */ + StringCchCopyW(lfw.lfFaceName, LF_FACESIZE, L""); /* one face per family (CHECK) */ EnumFontFamiliesExW(screenDC, &lfw, (FONTENUMPROCW)EnumFamilyNamesW, (LPARAM)(&fmi), 0L); diff --git a/src/java.desktop/windows/native/libfontmanager/lcdglyph.c b/src/java.desktop/windows/native/libfontmanager/lcdglyph.c index c63d96c301c..cc1ae59cbe7 100644 --- a/src/java.desktop/windows/native/libfontmanager/lcdglyph.c +++ b/src/java.desktop/windows/native/libfontmanager/lcdglyph.c @@ -48,6 +48,7 @@ #include #include #include +#include #include #include @@ -245,7 +246,7 @@ Java_sun_font_FileFontStrike__1getGlyphImageFromWindows name[nameLen] = '\0'; if (nameLen < (sizeof(lf.lfFaceName) / sizeof(lf.lfFaceName[0]))) { - wcscpy(lf.lfFaceName, name); + StringCchCopyW(lf.lfFaceName, LF_FACESIZE, name); } else { FREE_AND_RETURN; }