Commit 6e3bcb5a authored by Peter Berg Larsen's avatar Peter Berg Larsen Committed by Alexandre Julliard

Replace strncpy with memcpy or lstrcpyn.

parent 71be0944
......@@ -387,7 +387,7 @@ static void TOOLTIPS_GetDispInfoW(HWND hwnd, TOOLTIPS_INFO *infoPtr, TTTOOL_INFO
else if (ttnmdi.lpszText != LPSTR_TEXTCALLBACKW) {
INT max_len = (ttnmdi.lpszText == &ttnmdi.szText[0]) ?
sizeof(ttnmdi.szText)/sizeof(ttnmdi.szText[0]) : INFOTIPSIZE-1;
strncpyW(infoPtr->szTipText, ttnmdi.lpszText, max_len);
lstrcpynW(infoPtr->szTipText, ttnmdi.lpszText, max_len);
if (ttnmdi.uFlags & TTF_DI_SETITEM) {
INT len = max(strlenW(ttnmdi.lpszText), max_len);
toolPtr->hinst = 0;
......
......@@ -2065,7 +2065,7 @@ BOOL FILEDLG95_OnOpen(HWND hwnd)
if(fodInfos->unicode)
{
LPOPENFILENAMEW ofn = fodInfos->ofnInfos;
strncpyW(ofn->lpstrFileTitle, lpstrFileTitle, ofn->nMaxFileTitle);
lstrcpynW(ofn->lpstrFileTitle, lpstrFileTitle, ofn->nMaxFileTitle);
}
else
{
......
......@@ -94,6 +94,7 @@ static HRESULT WINAPI DEVENUM_IParseDisplayName_ParseDisplayName(
MediaCatMoniker * pMoniker = NULL;
CLSID clsidDevice;
HRESULT res = S_OK;
int classlen;
TRACE("(%p, %s, %p, %p)\n", pbc, debugstr_w(pszDisplayName), pchEaten, ppmkOut);
......@@ -107,12 +108,13 @@ static HRESULT WINAPI DEVENUM_IParseDisplayName_ParseDisplayName(
/* size = pszBetween - pszDisplayName - 1 (for '\\' after CLSID)
* + 1 (for NULL character)
*/
pszClass = CoTaskMemAlloc((int)(pszBetween - pszDisplayName) * sizeof(WCHAR));
classlen = (int)(pszBetween - pszDisplayName - 1);
pszClass = CoTaskMemAlloc((classlen + 1) * sizeof(WCHAR));
if (!pszClass)
return E_OUTOFMEMORY;
strncpyW(pszClass, pszDisplayName, (int)(pszBetween - pszDisplayName) - 1);
pszClass[(int)(pszBetween - pszDisplayName) - 1] = 0;
memcpy(pszClass, pszDisplayName, classlen * sizeof(WCHAR));
pszClass[classlen] = 0;
TRACE("Device CLSID: %s\n", debugstr_w(pszClass));
......
......@@ -163,11 +163,11 @@ HRESULT WINAPI IDirectMusicBandImpl_IDirectMusicObject_SetDescriptor (LPDIRECTMU
if (pDesc->dwValidData & DMUS_OBJ_CLASS)
memcpy (&This->pDesc->guidClass, &pDesc->guidClass, sizeof (pDesc->guidClass));
if (pDesc->dwValidData & DMUS_OBJ_NAME)
strncpyW (This->pDesc->wszName, pDesc->wszName, DMUS_MAX_NAME);
lstrcpynW (This->pDesc->wszName, pDesc->wszName, DMUS_MAX_NAME);
if (pDesc->dwValidData & DMUS_OBJ_CATEGORY)
strncpyW (This->pDesc->wszCategory, pDesc->wszCategory, DMUS_MAX_CATEGORY);
lstrcpynW (This->pDesc->wszCategory, pDesc->wszCategory, DMUS_MAX_CATEGORY);
if (pDesc->dwValidData & DMUS_OBJ_FILENAME)
strncpyW (This->pDesc->wszFileName, pDesc->wszFileName, DMUS_MAX_FILENAME);
lstrcpynW (This->pDesc->wszFileName, pDesc->wszFileName, DMUS_MAX_FILENAME);
if (pDesc->dwValidData & DMUS_OBJ_VERSION)
memcpy (&This->pDesc->vVersion, &pDesc->vVersion, sizeof (pDesc->vVersion));
if (pDesc->dwValidData & DMUS_OBJ_DATE)
......
......@@ -147,11 +147,11 @@ HRESULT WINAPI IDirectMusicChordMapImpl_IDirectMusicObject_SetDescriptor (LPDIRE
if (pDesc->dwValidData & DMUS_OBJ_CLASS)
memcpy (&This->pDesc->guidClass, &pDesc->guidClass, sizeof (pDesc->guidClass));
if (pDesc->dwValidData & DMUS_OBJ_NAME)
strncpyW (This->pDesc->wszName, pDesc->wszName, DMUS_MAX_NAME);
lstrcpynW (This->pDesc->wszName, pDesc->wszName, DMUS_MAX_NAME);
if (pDesc->dwValidData & DMUS_OBJ_CATEGORY)
strncpyW (This->pDesc->wszCategory, pDesc->wszCategory, DMUS_MAX_CATEGORY);
lstrcpynW (This->pDesc->wszCategory, pDesc->wszCategory, DMUS_MAX_CATEGORY);
if (pDesc->dwValidData & DMUS_OBJ_FILENAME)
strncpyW (This->pDesc->wszFileName, pDesc->wszFileName, DMUS_MAX_FILENAME);
lstrcpynW (This->pDesc->wszFileName, pDesc->wszFileName, DMUS_MAX_FILENAME);
if (pDesc->dwValidData & DMUS_OBJ_VERSION)
memcpy (&This->pDesc->vVersion, &pDesc->vVersion, sizeof (pDesc->vVersion));
if (pDesc->dwValidData & DMUS_OBJ_DATE)
......
......@@ -262,11 +262,11 @@ HRESULT WINAPI IDirectMusicAudioPathImpl_IDirectMusicObject_SetDescriptor (LPDIR
if (pDesc->dwValidData & DMUS_OBJ_CLASS)
memcpy (&This->pDesc->guidClass, &pDesc->guidClass, sizeof (pDesc->guidClass));
if (pDesc->dwValidData & DMUS_OBJ_NAME)
strncpyW (This->pDesc->wszName, pDesc->wszName, DMUS_MAX_NAME);
lstrcpynW (This->pDesc->wszName, pDesc->wszName, DMUS_MAX_NAME);
if (pDesc->dwValidData & DMUS_OBJ_CATEGORY)
strncpyW (This->pDesc->wszCategory, pDesc->wszCategory, DMUS_MAX_CATEGORY);
lstrcpynW (This->pDesc->wszCategory, pDesc->wszCategory, DMUS_MAX_CATEGORY);
if (pDesc->dwValidData & DMUS_OBJ_FILENAME)
strncpyW (This->pDesc->wszFileName, pDesc->wszFileName, DMUS_MAX_FILENAME);
lstrcpynW (This->pDesc->wszFileName, pDesc->wszFileName, DMUS_MAX_FILENAME);
if (pDesc->dwValidData & DMUS_OBJ_VERSION)
memcpy (&This->pDesc->vVersion, &pDesc->vVersion, sizeof (pDesc->vVersion));
if (pDesc->dwValidData & DMUS_OBJ_DATE)
......
......@@ -228,11 +228,11 @@ HRESULT WINAPI IDirectMusicGraphImpl_IDirectMusicObject_SetDescriptor (LPDIRECTM
if (pDesc->dwValidData & DMUS_OBJ_CLASS)
memcpy (&This->pDesc->guidClass, &pDesc->guidClass, sizeof (pDesc->guidClass));
if (pDesc->dwValidData & DMUS_OBJ_NAME)
strncpyW (This->pDesc->wszName, pDesc->wszName, DMUS_MAX_NAME);
lstrcpynW (This->pDesc->wszName, pDesc->wszName, DMUS_MAX_NAME);
if (pDesc->dwValidData & DMUS_OBJ_CATEGORY)
strncpyW (This->pDesc->wszCategory, pDesc->wszCategory, DMUS_MAX_CATEGORY);
lstrcpynW (This->pDesc->wszCategory, pDesc->wszCategory, DMUS_MAX_CATEGORY);
if (pDesc->dwValidData & DMUS_OBJ_FILENAME)
strncpyW (This->pDesc->wszFileName, pDesc->wszFileName, DMUS_MAX_FILENAME);
lstrcpynW (This->pDesc->wszFileName, pDesc->wszFileName, DMUS_MAX_FILENAME);
if (pDesc->dwValidData & DMUS_OBJ_VERSION)
memcpy (&This->pDesc->vVersion, &pDesc->vVersion, sizeof (pDesc->vVersion));
if (pDesc->dwValidData & DMUS_OBJ_DATE)
......
......@@ -548,11 +548,11 @@ HRESULT WINAPI IDirectMusicSegment8Impl_IDirectMusicObject_SetDescriptor (LPDIRE
if (pDesc->dwValidData & DMUS_OBJ_CLASS)
memcpy (&This->pDesc->guidClass, &pDesc->guidClass, sizeof (pDesc->guidClass));
if (pDesc->dwValidData & DMUS_OBJ_NAME)
strncpyW (This->pDesc->wszName, pDesc->wszName, DMUS_MAX_NAME);
lstrcpynW (This->pDesc->wszName, pDesc->wszName, DMUS_MAX_NAME);
if (pDesc->dwValidData & DMUS_OBJ_CATEGORY)
strncpyW (This->pDesc->wszCategory, pDesc->wszCategory, DMUS_MAX_CATEGORY);
lstrcpynW (This->pDesc->wszCategory, pDesc->wszCategory, DMUS_MAX_CATEGORY);
if (pDesc->dwValidData & DMUS_OBJ_FILENAME)
strncpyW (This->pDesc->wszFileName, pDesc->wszFileName, DMUS_MAX_FILENAME);
lstrcpynW (This->pDesc->wszFileName, pDesc->wszFileName, DMUS_MAX_FILENAME);
if (pDesc->dwValidData & DMUS_OBJ_VERSION)
memcpy (&This->pDesc->vVersion, &pDesc->vVersion, sizeof (pDesc->vVersion));
if (pDesc->dwValidData & DMUS_OBJ_DATE)
......
......@@ -67,7 +67,7 @@ HRESULT WINAPI IDirectMusicLoaderFileStream_Attach (LPSTREAM iface, LPCWSTR wzFi
}
/* create IDirectMusicGetLoader */
This->pLoader = (LPDIRECTMUSICLOADER8)pLoader;
strncpyW (This->wzFileName, wzFile, MAX_PATH);
lstrcpynW (This->wzFileName, wzFile, MAX_PATH);
TRACE(": succeeded\n");
return S_OK;
}
......
......@@ -226,11 +226,11 @@ HRESULT WINAPI IDirectMusicScriptImpl_IDirectMusicObject_SetDescriptor (LPDIRECT
if (pDesc->dwValidData & DMUS_OBJ_CLASS)
memcpy (&This->pDesc->guidClass, &pDesc->guidClass, sizeof (pDesc->guidClass));
if (pDesc->dwValidData & DMUS_OBJ_NAME)
strncpyW (This->pDesc->wszName, pDesc->wszName, DMUS_MAX_NAME);
lstrcpynW (This->pDesc->wszName, pDesc->wszName, DMUS_MAX_NAME);
if (pDesc->dwValidData & DMUS_OBJ_CATEGORY)
strncpyW (This->pDesc->wszCategory, pDesc->wszCategory, DMUS_MAX_CATEGORY);
lstrcpynW (This->pDesc->wszCategory, pDesc->wszCategory, DMUS_MAX_CATEGORY);
if (pDesc->dwValidData & DMUS_OBJ_FILENAME)
strncpyW (This->pDesc->wszFileName, pDesc->wszFileName, DMUS_MAX_FILENAME);
lstrcpynW (This->pDesc->wszFileName, pDesc->wszFileName, DMUS_MAX_FILENAME);
if (pDesc->dwValidData & DMUS_OBJ_VERSION)
memcpy (&This->pDesc->vVersion, &pDesc->vVersion, sizeof (pDesc->vVersion));
if (pDesc->dwValidData & DMUS_OBJ_DATE)
......
......@@ -230,11 +230,11 @@ HRESULT WINAPI IDirectMusicStyle8Impl_IDirectMusicObject_SetDescriptor (LPDIRECT
if (pDesc->dwValidData & DMUS_OBJ_CLASS)
memcpy (&This->pDesc->guidClass, &pDesc->guidClass, sizeof (pDesc->guidClass));
if (pDesc->dwValidData & DMUS_OBJ_NAME)
strncpyW (This->pDesc->wszName, pDesc->wszName, DMUS_MAX_NAME);
lstrcpynW (This->pDesc->wszName, pDesc->wszName, DMUS_MAX_NAME);
if (pDesc->dwValidData & DMUS_OBJ_CATEGORY)
strncpyW (This->pDesc->wszCategory, pDesc->wszCategory, DMUS_MAX_CATEGORY);
lstrcpynW (This->pDesc->wszCategory, pDesc->wszCategory, DMUS_MAX_CATEGORY);
if (pDesc->dwValidData & DMUS_OBJ_FILENAME)
strncpyW (This->pDesc->wszFileName, pDesc->wszFileName, DMUS_MAX_FILENAME);
lstrcpynW (This->pDesc->wszFileName, pDesc->wszFileName, DMUS_MAX_FILENAME);
if (pDesc->dwValidData & DMUS_OBJ_VERSION)
memcpy (&This->pDesc->vVersion, &pDesc->vVersion, sizeof (pDesc->vVersion));
if (pDesc->dwValidData & DMUS_OBJ_DATE)
......
......@@ -2319,7 +2319,7 @@ GetCharacterPlacementW(
/* Treat the case where no special handling was requested in a fastpath way */
/* copy will do if the GCP_REORDER flag is not set */
if(lpResults->lpOutString)
strncpyW( lpResults->lpOutString, lpString, nSet );
memcpy( lpResults->lpOutString, lpString, nSet * sizeof(WCHAR));
if(lpResults->lpOrder)
{
......
......@@ -2044,13 +2044,13 @@ static void GetEnumStructs(Face *face, LPENUMLOGFONTEXW pelf,
if(potm) {
pntm->ntmTm.ntmSizeEM = potm->otmEMSquare;
strncpyW(pelf->elfLogFont.lfFaceName,
lstrcpynW(pelf->elfLogFont.lfFaceName,
(WCHAR*)((char*)potm + (ptrdiff_t)potm->otmpFamilyName),
LF_FACESIZE);
strncpyW(pelf->elfFullName,
lstrcpynW(pelf->elfFullName,
(WCHAR*)((char*)potm + (ptrdiff_t)potm->otmpFaceName),
LF_FULLFACESIZE);
strncpyW(pelf->elfStyle,
lstrcpynW(pelf->elfStyle,
(WCHAR*)((char*)potm + (ptrdiff_t)potm->otmpStyleName),
LF_FACESIZE);
......@@ -2058,8 +2058,8 @@ static void GetEnumStructs(Face *face, LPENUMLOGFONTEXW pelf,
} else {
pntm->ntmTm.ntmSizeEM = pntm->ntmTm.tmHeight - pntm->ntmTm.tmInternalLeading;
strncpyW(pelf->elfLogFont.lfFaceName, face->family->FamilyName, LF_FACESIZE);
strncpyW(pelf->elfFullName, face->family->FamilyName, LF_FACESIZE);
lstrcpynW(pelf->elfLogFont.lfFaceName, face->family->FamilyName, LF_FACESIZE);
lstrcpynW(pelf->elfFullName, face->family->FamilyName, LF_FACESIZE);
pelf->elfStyle[0] = '\0';
}
......
......@@ -1538,7 +1538,7 @@ int chm_enumerate_dir(struct chmFile *h,
curPage = h->index_head;
/* initialize pathname state */
strncpyW(prefixRectified, prefix, CHM_MAX_PATHLEN);
lstrcpynW(prefixRectified, prefix, CHM_MAX_PATHLEN);
prefixLen = strlenW(prefixRectified);
if (prefixLen != 0)
{
......
......@@ -701,7 +701,7 @@ static LPWSTR COND_GetString( struct cond_str *str )
ret = HeapAlloc( GetProcessHeap(), 0, (str->len+1) * sizeof (WCHAR) );
if( ret )
{
strncpyW( ret, str->data, str->len );
memcpy( ret, str->data, str->len * sizeof(WCHAR));
ret[str->len]=0;
}
TRACE("Got identifier %s\n",debugstr_w(ret));
......
......@@ -372,7 +372,7 @@ char* MSVCRT_setlocale(int category, const char* locale)
if (next && next != locale)
{
haveLang = 1;
strncpy(lc.search_language,locale,next-locale);
memcpy(lc.search_language,locale,next-locale);
locale += next-locale+1;
}
......@@ -383,23 +383,23 @@ char* MSVCRT_setlocale(int category, const char* locale)
if (next == locale)
{
locale++;
strncpy(lc.search_codepage, locale, MAX_ELEM_LEN);
lstrcpynA(lc.search_codepage, locale, MAX_ELEM_LEN);
}
else
{
if (haveLang)
{
haveCountry = 1;
strncpy(lc.search_country,locale,next-locale);
memcpy(lc.search_country,locale,next-locale);
locale += next-locale+1;
}
else
{
haveLang = 1;
strncpy(lc.search_language,locale,next-locale);
memcpy(lc.search_language,locale,next-locale);
locale += next-locale+1;
}
strncpy(lc.search_codepage, locale, MAX_ELEM_LEN);
lstrcpynA(lc.search_codepage, locale, MAX_ELEM_LEN);
}
}
else
......@@ -407,12 +407,12 @@ char* MSVCRT_setlocale(int category, const char* locale)
if (haveLang)
{
haveCountry = 1;
strncpy(lc.search_country, locale, MAX_ELEM_LEN);
lstrcpynA(lc.search_country, locale, MAX_ELEM_LEN);
}
else
{
haveLang = 1;
strncpy(lc.search_language, locale, MAX_ELEM_LEN);
lstrcpynA(lc.search_language, locale, MAX_ELEM_LEN);
}
}
......
......@@ -1010,7 +1010,7 @@ end_of_mci_open:
return mwi->lasterror;
case MCIWNDM_RETURNSTRINGW:
strncpyW((LPWSTR)lParam, mwi->return_string, wParam);
lstrcpynW((LPWSTR)lParam, mwi->return_string, wParam);
TRACE("MCIWNDM_RETURNTRINGW %s\n", debugstr_wn((LPWSTR)lParam, wParam));
return mwi->lasterror;
......@@ -1095,7 +1095,7 @@ end_of_mci_open:
case MCIWNDM_GETFILENAMEW:
TRACE("MCIWNDM_GETFILENAMEW: %s\n", debugstr_w(mwi->lpName));
if (mwi->lpName)
strncpyW((LPWSTR)lParam, mwi->lpName, wParam);
lstrcpynW((LPWSTR)lParam, mwi->lpName, wParam);
return 0;
case MCIWNDM_GETTIMEFORMATA:
......
......@@ -834,7 +834,7 @@ DWORD WINAPI VideoCapDriverDescAndVer16(WORD nr, LPSTR buf1, WORD buf1len,
else
{
TRACE("GetFileVersionInfoA failed for %s.\n", fn);
strncpy(buf2, fn, buf2len); /* msvideo.dll appears to copy fn*/
lstrcpynA(buf2, fn, buf2len); /* msvideo.dll appears to copy fn*/
}
/* FIXME: language problem? */
if (VerQueryValueA( infobuf,
......@@ -843,13 +843,15 @@ DWORD WINAPI VideoCapDriverDescAndVer16(WORD nr, LPSTR buf1, WORD buf1len,
&subblocklen
))
{
UINT copylen = min(subblocklen,buf1len-1);
memcpy(buf1, subblock, copylen);
buf1[copylen] = '\0';
TRACE("VQA returned %s\n", (LPCSTR)subblock);
strncpy(buf1, subblock, buf1len);
}
else
{
TRACE("VQA did not return on query \\StringFileInfo\\040904E4\\FileDescription?\n");
strncpy(buf1, fn, buf1len); /* msvideo.dll appears to copy fn*/
lstrcpynA(buf1, fn, buf1len); /* msvideo.dll appears to copy fn*/
}
HeapFree(GetProcessHeap(), 0, infobuf);
return 0;
......
......@@ -479,7 +479,7 @@ static BOOL UIINSERTOBJECTDLG_OnOpen(InsertObjectDlgInfo* pdlgInfo)
WCHAR wcsFile[MAX_PATH];
SendMessageA(pdlgInfo->hwndFileTB, WM_GETTEXT, (WPARAM)MAX_PATH, (LPARAM)fname);
strncpy(pdlgInfo->lpOleUIInsertObject->lpszFile, fname, pdlgInfo->lpOleUIInsertObject->cchFile);
lstrcpynA(pdlgInfo->lpOleUIInsertObject->lpszFile, fname, pdlgInfo->lpOleUIInsertObject->cchFile);
RtlMultiByteToUnicodeN(wcsFile, MAX_PATH, NULL, fname, MAX_PATH);
if (ERROR_SUCCESS == (hres = GetClassFile(wcsFile, &pdlgInfo->lpOleUIInsertObject->clsid)))
......
......@@ -732,7 +732,7 @@ static HRESULT WINAPI FilterMapper2_RegisterFilter(
if (SUCCEEDED(hr))
{
strncpyW(pCurrent, szClsidTemp, CHARS_IN_GUID);
memcpy(pCurrent, szClsidTemp, CHARS_IN_GUID * sizeof(WCHAR));
pCurrent += CHARS_IN_GUID - 1;
pCurrent[0] = '\\';
......
......@@ -159,13 +159,13 @@ DWORD _dbg_ILSimpleGetText (LPCITEMIDLIST pidl, LPSTR szOut, UINT uOutSize)
if (_dbg_ILIsDesktop(pidl))
{
/* desktop */
if (szOut) strncpy(szOut, "Desktop", uOutSize);
if (szOut) lstrcpynA(szOut, "Desktop", uOutSize);
dwReturn = strlen ("Desktop");
}
else if (( szSrc = _dbg_ILGetTextPointer(pidl) ))
{
/* filesystem */
if (szOut) strncpy(szOut, szSrc, uOutSize);
if (szOut) lstrcpynA(szOut, szSrc, uOutSize);
dwReturn = strlen(szSrc);
}
else if (( riid = _dbg_ILGetGUIDPointer(pidl) ))
......
......@@ -909,7 +909,7 @@ static HRESULT Stream_WriteAdvertiseInfo( IStream* stm, LPCWSTR string, DWORD ma
memset( &buffer, 0, sizeof buffer );
buffer.dbh.cbSize = sizeof buffer;
buffer.dbh.dwSignature = magic;
strncpyW( buffer.szwDarwinID, string, MAX_PATH );
lstrcpynW( buffer.szwDarwinID, string, MAX_PATH );
WideCharToMultiByte(CP_ACP, 0, string, -1, buffer.szDarwinID, MAX_PATH, NULL, NULL );
return IStream_Write( stm, &buffer, buffer.dbh.cbSize, &count );
......
......@@ -1210,7 +1210,7 @@ static HRESULT _SHGetUserShellFolderPath(HKEY rootKey, LPCWSTR userPrefix,
WCHAR szTemp[MAX_PATH];
_SHExpandEnvironmentStrings(path, szTemp);
strncpyW(path, szTemp, MAX_PATH);
lstrcpynW(path, szTemp, MAX_PATH);
}
ret = RegSetValueExW(shellFolderKey, value, 0, REG_SZ, (LPBYTE)path,
(strlenW(path) + 1) * sizeof(WCHAR));
......@@ -1493,12 +1493,12 @@ static HRESULT _SHGetProfilesValue(HKEY profilesKey, LPCWSTR szValueName,
else
{
/* Missing or invalid value, set a default */
strncpyW(szValue, szDefault, MAX_PATH);
szValue[MAX_PATH - 1] = '\0';
lstrcpynW(szValue, szDefault, MAX_PATH);
TRACE("Setting missing value %s to %s\n", debugstr_w(szValueName),
debugstr_w(szValue));
debugstr_w(szValue));
lRet = RegSetValueExW(profilesKey, szValueName, 0, REG_EXPAND_SZ,
(LPBYTE)szValue, (strlenW(szValue) + 1) * sizeof(WCHAR));
(LPBYTE)szValue,
(strlenW(szValue) + 1) * sizeof(WCHAR));
if (lRet)
hr = HRESULT_FROM_WIN32(lRet);
else
......
......@@ -1218,7 +1218,7 @@ BOOL WINAPI ShellExecuteExW32 (LPSHELLEXECUTEINFOW sei, SHELL_ExecuteW32 execfun
LPWSTR beg = wszApplicationName/*sei_tmp.lpFile*/;
for(s=beg; (space=strchrW(s, ' ')); s=space+1) {
int idx = space-sei_tmp.lpFile;
strncpyW(buffer, sei_tmp.lpFile, idx);
memcpy(buffer, sei_tmp.lpFile, idx * sizeof(WCHAR));
buffer[idx] = '\0';
/*FIXME This finds directory paths if the targeted file name contains spaces. */
......@@ -1296,7 +1296,7 @@ BOOL WINAPI ShellExecuteExW32 (LPSHELLEXECUTEINFOW sei, SHELL_ExecuteW32 execfun
TRACE("Got URL: %s\n", debugstr_w(lpFile));
/* Looking for ...protocol\shell\lpOperation\command */
strncpyW(lpstrProtocol, lpFile, iSize);
memcpy(lpstrProtocol, lpFile, iSize*sizeof(WCHAR));
lpstrProtocol[iSize] = '\0';
strcatW(lpstrProtocol, wShell);
strcatW(lpstrProtocol, sei_tmp.lpVerb? sei_tmp.lpVerb: wszOpen);
......
......@@ -256,8 +256,7 @@ void SYSTRAY_ItemSetTip(SystrayItem *ptrayItem, CHAR* szTip, int modify)
{
TTTOOLINFOA ti;
strncpy(ptrayItem->notifyIcon.szTip, szTip, sizeof(ptrayItem->notifyIcon.szTip));
ptrayItem->notifyIcon.szTip[sizeof(ptrayItem->notifyIcon.szTip)-1]=0;
lstrcpynA(ptrayItem->notifyIcon.szTip, szTip, sizeof(ptrayItem->notifyIcon.szTip));
ti.cbSize = sizeof(TTTOOLINFOA);
ti.uFlags = 0;
......
......@@ -3052,7 +3052,7 @@ static void EDIT_EM_ReplaceSel(EDITSTATE *es, BOOL can_undo, LPCWSTR lpsz_replac
bufl = e - s;
buf = HeapAlloc(GetProcessHeap(), 0, (bufl + 1) * sizeof(WCHAR));
if (!buf) return;
strncpyW(buf, es->text + s, bufl);
memcpy(buf, es->text + s, bufl * sizeof(WCHAR));
buf[bufl] = 0; /* ensure 0 termination */
/* now delete */
strcpyW(es->text + s, es->text + e);
......@@ -3113,7 +3113,7 @@ static void EDIT_EM_ReplaceSel(EDITSTATE *es, BOOL can_undo, LPCWSTR lpsz_replac
if (!es->undo_insert_count && (*es->undo_text && (s == es->undo_position))) {
/* undo-buffer is extended to the right */
EDIT_MakeUndoFit(es, utl + e - s);
strncpyW(es->undo_text + utl, buf, e - s + 1);
memcpy(es->undo_text + utl, buf, (e - s)*sizeof(WCHAR));
(es->undo_text + utl)[e - s] = 0; /* ensure 0 termination */
} else if (!es->undo_insert_count && (*es->undo_text && (e == es->undo_position))) {
/* undo-buffer is extended to the left */
......@@ -3126,7 +3126,7 @@ static void EDIT_EM_ReplaceSel(EDITSTATE *es, BOOL can_undo, LPCWSTR lpsz_replac
} else {
/* new undo-buffer */
EDIT_MakeUndoFit(es, e - s);
strncpyW(es->undo_text, buf, e - s + 1);
memcpy(es->undo_text, buf, (e - s)*sizeof(WCHAR));
es->undo_text[e - s] = 0; /* ensure 0 termination */
es->undo_position = s;
}
......@@ -3932,13 +3932,15 @@ static void EDIT_WM_Copy(EDITSTATE *es)
INT e = max(es->selection_start, es->selection_end);
HGLOBAL hdst;
LPWSTR dst;
DWORD len;
if (e == s) return;
hdst = GlobalAlloc(GMEM_MOVEABLE | GMEM_DDESHARE, (DWORD)(e - s + 1) * sizeof(WCHAR));
len = e - s;
hdst = GlobalAlloc(GMEM_MOVEABLE | GMEM_DDESHARE, (len + 1) * sizeof(WCHAR));
dst = GlobalLock(hdst);
strncpyW(dst, es->text + s, e - s);
dst[e - s] = 0; /* ensure 0 termination */
memcpy(dst, es->text + s, len * sizeof(WCHAR));
dst[len] = 0; /* ensure 0 termination */
TRACE("%s\n", debugstr_w(dst));
GlobalUnlock(hdst);
OpenClipboard(es->hwndSelf);
......
......@@ -3434,7 +3434,7 @@ static int INT21_GetDiskSerialNumber( CONTEXT86 *context )
*(WORD *)dataptr = 0;
memcpy(dataptr + 2, &serial, sizeof(DWORD));
WideCharToMultiByte(CP_OEMCP, 0, label, 11, dataptr + 6, 11, NULL, NULL);
strncpy(dataptr + 17, "FAT16 ", 8);
memcpy(dataptr + 17, "FAT16 ", 8);
return 1;
}
......
......@@ -76,7 +76,7 @@ static BOOL WININET_GetProxyServer( HINTERNET hRequest, LPWSTR szBuf, DWORD sz )
if (NULL == hIC)
return FALSE;
strncpyW(szBuf, hIC->lpszProxy, sz);
lstrcpynW(szBuf, hIC->lpszProxy, sz);
/* FIXME: perhaps it would be better to use InternetCrackUrl here */
p = strchrW(szBuf, ':');
......
......@@ -1195,6 +1195,13 @@ static INTERNET_SCHEME GetInternetSchemeW(LPCWSTR lpszScheme, DWORD nMaxCmp)
*
* Helper function for InternetCrackUrlW
*
* PARAMS
* lppszComponent [O] Holds the returned string
* dwComponentLen [I] Holds the size of lppszComponent
* [O] Holds the length of the string in lppszComponent without '\0'
* lpszStart [I] Holds the string to copy from
* len [I] Holds the length of lpszStart without '\0'
*
* RETURNS
* TRUE on success
* FALSE on failure
......@@ -1217,7 +1224,7 @@ static BOOL SetUrlComponentValueW(LPWSTR* lppszComponent, LPDWORD dwComponentLen
else
{
DWORD ncpylen = min((*dwComponentLen)-1, len);
strncpyW(*lppszComponent, lpszStart, ncpylen);
memcpy(*lppszComponent, lpszStart, ncpylen*sizeof(WCHAR));
(*lppszComponent)[ncpylen] = '\0';
*dwComponentLen = ncpylen;
}
......
......@@ -53,6 +53,7 @@ time_t ConvertTimeString(LPCWSTR asctime)
if(!asctime || !timelen)
return 0;
/* The atoiWs below relie on that tmpChar is \0 padded? */
strncpyW(tmpChar, asctime, TIME_STRING_LEN);
/* Assert that the string is the expected length */
......
......@@ -701,7 +701,7 @@ static BOOL OSS_WaveOutInit(OSS_DEVICE* ossdev)
if ((mixer = open(ossdev->mixer_name, O_RDONLY|O_NDELAY)) >= 0) {
mixer_info info;
if (ioctl(mixer, SOUND_MIXER_INFO, &info) >= 0) {
strncpy(ossdev->ds_desc.szDesc, info.name, sizeof(info.name));
lstrcpynA(ossdev->ds_desc.szDesc, info.name, sizeof(info.name));
strcpy(ossdev->ds_desc.szDrvname, "wineoss.drv");
MultiByteToWideChar(CP_ACP, 0, info.name, sizeof(info.name),
ossdev->out_caps.szPname,
......
......@@ -310,7 +310,7 @@ int autodetect_drives()
return FALSE;
}
strncpy(label, "Drive X", 8);
strcpy(label, "Drive X");
label[6] = letter;
WINE_TRACE("adding drive %c for %s, type %s with label %s\n", letter, ent->mnt_dir, ent->mnt_type,label);
......
......@@ -207,12 +207,13 @@ static void fill_fontinfo(FT_Face face, int enc, FILE *fp, int dpi, unsigned cha
num_names = FT_Get_Sfnt_Name_Count(face);
for(i = 0; i <num_names; i++) {
FT_Get_Sfnt_Name(face, i, &sfntname);
strncpy(namebuf, sfntname.string, sfntname.string_len);
memcpy(namebuf, sfntname.string, sfntname.string_len);
namebuf[sfntname.string_len] = '\0';
if(sfntname.platform_id == 1 && sfntname.encoding_id == 0 && sfntname.language_id == 0 && sfntname.name_id == 0) {
if(sfntname.platform_id == 1 && sfntname.encoding_id == 0 &&
sfntname.language_id == 0 && sfntname.name_id == 0) {
strncpy(hdr.dfCopyright, namebuf, 60);
hdr.dfCopyright[59] = '\0';
}
}
}
os2 = FT_Get_Sfnt_Table(face, ft_sfnt_os2);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment