Strncpy elimination.
This commit is contained in:
parent
972a949552
commit
6aefbc0934
|
@ -111,7 +111,7 @@ HRESULT WINAPI IDirectMusicContainerImpl_IDirectMusicContainer_EnumObject (LPDIR
|
|||
if (dwCount == dwIndex) {
|
||||
HRESULT result = S_OK;
|
||||
if (pwszAlias) {
|
||||
strncpyW (pwszAlias, pContainedObject->wszAlias, DMUS_MAX_FILENAME);
|
||||
lstrcpynW (pwszAlias, pContainedObject->wszAlias, DMUS_MAX_FILENAME);
|
||||
if (strlenW (pContainedObject->wszAlias) > DMUS_MAX_FILENAME)
|
||||
result = DMUS_S_STRING_TRUNCATED;
|
||||
}
|
||||
|
@ -199,15 +199,15 @@ HRESULT WINAPI IDirectMusicContainerImpl_IDirectMusicObject_SetDescriptor (LPDIR
|
|||
dwNewFlags |= DMUS_OBJ_OBJECT;
|
||||
}
|
||||
if (pDesc->dwValidData & DMUS_OBJ_NAME) {
|
||||
strncpyW (This->Desc.wszName, pDesc->wszName, DMUS_MAX_NAME);
|
||||
lstrcpynW (This->Desc.wszName, pDesc->wszName, DMUS_MAX_NAME);
|
||||
dwNewFlags |= DMUS_OBJ_NAME;
|
||||
}
|
||||
if (pDesc->dwValidData & DMUS_OBJ_CATEGORY) {
|
||||
strncpyW (This->Desc.wszCategory, pDesc->wszCategory, DMUS_MAX_CATEGORY);
|
||||
lstrcpynW (This->Desc.wszCategory, pDesc->wszCategory, DMUS_MAX_CATEGORY);
|
||||
dwNewFlags |= DMUS_OBJ_CATEGORY;
|
||||
}
|
||||
if (pDesc->dwValidData & (DMUS_OBJ_FILENAME | DMUS_OBJ_FULLPATH)) {
|
||||
strncpyW (This->Desc.wszFileName, pDesc->wszFileName, DMUS_MAX_FILENAME);
|
||||
lstrcpynW (This->Desc.wszFileName, pDesc->wszFileName, DMUS_MAX_FILENAME);
|
||||
dwNewFlags |= (pDesc->dwValidData & (DMUS_OBJ_FILENAME | DMUS_OBJ_FULLPATH));
|
||||
}
|
||||
if (pDesc->dwValidData & DMUS_OBJ_VERSION) {
|
||||
|
|
|
@ -131,6 +131,7 @@ HRESULT WINAPI IDirectMusicCollectionImpl_IDirectMusicCollection_EnumInstrument
|
|||
unsigned int r = 0;
|
||||
DMUS_PRIVATE_INSTRUMENTENTRY *tmpEntry;
|
||||
struct list *listEntry;
|
||||
DWORD dwLen;
|
||||
|
||||
TRACE("(%p, %ld, %p, %p, %ld)\n", This, dwIndex, pdwPatch, pwszName, dwNameLen);
|
||||
LIST_FOR_EACH (listEntry, &This->Instruments) {
|
||||
|
@ -138,8 +139,11 @@ HRESULT WINAPI IDirectMusicCollectionImpl_IDirectMusicCollection_EnumInstrument
|
|||
if (r == dwIndex) {
|
||||
ICOM_NAME_MULTI (IDirectMusicInstrumentImpl, InstrumentVtbl, tmpEntry->pInstrument, pInstrument);
|
||||
IDirectMusicInstrument_GetPatch (tmpEntry->pInstrument, pdwPatch);
|
||||
dwNameLen = strlenW (pInstrument->wszName);
|
||||
strncpyW (pwszName, pInstrument->wszName, dwNameLen);
|
||||
if (pwszName) {
|
||||
dwLen = min(strlenW(pInstrument->wszName),dwNameLen-1);
|
||||
memcpy (pwszName, pInstrument->wszName, dwLen * sizeof(WCHAR));
|
||||
pwszName[dwLen] = '\0';
|
||||
}
|
||||
return S_OK;
|
||||
}
|
||||
r++;
|
||||
|
@ -190,11 +194,11 @@ HRESULT WINAPI IDirectMusicCollectionImpl_IDirectMusicObject_SetDescriptor (LPDI
|
|||
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)
|
||||
|
|
|
@ -293,9 +293,11 @@ static TDB *TASK_Create( NE_MODULE *pModule, UINT16 cmdShow, LPCSTR cmdline, BYT
|
|||
|
||||
if (hModule)
|
||||
{
|
||||
char name[10];
|
||||
char name[sizeof(pTask->module_name)+1];
|
||||
size_t len;
|
||||
GetModuleName16( hModule, name, sizeof(name) );
|
||||
strncpy( pTask->module_name, name, sizeof(pTask->module_name) );
|
||||
len = strlen(name) + 1;
|
||||
memcpy(pTask->module_name, name, min(len,sizeof(pTask->module_name)));
|
||||
pTask->compat_flags = GetProfileIntA( "Compatibility", name, 0 );
|
||||
}
|
||||
|
||||
|
|
|
@ -1399,21 +1399,19 @@ static BOOL unpad_data(CONST BYTE *abData, DWORD dwDataLen, BYTE *abBuffer, DWOR
|
|||
BOOL WINAPI RSAENH_CPAcquireContext(HCRYPTPROV *phProv, LPSTR pszContainer,
|
||||
DWORD dwFlags, PVTableProvStruc pVTable)
|
||||
{
|
||||
DWORD dwLen;
|
||||
CHAR szKeyContainerName[MAX_PATH] = "";
|
||||
CHAR szKeyContainerName[MAX_PATH];
|
||||
CHAR szRegKey[MAX_PATH];
|
||||
|
||||
TRACE("(phProv=%p, pszContainer=%s, dwFlags=%08lx, pVTable=%p)\n", phProv,
|
||||
debugstr_a(pszContainer), dwFlags, pVTable);
|
||||
|
||||
if (pszContainer ? strlen(pszContainer) : 0)
|
||||
if (pszContainer && *pszContainer)
|
||||
{
|
||||
strncpy(szKeyContainerName, pszContainer, MAX_PATH);
|
||||
szKeyContainerName[MAX_PATH-1] = '\0';
|
||||
lstrcpynA(szKeyContainerName, pszContainer, MAX_PATH);
|
||||
}
|
||||
else
|
||||
{
|
||||
dwLen = MAX_PATH;
|
||||
DWORD dwLen = sizeof(szKeyContainerName);
|
||||
if (!GetUserNameA(szKeyContainerName, &dwLen)) return FALSE;
|
||||
}
|
||||
|
||||
|
|
|
@ -2774,7 +2774,7 @@ int WINAPI PathCommonPrefixW(LPCWSTR lpszFile1, LPCWSTR lpszFile2, LPWSTR achPat
|
|||
* dx [I] Desired width
|
||||
*
|
||||
* RETURNS
|
||||
* TRUE If the path was modified.
|
||||
* TRUE If the path was modified/went well.
|
||||
* FALSE Otherwise.
|
||||
*/
|
||||
BOOL WINAPI PathCompactPathA(HDC hDC, LPSTR lpszPath, UINT dx)
|
||||
|
@ -2810,7 +2810,7 @@ BOOL WINAPI PathCompactPathW(HDC hDC, LPWSTR lpszPath, UINT dx)
|
|||
TRACE("(%p,%s,%d)\n", hDC, debugstr_w(lpszPath), dx);
|
||||
|
||||
if (!lpszPath)
|
||||
return bRet;
|
||||
return FALSE;
|
||||
|
||||
if (!hDC)
|
||||
hdc = hDC = GetDC(0);
|
||||
|
@ -2887,7 +2887,7 @@ BOOL WINAPI PathCompactPathW(HDC hDC, LPWSTR lpszPath, UINT dx)
|
|||
|
||||
if (dwLen > MAX_PATH - 3)
|
||||
dwLen = MAX_PATH - 3;
|
||||
strncpyW(buff, sFile, dwLen);
|
||||
lstrcpynW(buff, sFile, dwLen);
|
||||
|
||||
do {
|
||||
dwLen--;
|
||||
|
|
|
@ -720,7 +720,7 @@ HRESULT WINAPI UrlCombineW(LPCWSTR pszBase, LPCWSTR pszRelative,
|
|||
* Return the pszBase scheme with pszRelative. Basically
|
||||
* keeps the scheme and replaces the domain and following.
|
||||
*/
|
||||
strncpyW(preliminary, base.pszProtocol, base.cchProtocol + 1);
|
||||
memcpy(preliminary, base.pszProtocol, (base.cchProtocol + 1)*sizeof(WCHAR));
|
||||
work = preliminary + base.cchProtocol + 1;
|
||||
strcpyW(work, relative.pszSuffix);
|
||||
if (!(dwFlags & URL_PLUGGABLE_PROTOCOL) &&
|
||||
|
@ -733,7 +733,7 @@ HRESULT WINAPI UrlCombineW(LPCWSTR pszBase, LPCWSTR pszRelative,
|
|||
* after the location is pszRelative. (Replace document
|
||||
* from root on.)
|
||||
*/
|
||||
strncpyW(preliminary, base.pszProtocol, base.cchProtocol+1+sizeloc);
|
||||
memcpy(preliminary, base.pszProtocol, (base.cchProtocol+1+sizeloc)*sizeof(WCHAR));
|
||||
work = preliminary + base.cchProtocol + 1 + sizeloc;
|
||||
if (dwFlags & URL_PLUGGABLE_PROTOCOL)
|
||||
*(work++) = L'/';
|
||||
|
@ -744,7 +744,8 @@ HRESULT WINAPI UrlCombineW(LPCWSTR pszBase, LPCWSTR pszRelative,
|
|||
* Return the pszBase without its document (if any) and
|
||||
* append pszRelative after its scheme.
|
||||
*/
|
||||
strncpyW(preliminary, base.pszProtocol, base.cchProtocol+1+base.cchSuffix);
|
||||
memcpy(preliminary, base.pszProtocol,
|
||||
(base.cchProtocol+1+base.cchSuffix)*sizeof(WCHAR));
|
||||
work = preliminary + base.cchProtocol+1+base.cchSuffix - 1;
|
||||
if (*work++ != L'/')
|
||||
*(work++) = L'/';
|
||||
|
@ -1951,7 +1952,9 @@ static LONG URL_ParseUrl(LPCWSTR pszUrl, WINE_PARSE_URL *pl)
|
|||
* PARAMS
|
||||
* pszIn [I] Url to parse
|
||||
* pszOut [O] Destination for part of pszIn requested
|
||||
* pcchOut [I/O] Length of pszOut/destination for length of pszOut
|
||||
* pcchOut [I] Size of pszOut
|
||||
* [O] length of pszOut string EXLUDING '\0' if S_OK, otherwise
|
||||
* needed size of pszOut INCLUDING '\0'.
|
||||
* dwPart [I] URL_PART_ enum from "shlwapi.h"
|
||||
* dwFlags [I] URL_ flags from "shlwapi.h"
|
||||
*
|
||||
|
@ -2003,7 +2006,6 @@ HRESULT WINAPI UrlGetPartW(LPCWSTR pszIn, LPWSTR pszOut, LPDWORD pcchOut,
|
|||
HRESULT ret;
|
||||
DWORD size, schsize;
|
||||
LPCWSTR addr, schaddr;
|
||||
LPWSTR work;
|
||||
|
||||
TRACE("(%s %p %p(%ld) %08lx %08lx)\n",
|
||||
debugstr_w(pszIn), pszOut, pcchOut, *pcchOut, dwPart, dwFlags);
|
||||
|
@ -2055,24 +2057,21 @@ HRESULT WINAPI UrlGetPartW(LPCWSTR pszIn, LPWSTR pszOut, LPDWORD pcchOut,
|
|||
}
|
||||
|
||||
if (dwFlags == URL_PARTFLAG_KEEPSCHEME) {
|
||||
if (*pcchOut < size + schsize + 2) {
|
||||
*pcchOut = size + schsize + 2;
|
||||
if (*pcchOut < schsize + size + 2) {
|
||||
*pcchOut = schsize + size + 2;
|
||||
return E_POINTER;
|
||||
}
|
||||
strncpyW(pszOut, schaddr, schsize);
|
||||
work = pszOut + schsize;
|
||||
*work = L':';
|
||||
strncpyW(work+1, addr, size);
|
||||
*pcchOut = size + schsize + 1;
|
||||
work += (size + 1);
|
||||
*work = L'\0';
|
||||
memcpy(pszOut, schaddr, schsize*sizeof(WCHAR));
|
||||
pszOut[schsize] = ':';
|
||||
memcpy(pszOut+schsize+1, addr, size*sizeof(WCHAR));
|
||||
pszOut[schsize+1+size] = 0;
|
||||
*pcchOut = schsize + 1 + size;
|
||||
}
|
||||
else {
|
||||
if (*pcchOut < size + 1) {*pcchOut = size+1; return E_POINTER;}
|
||||
strncpyW(pszOut, addr, size);
|
||||
memcpy(pszOut, addr, size*sizeof(WCHAR));
|
||||
pszOut[size] = 0;
|
||||
*pcchOut = size;
|
||||
work = pszOut + size;
|
||||
*work = L'\0';
|
||||
}
|
||||
TRACE("len=%ld %s\n", *pcchOut, debugstr_w(pszOut));
|
||||
}
|
||||
|
|
|
@ -563,10 +563,11 @@ DWORD DOSDEV_FindCharDevice(char*name)
|
|||
int cnt;
|
||||
|
||||
/* get first 8 characters */
|
||||
strncpy(dname,name,8);
|
||||
/* if less than 8 characters, pad with spaces */
|
||||
for (cnt=0; cnt<8; cnt++)
|
||||
if (!dname[cnt]) dname[cnt]=' ';
|
||||
for (cnt=0; name[cnt] && cnt<8; cnt++)
|
||||
dname[cnt]=name[cnt];
|
||||
|
||||
while(cnt<8) dname[cnt++] = ' ';
|
||||
|
||||
/* search for char devices with the right name */
|
||||
while (cur &&
|
||||
|
|
|
@ -670,22 +670,25 @@ static BOOL URLCache_LocalFileNameToPathA(
|
|||
LPLONG lpBufferSize)
|
||||
{
|
||||
LONG nRequired;
|
||||
int path_len = WideCharToMultiByte(CP_ACP, 0, pContainer->path, -1, NULL, 0, NULL, NULL);
|
||||
int file_name_len = strlen(szLocalFileName);
|
||||
int dir_len = DIR_LENGTH;
|
||||
int path_len, file_name_len, dir_len;
|
||||
|
||||
if (Directory >= pHeader->DirectoryCount)
|
||||
{
|
||||
*lpBufferSize = 0;
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
nRequired = (path_len + dir_len + file_name_len + 1) * sizeof(WCHAR);
|
||||
path_len = WideCharToMultiByte(CP_ACP, 0, pContainer->path, -1, NULL, 0, NULL, NULL);
|
||||
file_name_len = strlen(szLocalFileName);
|
||||
dir_len = DIR_LENGTH;
|
||||
|
||||
nRequired = (path_len + dir_len + 1 + file_name_len) * sizeof(WCHAR);
|
||||
if (nRequired < *lpBufferSize)
|
||||
{
|
||||
WideCharToMultiByte(CP_ACP, 0, pContainer->path, -1, szPath, -1, NULL, NULL);
|
||||
strncpy(szPath, pHeader->directory_data[Directory].filename, DIR_LENGTH);
|
||||
szPath[dir_len + path_len] = '\\';
|
||||
strcpy(szPath + dir_len + path_len + 1, szLocalFileName);
|
||||
memcpy(szPath+path_len, pHeader->directory_data[Directory].filename, dir_len);
|
||||
szPath[path_len + dir_len] = '\\';
|
||||
memcpy(szPath + path_len + dir_len + 1, szLocalFileName, file_name_len);
|
||||
*lpBufferSize = nRequired;
|
||||
return TRUE;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue