提交 eb95e6fb 编写于 作者: B bagiras

7064312: Cleanup: avoid using unsafe string function

Reviewed-by: serb, pchelko
上级 362a5308
/*
* Copyright (c) 1996, 2010, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 1996, 2013, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
......@@ -73,7 +73,7 @@ AwtFileDialog::Initialize(JNIEnv *env, jstring filterDescription)
int length = env->GetStringLength(filterDescription);
DASSERT(length + 1 < MAX_FILTER_STRING);
LPCTSTR tmp = JNU_GetStringPlatformChars(env, filterDescription, NULL);
_tcscpy(s_fileFilterString, tmp);
_tcscpy_s(s_fileFilterString, MAX_FILTER_STRING, tmp);
JNU_ReleaseStringPlatformChars(env, filterDescription, tmp);
//AdditionalString should be terminated by two NULL characters (Windows
......@@ -353,7 +353,7 @@ AwtFileDialog::Show(void *p)
if (!result) {
dlgerr = ::CommDlgExtendedError();
if (dlgerr == FNERR_INVALIDFILENAME) {
_tcscpy(fileBuffer, TEXT(""));
_tcscpy_s(fileBuffer, bufferLimit, TEXT(""));
if (mode == java_awt_FileDialog_LOAD) {
result = AwtFileDialog::GetOpenFileName(&ofn);
} else {
......
/*
* Copyright (c) 1996, 2010, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 1996, 2013, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
......@@ -366,17 +366,6 @@ AwtFont* AwtFont::Create(JNIEnv *env, jobject font, jint angle, jfloat awScale)
return awtFont;
}
int CALLBACK FindFamilyName (ENUMLOGFONTEX *lpelfe,
NEWTEXTMETRICEX *lpntme, int FontType, LPARAM lParam)
{
if(_tcsstr((LPTSTR)lParam, lpelfe->elfLogFont.lfFaceName)) {
_tcscpy((LPTSTR)lParam, lpelfe->elfLogFont.lfFaceName);
return 0;
} else {
return 1;
}
}
static void strip_tail(wchar_t* text, wchar_t* tail) { // strips tail and any possible whitespace before it from the end of text
if (wcslen(text)<=wcslen(tail)) {
return;
......
/*
* Copyright (c) 1999, 2008, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 1999, 2013, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
......@@ -422,17 +422,17 @@ BOOL AwtPrintControl::CreateDevModeAndDevNames(PRINTDLG *ppd,
devnames->wOutputOffset =
static_cast<WORD>(sizeof(DEVNAMES)/sizeof(TCHAR) + lenDriverName + lenPrinterName);
if (info2->pDriverName != NULL) {
_tcscpy(lpcDevnames + devnames->wDriverOffset, info2->pDriverName);
_tcscpy_s(lpcDevnames + devnames->wDriverOffset, devnameSize - devnames->wDriverOffset, info2->pDriverName);
} else {
*(lpcDevnames + devnames->wDriverOffset) = _T('\0');
}
if (pPrinterName != NULL) {
_tcscpy(lpcDevnames + devnames->wDeviceOffset, pPrinterName);
_tcscpy_s(lpcDevnames + devnames->wDeviceOffset, devnameSize - devnames->wDeviceOffset, pPrinterName);
} else {
*(lpcDevnames + devnames->wDeviceOffset) = _T('\0');
}
if (info2->pPortName != NULL) {
_tcscpy(lpcDevnames + devnames->wOutputOffset, info2->pPortName);
_tcscpy_s(lpcDevnames + devnames->wOutputOffset, devnameSize - devnames->wOutputOffset, info2->pPortName);
} else {
*(lpcDevnames + devnames->wOutputOffset) = _T('\0');
}
......
......@@ -228,7 +228,7 @@ BOOL AwtToolkit::activateKeyboardLayout(HKL hkl) {
// create input locale string, e.g., "00000409", from hkl.
TCHAR inputLocale[9];
TCHAR buf[9];
_tcscpy(inputLocale, TEXT("00000000"));
_tcscpy_s(inputLocale, 9, TEXT("00000000"));
// 64-bit: ::LoadKeyboardLayout() is such a weird API - a string of
// the hex value you want?! Here we're converting our HKL value to
......
/*
* Copyright (c) 2005, 2011, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2005, 2013, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
......@@ -711,7 +711,7 @@ void AwtTrayIcon::SetToolTip(LPCTSTR tooltip)
_tcsncpy(m_nid.szTip, tooltip, TRAY_ICON_TOOLTIP_MAX_SIZE);
m_nid.szTip[TRAY_ICON_TOOLTIP_MAX_SIZE - 1] = '\0';
} else {
_tcscpy(m_nid.szTip, tooltip);
_tcscpy_s(m_nid.szTip, TRAY_ICON_TOOLTIP_MAX_SIZE, tooltip);
}
SendTrayMessage(NIM_MODIFY);
......@@ -817,7 +817,7 @@ void AwtTrayIcon::DisplayMessage(LPCTSTR caption, LPCTSTR text, LPCTSTR msgType)
m_nid.szInfoTitle[TRAY_ICON_BALLOON_TITLE_MAX_SIZE - 1] = '\0';
} else {
_tcscpy(m_nid.szInfoTitle, caption);
_tcscpy_s(m_nid.szInfoTitle, TRAY_ICON_BALLOON_TITLE_MAX_SIZE, caption);
}
if (text[0] == '\0') {
......@@ -830,7 +830,7 @@ void AwtTrayIcon::DisplayMessage(LPCTSTR caption, LPCTSTR text, LPCTSTR msgType)
m_nid.szInfo[TRAY_ICON_BALLOON_INFO_MAX_SIZE - 1] = '\0';
} else {
_tcscpy(m_nid.szInfo, text);
_tcscpy_s(m_nid.szInfo, TRAY_ICON_BALLOON_INFO_MAX_SIZE, text);
}
SendTrayMessage(NIM_MODIFY);
......
......@@ -70,7 +70,7 @@ namespace SUN_DBG_NS{
bErrorReport?_T("Error:"):_T(""),
szBuffer) < 0)
{
_tcscpy(szBuffer1 + DTRACE_BUF_LEN - 5, _T("...")); //reserver for \n
_tcscpy_s(szBuffer1 + DTRACE_BUF_LEN - 5, 5, _T("...")); //reserver for \n
}
memcpy(szBuffer1, szTime, iTimeLen*sizeof(TCHAR));
_tcscat(szBuffer1, _T("\n"));
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册