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

Janitorial: Get rid of strncpy/strncpyW.

parent 65e4d345
......@@ -462,16 +462,17 @@ BOOL WINAPI GetFileDialog95W(LPOPENFILENAMEW ofn,UINT iDlgType)
if(ofn->lpstrFile)
{
fodInfos.filename = MemAlloc(ofn->nMaxFile*sizeof(WCHAR));
strncpyW(fodInfos.filename,ofn->lpstrFile,ofn->nMaxFile);
lstrcpynW(fodInfos.filename,ofn->lpstrFile,ofn->nMaxFile);
}
else
fodInfos.filename = NULL;
if(ofn->lpstrInitialDir)
{
DWORD len = strlenW(ofn->lpstrInitialDir);
fodInfos.initdir = MemAlloc((len+1)*sizeof(WCHAR));
strcpyW(fodInfos.initdir,ofn->lpstrInitialDir);
/* fodInfos.initdir = strdupW(ofn->lpstrInitialDir); */
DWORD len = strlenW(ofn->lpstrInitialDir)+1;
fodInfos.initdir = MemAlloc(len*sizeof(WCHAR));
memcpy(fodInfos.initdir,ofn->lpstrInitialDir,len*sizeof(WCHAR));
}
else
fodInfos.initdir = NULL;
......@@ -853,7 +854,7 @@ HRESULT FILEDLG95_Handle_GetFilePath(HWND hwnd, DWORD size, LPVOID buffer)
/* Prepend the current path */
n = strlenW(lpstrCurrentDir) + 1;
strncpyW( bufW, lpstrCurrentDir, size );
memcpy( bufW, lpstrCurrentDir, min(n,size) * sizeof(WCHAR));
if(n<size)
{
/* 'n' includes trailing \0 */
......@@ -2034,7 +2035,7 @@ BOOL FILEDLG95_OnOpen(HWND hwnd)
{
LPOPENFILENAMEW ofn = fodInfos->ofnInfos;
strncpyW(ofn->lpstrFile, lpstrPathAndFile, ofn->nMaxFile);
lstrcpynW(ofn->lpstrFile, lpstrPathAndFile, ofn->nMaxFile);
if (ofn->Flags & OFN_ALLOWMULTISELECT)
ofn->lpstrFile[lstrlenW(ofn->lpstrFile) + 1] = '\0';
}
......
......@@ -126,8 +126,7 @@ BOOL WINAPI SymGetSearchPath(HANDLE hProcess, LPSTR szSearchPath,
struct process* pcs = process_find_by_handle(hProcess);
if (!pcs) return FALSE;
strncpy(szSearchPath, pcs->search_path, SearchPathLength);
szSearchPath[SearchPathLength - 1] = '\0';
lstrcpynA(szSearchPath, pcs->search_path, SearchPathLength);
return TRUE;
}
......
......@@ -42,8 +42,7 @@ static void module_fill_module(const char* in, char* out, unsigned size)
*ptr != '/' && *ptr != '\\' && ptr >= in;
ptr--);
if (ptr < in || *ptr == '/' || *ptr == '\\') ptr++;
strncpy(out, ptr, size);
out[size - 1] = '\0';
lstrcpynA(out, ptr, size);
len = strlen(out);
if (len > 4 &&
(!strcasecmp(&out[len - 4], ".dll") || !strcasecmp(&out[len - 4], ".exe")))
......@@ -51,7 +50,7 @@ static void module_fill_module(const char* in, char* out, unsigned size)
else if (((len > 12 && out[len - 13] == '/') || len == 12) &&
(!strcasecmp(out + len - 12, "wine-pthread") ||
!strcasecmp(out + len - 12, "wine-kthread")))
strcpy(out, "<wine-loader>");
lstrcpynA(out, "<wine-loader>",size);
else
{
if (len > 7 &&
......@@ -96,9 +95,7 @@ struct module* module_new(struct process* pcs, const char* name,
module->module.ImageSize = size;
module_fill_module(name, module->module.ModuleName, sizeof(module->module.ModuleName));
module->module.ImageName[0] = '\0';
strncpy(module->module.LoadedImageName, name,
sizeof(module->module.LoadedImageName));
module->module.LoadedImageName[sizeof(module->module.LoadedImageName) - 1] = '\0';
lstrcpynA(module->module.LoadedImageName, name, sizeof(module->module.LoadedImageName));
module->module.SymType = SymNone;
module->module.NumSyms = 0;
module->module.TimeDateStamp = stamp;
......@@ -360,13 +357,8 @@ done:
* of ImageName. Overwrite it, if we have better information
*/
if (ModuleName)
{
strncpy(module->module.ModuleName, ModuleName,
sizeof(module->module.ModuleName));
module->module.ModuleName[sizeof(module->module.ModuleName) - 1] = '\0';
}
strncpy(module->module.ImageName, ImageName, sizeof(module->module.ImageName));
module->module.ImageName[sizeof(module->module.ImageName) - 1] = '\0';
lstrcpynA(module->module.ModuleName, ModuleName, sizeof(module->module.ModuleName));
lstrcpynA(module->module.ImageName, ImageName, sizeof(module->module.ImageName));
return module->module.BaseOfImage;
}
......
......@@ -536,7 +536,7 @@ static void symt_fill_sym_info(const struct module* module,
sym_info->MaxNameLen, UNDNAME_COMPLETE) == 0))
{
sym_info->NameLen = min(strlen(name), sym_info->MaxNameLen - 1);
strncpy(sym_info->Name, name, sym_info->NameLen);
memcpy(sym_info->Name, name, sym_info->NameLen);
sym_info->Name[sym_info->NameLen] = '\0';
}
}
......@@ -916,8 +916,7 @@ BOOL WINAPI SymGetSymFromAddr(HANDLE hProcess, DWORD Address,
Symbol->Size = si->Size;
Symbol->Flags = si->Flags;
len = min(Symbol->MaxNameLength, si->MaxNameLen);
strncpy(Symbol->Name, si->Name, len);
Symbol->Name[len - 1] = '\0';
lstrcpynA(Symbol->Name, si->Name, len);
return TRUE;
}
......@@ -992,8 +991,7 @@ BOOL WINAPI SymGetSymFromName(HANDLE hProcess, LPSTR Name, PIMAGEHLP_SYMBOL Symb
Symbol->Size = si->Size;
Symbol->Flags = si->Flags;
len = min(Symbol->MaxNameLength, si->MaxNameLen);
strncpy(Symbol->Name, si->Name, len);
Symbol->Name[len - 1] = '\0';
lstrcpynA(Symbol->Name, si->Name, len);
return TRUE;
}
......
......@@ -165,9 +165,9 @@ HRESULT WINAPI IDirectMusicBandImpl_IDirectMusicObject_SetDescriptor (LPDIRECTMU
if (pDesc->dwValidData & DMUS_OBJ_NAME)
strncpyW (This->pDesc->wszName, pDesc->wszName, DMUS_MAX_NAME);
if (pDesc->dwValidData & DMUS_OBJ_CATEGORY)
strncpyW (This->pDesc->wszCategory, pDesc->wszCategory, DMUS_MAX_CATEGORY);
strncpyW (This->pDesc->wszCategory, pDesc->wszCategory, DMUS_MAX_CATEGORY);
if (pDesc->dwValidData & DMUS_OBJ_FILENAME)
strncpyW (This->pDesc->wszFileName, pDesc->wszFileName, DMUS_MAX_FILENAME);
strncpyW (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)
......
......@@ -149,9 +149,9 @@ HRESULT WINAPI IDirectMusicChordMapImpl_IDirectMusicObject_SetDescriptor (LPDIRE
if (pDesc->dwValidData & DMUS_OBJ_NAME)
strncpyW (This->pDesc->wszName, pDesc->wszName, DMUS_MAX_NAME);
if (pDesc->dwValidData & DMUS_OBJ_CATEGORY)
strncpyW (This->pDesc->wszCategory, pDesc->wszCategory, DMUS_MAX_CATEGORY);
strncpyW (This->pDesc->wszCategory, pDesc->wszCategory, DMUS_MAX_CATEGORY);
if (pDesc->dwValidData & DMUS_OBJ_FILENAME)
strncpyW (This->pDesc->wszFileName, pDesc->wszFileName, DMUS_MAX_FILENAME);
strncpyW (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)
......
......@@ -264,9 +264,9 @@ HRESULT WINAPI IDirectMusicAudioPathImpl_IDirectMusicObject_SetDescriptor (LPDIR
if (pDesc->dwValidData & DMUS_OBJ_NAME)
strncpyW (This->pDesc->wszName, pDesc->wszName, DMUS_MAX_NAME);
if (pDesc->dwValidData & DMUS_OBJ_CATEGORY)
strncpyW (This->pDesc->wszCategory, pDesc->wszCategory, DMUS_MAX_CATEGORY);
strncpyW (This->pDesc->wszCategory, pDesc->wszCategory, DMUS_MAX_CATEGORY);
if (pDesc->dwValidData & DMUS_OBJ_FILENAME)
strncpyW (This->pDesc->wszFileName, pDesc->wszFileName, DMUS_MAX_FILENAME);
strncpyW (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,9 +230,9 @@ HRESULT WINAPI IDirectMusicGraphImpl_IDirectMusicObject_SetDescriptor (LPDIRECTM
if (pDesc->dwValidData & DMUS_OBJ_NAME)
strncpyW (This->pDesc->wszName, pDesc->wszName, DMUS_MAX_NAME);
if (pDesc->dwValidData & DMUS_OBJ_CATEGORY)
strncpyW (This->pDesc->wszCategory, pDesc->wszCategory, DMUS_MAX_CATEGORY);
strncpyW (This->pDesc->wszCategory, pDesc->wszCategory, DMUS_MAX_CATEGORY);
if (pDesc->dwValidData & DMUS_OBJ_FILENAME)
strncpyW (This->pDesc->wszFileName, pDesc->wszFileName, DMUS_MAX_FILENAME);
strncpyW (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)
......
......@@ -550,9 +550,9 @@ HRESULT WINAPI IDirectMusicSegment8Impl_IDirectMusicObject_SetDescriptor (LPDIRE
if (pDesc->dwValidData & DMUS_OBJ_NAME)
strncpyW (This->pDesc->wszName, pDesc->wszName, DMUS_MAX_NAME);
if (pDesc->dwValidData & DMUS_OBJ_CATEGORY)
strncpyW (This->pDesc->wszCategory, pDesc->wszCategory, DMUS_MAX_CATEGORY);
strncpyW (This->pDesc->wszCategory, pDesc->wszCategory, DMUS_MAX_CATEGORY);
if (pDesc->dwValidData & DMUS_OBJ_FILENAME)
strncpyW (This->pDesc->wszFileName, pDesc->wszFileName, DMUS_MAX_FILENAME);
strncpyW (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)
......
......@@ -567,8 +567,8 @@ IDirectSoundCaptureImpl_Initialize(
if (err == DS_OK) {
This->drvcaps.dwFlags = 0;
strncpy(This->drvdesc.szDrvname, wic.szPname,
sizeof(This->drvdesc.szDrvname));
lstrcpynA(This->drvdesc.szDrvname, wic.szPname,
sizeof(This->drvdesc.szDrvname));
This->drvcaps.dwFlags |= DSCCAPS_EMULDRIVER;
This->drvcaps.dwFormats = wic.dwFormats;
......
......@@ -149,8 +149,7 @@ void setup_dsound_options(void)
char appname[MAX_PATH+16];
char *p = strrchr( buffer, '\\' );
if (p!=NULL) {
appname[MAX_PATH]='\0';
strncpy(appname,p+1,MAX_PATH);
lstrcpynA(appname,p+1,MAX_PATH);
strcat(appname,"\\dsound");
TRACE("appname = [%s] \n",appname);
if (RegOpenKeyA( tmpkey, appname, &appkey )) appkey = 0;
......
......@@ -384,8 +384,8 @@ static HRESULT WINAPI DSPROPERTY_Description1(
err = mmErr(waveOutMessage((HWAVEOUT)wod,DRV_QUERYDSOUNDDESC,(DWORD)&(desc),0));
if (err == DS_OK) {
PIDSDRIVER drv = NULL;
strncpy(ppd->DescriptionA, desc.szDesc, sizeof(ppd->DescriptionA) - 1);
strncpy(ppd->ModuleA, desc.szDrvname, sizeof(ppd->ModuleA) - 1);
lstrcpynA(ppd->DescriptionA, desc.szDesc, sizeof(ppd->DescriptionA));
lstrcpynA(ppd->ModuleA, desc.szDrvname, sizeof(ppd->ModuleA));
MultiByteToWideChar( CP_ACP, 0, desc.szDesc, -1, ppd->DescriptionW, sizeof(ppd->DescriptionW)/sizeof(WCHAR) );
MultiByteToWideChar( CP_ACP, 0, desc.szDrvname, -1, ppd->ModuleW, sizeof(ppd->ModuleW)/sizeof(WCHAR) );
err = mmErr(waveOutMessage((HWAVEOUT)wod, DRV_QUERYDSOUNDIFACE, (DWORD)&drv, 0));
......@@ -415,8 +415,8 @@ static HRESULT WINAPI DSPROPERTY_Description1(
err = mmErr(waveInMessage((HWAVEIN)wid,DRV_QUERYDSOUNDDESC,(DWORD)&(desc),0));
if (err == DS_OK) {
PIDSCDRIVER drv;
strncpy(ppd->DescriptionA, desc.szDesc, sizeof(ppd->DescriptionA) - 1);
strncpy(ppd->ModuleA, desc.szDrvname, sizeof(ppd->ModuleA) - 1);
lstrcpynA(ppd->DescriptionA, desc.szDesc, sizeof(ppd->DescriptionA));
lstrcpynA(ppd->ModuleA, desc.szDrvname, sizeof(ppd->ModuleA));
MultiByteToWideChar( CP_ACP, 0, desc.szDesc, -1, ppd->DescriptionW, sizeof(ppd->DescriptionW)/sizeof(WCHAR) );
MultiByteToWideChar( CP_ACP, 0, desc.szDrvname, -1, ppd->ModuleW, sizeof(ppd->ModuleW)/sizeof(WCHAR) );
err = mmErr(waveInMessage((HWAVEIN)wid,DRV_QUERYDSOUNDIFACE,(DWORD)&drv,0));
......@@ -447,8 +447,8 @@ static HRESULT WINAPI DSPROPERTY_Description1(
err = mmErr(waveOutMessage((HWAVEOUT)wod,DRV_QUERYDSOUNDDESC,(DWORD)&(desc),0));
if (err == DS_OK) {
PIDSDRIVER drv = NULL;
strncpy(ppd->DescriptionA, desc.szDesc, sizeof(ppd->DescriptionA) - 1);
strncpy(ppd->ModuleA, desc.szDrvname, sizeof(ppd->ModuleA) - 1);
lstrcpynA(ppd->DescriptionA, desc.szDesc, sizeof(ppd->DescriptionA));
lstrcpynA(ppd->ModuleA, desc.szDrvname, sizeof(ppd->ModuleA));
MultiByteToWideChar( CP_ACP, 0, desc.szDesc, -1, ppd->DescriptionW, sizeof(ppd->DescriptionW)/sizeof(WCHAR) );
MultiByteToWideChar( CP_ACP, 0, desc.szDrvname, -1, ppd->ModuleW, sizeof(ppd->ModuleW)/sizeof(WCHAR) );
err = mmErr(waveOutMessage((HWAVEOUT)wod, DRV_QUERYDSOUNDIFACE, (DWORD)&drv, 0));
......@@ -480,8 +480,8 @@ static HRESULT WINAPI DSPROPERTY_Description1(
err = mmErr(waveInMessage((HWAVEIN)wod,DRV_QUERYDSOUNDDESC,(DWORD)&(desc),0));
if (err == DS_OK) {
PIDSDRIVER drv = NULL;
strncpy(ppd->DescriptionA, desc.szDesc, sizeof(ppd->DescriptionA) - 1);
strncpy(ppd->ModuleA, desc.szDrvname, sizeof(ppd->ModuleA) - 1);
lstrcpynA(ppd->DescriptionA, desc.szDesc, sizeof(ppd->DescriptionA));
lstrcpynA(ppd->ModuleA, desc.szDrvname, sizeof(ppd->ModuleA));
MultiByteToWideChar( CP_ACP, 0, desc.szDesc, -1, ppd->DescriptionW, sizeof(ppd->DescriptionW)/sizeof(WCHAR) );
MultiByteToWideChar( CP_ACP, 0, desc.szDrvname, -1, ppd->ModuleW, sizeof(ppd->ModuleW)/sizeof(WCHAR) );
err = mmErr(waveInMessage((HWAVEIN)wod, DRV_QUERYDSOUNDIFACE, (DWORD)&drv, 0));
......@@ -1005,8 +1005,8 @@ static HRESULT WINAPI DSPROPERTY_Enumerate1(
data.DataFlow = DIRECTSOUNDDEVICE_DATAFLOW_RENDER;
data.WaveDeviceId = wod;
data.DeviceId = DSOUND_renderer_guids[wod];
strncpy(data.DescriptionA, desc.szDesc, sizeof(data.DescriptionA));
strncpy(data.ModuleA, desc.szDrvname, sizeof(data.ModuleA));
lstrcpynA(data.DescriptionA, desc.szDesc, sizeof(data.DescriptionA));
lstrcpynA(data.ModuleA, desc.szDrvname, sizeof(data.ModuleA));
MultiByteToWideChar( CP_ACP, 0, data.DescriptionA, -1, data.DescriptionW, sizeof(data.DescriptionW) );
MultiByteToWideChar( CP_ACP, 0, data.ModuleA, -1, data.ModuleW, sizeof(data.ModuleW) );
......@@ -1024,8 +1024,8 @@ static HRESULT WINAPI DSPROPERTY_Enumerate1(
data.DataFlow = DIRECTSOUNDDEVICE_DATAFLOW_RENDER;
data.WaveDeviceId = wod;
data.DeviceId = DSOUND_renderer_guids[wod];
strncpy(data.DescriptionA, desc.szDesc, sizeof(data.DescriptionA));
strncpy(data.ModuleA, desc.szDrvname, sizeof(data.ModuleA));
lstrcpynA(data.DescriptionA, desc.szDesc, sizeof(data.DescriptionA));
lstrcpynA(data.ModuleA, desc.szDrvname, sizeof(data.ModuleA));
MultiByteToWideChar( CP_ACP, 0, data.DescriptionA, -1, data.DescriptionW, sizeof(data.DescriptionW) );
MultiByteToWideChar( CP_ACP, 0, data.ModuleA, -1, data.ModuleW, sizeof(data.ModuleW) );
......
......@@ -346,11 +346,11 @@ HRESULT WINAPI IDirectMusicWaveImpl_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)
......
......@@ -67,8 +67,7 @@ static ATOM PortNameToAtom(LPCSTR lpPortName, BOOL16 add)
{
char buffer[256];
strncpy( buffer, lpPortName, sizeof(buffer) );
buffer[sizeof(buffer)-1] = 0;
lstrcpynA( buffer, lpPortName, sizeof(buffer) );
if (buffer[0] && buffer[strlen(buffer)-1] == ':') buffer[strlen(buffer)-1] = 0;
......
......@@ -191,8 +191,7 @@ static int isLoopbackInterface(int fd, const char *name)
if (name) {
struct ifreq ifr;
strncpy(ifr.ifr_name, name, IFNAMSIZ);
ifr.ifr_name[IFNAMSIZ-1] = '\0';
lstrcpynA(ifr.ifr_name, name, IFNAMSIZ);
if (ioctl(fd, SIOCGIFFLAGS, &ifr) == 0)
ret = ifr.ifr_flags & IFF_LOOPBACK;
}
......@@ -245,8 +244,7 @@ static void storeInterfaceInMap(InterfaceNameMap *map, const char *name)
/* look for new slot */
for (ndx = 0; !stored && ndx < map->numAllocated; ndx++) {
if (!map->table[ndx].inUse) {
strncpy(map->table[ndx].name, name, IFNAMSIZ);
map->table[ndx].name[IFNAMSIZ-1] = '\0';
lstrcpynA(map->table[ndx].name, name, IFNAMSIZ);
map->table[ndx].inUse = TRUE;
stored = TRUE;
if (ndx >= map->nextAvailable)
......@@ -467,8 +465,7 @@ DWORD getInterfaceIPAddrByName(const char *name)
if (fd != -1) {
struct ifreq ifr;
strncpy(ifr.ifr_name, name, IFNAMSIZ);
ifr.ifr_name[IFNAMSIZ-1] = '\0';
lstrcpynA(ifr.ifr_name, name, IFNAMSIZ);
if (ioctl(fd, SIOCGIFADDR, &ifr) == 0)
memcpy(&ret, ifr.ifr_addr.sa_data + 2, sizeof(DWORD));
close(fd);
......@@ -499,8 +496,7 @@ DWORD getInterfaceBCastAddrByName(const char *name)
if (fd != -1) {
struct ifreq ifr;
strncpy(ifr.ifr_name, name, IFNAMSIZ);
ifr.ifr_name[IFNAMSIZ-1] = '\0';
lstrcpynA(ifr.ifr_name, name, IFNAMSIZ);
if (ioctl(fd, SIOCGIFBRDADDR, &ifr) == 0)
memcpy(&ret, ifr.ifr_addr.sa_data + 2, sizeof(DWORD));
close(fd);
......@@ -531,8 +527,7 @@ DWORD getInterfaceMaskByName(const char *name)
if (fd != -1) {
struct ifreq ifr;
strncpy(ifr.ifr_name, name, IFNAMSIZ);
ifr.ifr_name[IFNAMSIZ-1] = '\0';
lstrcpynA(ifr.ifr_name, name, IFNAMSIZ);
if (ioctl(fd, SIOCGIFNETMASK, &ifr) == 0)
memcpy(&ret, ifr.ifr_addr.sa_data + 2, sizeof(DWORD));
close(fd);
......@@ -568,8 +563,7 @@ DWORD getInterfacePhysicalByName(const char *name, PDWORD len, PBYTE addr,
struct ifreq ifr;
memset(&ifr, 0, sizeof(struct ifreq));
strncpy(ifr.ifr_name, name, IFNAMSIZ);
ifr.ifr_name[IFNAMSIZ-1] = '\0';
lstrcpynA(ifr.ifr_name, name, IFNAMSIZ);
if ((ioctl(fd, SIOCGIFHWADDR, &ifr)))
ret = ERROR_INVALID_DATA;
else {
......@@ -813,8 +807,7 @@ DWORD getInterfaceMtuByName(const char *name, PDWORD mtu)
if (fd != -1) {
struct ifreq ifr;
strncpy(ifr.ifr_name, name, IFNAMSIZ);
ifr.ifr_name[IFNAMSIZ-1] = '\0';
lstrcpynA(ifr.ifr_name, name, IFNAMSIZ);
if ((ioctl(fd, SIOCGIFMTU, &ifr)))
ret = ERROR_INVALID_DATA;
else {
......@@ -855,8 +848,7 @@ DWORD getInterfaceStatusByName(const char *name, PDWORD status)
if (fd != -1) {
struct ifreq ifr;
strncpy(ifr.ifr_name, name, IFNAMSIZ);
ifr.ifr_name[IFNAMSIZ-1] = '\0';
lstrcpynA(ifr.ifr_name, name, IFNAMSIZ);
if ((ioctl(fd, SIOCGIFFLAGS, &ifr)))
ret = ERROR_INVALID_DATA;
else {
......@@ -940,8 +932,7 @@ char *toIPAddressString(unsigned int addr, char string[16])
iAddr.s_addr = addr;
/* extra-anal, just to make auditors happy */
strncpy(string, inet_ntoa(iAddr), 16);
string[16] = '\0';
lstrcpynA(string, inet_ntoa(iAddr), sizeof(string));
}
return string;
}
......@@ -643,10 +643,9 @@ DWORD WINAPI GetAdaptersInfo(PIP_ADAPTER_INFO pAdapterInfo, PULONG pOutBufLen)
DWORD addrLen = sizeof(ptr->Address), type;
/* on Win98 this is left empty, but whatever */
strncpy(ptr->AdapterName,
lstrcpynA(ptr->AdapterName,
getInterfaceNameByIndex(table->indexes[ndx]),
sizeof(ptr->AdapterName));
ptr->AdapterName[MAX_ADAPTER_NAME_LENGTH] = '\0';
MAX_ADAPTER_NAME_LENGTH+1);
getInterfacePhysicalByIndex(table->indexes[ndx], &addrLen,
ptr->Address, &type);
/* MS defines address length and type as UINT in some places and
......
......@@ -210,14 +210,14 @@ ATOM WINAPI AddAtom16( LPCSTR str )
if (ATOM_IsIntAtomA( str, &iatom )) return iatom;
TRACE("%s\n",debugstr_a(buffer));
TRACE("%s\n",debugstr_a(str));
if (!(table = ATOM_GetTable( TRUE ))) return 0;
/* Make a copy of the string to be sure it doesn't move in linear memory. */
lstrcpynA( buffer, str, sizeof(buffer) );
len = strlen( buffer );
if (!(table = ATOM_GetTable( TRUE ))) return 0;
hash = ATOM_Hash( table->size, buffer, len );
entry = table->entries[hash];
while (entry)
......@@ -242,9 +242,10 @@ ATOM WINAPI AddAtom16( LPCSTR str )
entryPtr->next = table->entries[hash];
entryPtr->refCount = 1;
entryPtr->length = len;
/* Some applications _need_ the '\0' padding provided by this strncpy */
strncpy( entryPtr->str, buffer, ae_len - sizeof(ATOMENTRY) + 1 );
entryPtr->str[ae_len - sizeof(ATOMENTRY)] = '\0';
memcpy( entryPtr->str, buffer, len);
/* Some applications _need_ the '\0' padding provided by memset */
/* Note that 1 byte of the str is accounted for in the ATOMENTRY struct */
memset( entryPtr->str+len, 0, ae_len - sizeof(ATOMENTRY) - (len - 1));
table->entries[hash] = entry;
TRACE("-- new 0x%x\n", entry);
return HANDLETOATOM( entry );
......
......@@ -899,7 +899,7 @@ static INT PROFILE_GetSection( PROFILESECTION *section, LPCWSTR section_name,
static INT PROFILE_GetSectionNames( LPWSTR buffer, UINT len )
{
LPWSTR buf;
UINT f,l;
UINT buflen,tmplen;
PROFILESECTION *section;
TRACE("(%p, %d)\n", buffer, len);
......@@ -911,24 +911,24 @@ static INT PROFILE_GetSectionNames( LPWSTR buffer, UINT len )
return 0;
}
f=len-1;
buflen=len-1;
buf=buffer;
section = CurProfile->section;
while ((section!=NULL)) {
if (section->name[0]) {
l = strlenW(section->name)+1;
if (l > f) {
if (f>0) {
strncpyW(buf, section->name, f-1);
buf += f-1;
tmplen = strlenW(section->name)+1;
if (tmplen > buflen) {
if (buflen > 0) {
memcpy(buf, section->name, (buflen-1) * sizeof(WCHAR));
buf += buflen-1;
*buf++='\0';
}
*buf='\0';
return len-2;
}
strcpyW(buf, section->name);
buf += l;
f -= l;
memcpy(buf, section->name, tmplen * sizeof(WCHAR));
buf += tmplen;
buflen -= tmplen;
}
section = section->next;
}
......@@ -1109,7 +1109,7 @@ static int PROFILE_GetPrivateProfileString( LPCWSTR section, LPCWSTR entry,
LPWSTR p;
p = HeapAlloc(GetProcessHeap(), 0, (len + 1) * sizeof(WCHAR));
strncpyW(p, def_val, len);
memcpy(p, def_val, len * sizeof(WCHAR));
p[len] = '\0';
pDefVal = p;
}
......
......@@ -268,8 +268,7 @@ static void doChild(const char* file, const char* option)
i = 0;
while (*ptrA)
{
strncpy(env_var, ptrA, MAX_LISTED_ENV_VAR - 1);
env_var[MAX_LISTED_ENV_VAR - 1] = '\0';
lstrcpynA(env_var, ptrA, MAX_LISTED_ENV_VAR);
childPrintf(hFile, "env%d=%s\n", i, encodeA(env_var));
i++;
ptrA += strlen(ptrA) + 1;
......
......@@ -922,7 +922,7 @@ UINT ACTION_DoTopLevelINSTALL(MSIPACKAGE *package, LPCWSTR szPackagePath,
while (*ptr == ' ') ptr++;
len = ptr2-ptr;
prop = HeapAlloc(GetProcessHeap(),0,(len+1)*sizeof(WCHAR));
strncpyW(prop,ptr,len);
memcpy(prop,ptr,len*sizeof(WCHAR));
prop[len]=0;
ptr2++;
......@@ -942,7 +942,7 @@ UINT ACTION_DoTopLevelINSTALL(MSIPACKAGE *package, LPCWSTR szPackagePath,
len -= 2;
}
val = HeapAlloc(GetProcessHeap(),0,(len+1)*sizeof(WCHAR));
strncpyW(val,ptr2,len);
memcpy(val,ptr2,len*sizeof(WCHAR));
val[len] = 0;
if (strlenW(prop) > 0)
......
......@@ -672,8 +672,8 @@ static UINT ACTION_SearchDirectory(MSIPACKAGE *package, MSISIGNATURE *sig,
pathWithDrive[0] = 'A' + i;
if (GetDriveTypeW(pathWithDrive) == DRIVE_FIXED)
{
strncpyW(pathWithDrive + 3, expanded,
sizeof(pathWithDrive) / sizeof(pathWithDrive[0]) - 3);
lstrcpynW(pathWithDrive + 3, expanded,
sizeof(pathWithDrive) / sizeof(pathWithDrive[0]) - 3);
if (sig->File)
rc = ACTION_RecurseSearchDirectory(package, &found, sig,
pathWithDrive, depth);
......
......@@ -131,7 +131,7 @@ static LPWSTR msi_dialog_get_style( LPCWSTR *text )
ret = HeapAlloc( GetProcessHeap(), 0, len*sizeof(WCHAR) );
if( !ret )
return ret;
strncpyW( ret, p, len );
memcpy( ret, p, len*sizeof(WCHAR) );
ret[len-1] = 0;
return ret;
}
......
......@@ -252,7 +252,7 @@ static BOOL find_next_outermost_key(LPCWSTR source, DWORD len_remaining,
*key = HeapAlloc(GetProcessHeap(),0,i*sizeof(WCHAR));
/* do not have the [] in the key */
i -= 1;
strncpyW(*key,&(*mark)[1],i);
memcpy(*key,&(*mark)[1],i*sizeof(WCHAR));
(*key)[i] = 0;
TRACE("Found Key %s\n",debugstr_w(*key));
......
......@@ -1233,7 +1233,7 @@ void _searchenv(const char* file, const char* env, char *buf)
msvcrt_set_errno(ERROR_FILE_NOT_FOUND);
return;
}
strncpy(curPath, penv, end - penv);
memcpy(curPath, penv, end - penv);
if (curPath[end - penv] != '/' || curPath[end - penv] != '\\')
{
curPath[end - penv] = '\\';
......
......@@ -821,17 +821,15 @@ DWORD WINAPI VideoCapDriverDescAndVer16(WORD nr, LPSTR buf1, WORD buf1len,
infobuf = HeapAlloc(GetProcessHeap(), 0, infosize);
if (GetFileVersionInfoA(fn, verhandle, infosize, infobuf))
{
char vbuf[200];
/* Yes, two space behind : */
/* FIXME: test for buflen */
sprintf(vbuf, "Version: %d.%d.%d.%d\n",
snprintf(buf2, buf2len, "Version: %d.%d.%d.%d\n",
((WORD*)infobuf)[0x0f],
((WORD*)infobuf)[0x0e],
((WORD*)infobuf)[0x11],
((WORD*)infobuf)[0x10]
);
TRACE("version of %s is %s\n", fn, vbuf);
strncpy(buf2, vbuf, buf2len);
TRACE("version of %s is %s\n", fn, buf2);
}
else
{
......
......@@ -390,7 +390,7 @@ void* WINAPI wglGetProcAddress(LPCSTR lpszProc) {
OpenGL drivers (moreover, it is only useful for old 1.0 apps
that query the glBindTextureEXT extension).
*/
strncpy(buf, ext_ret->glx_name, strlen(ext_ret->glx_name) - 3);
memcpy(buf, ext_ret->glx_name, strlen(ext_ret->glx_name) - 3);
buf[strlen(ext_ret->glx_name) - 3] = '\0';
TRACE(" extension not found in the Linux OpenGL library, checking against libGL bug with %s..\n", buf);
......
......@@ -307,7 +307,7 @@ HRESULT DSoundRender_create(IUnknown * pUnkOuter, LPVOID * ppv)
/* construct input pin */
piInput.dir = PINDIR_INPUT;
piInput.pFilter = (IBaseFilter *)pDSoundRender;
strncpyW(piInput.achName, wcsInputPinName, sizeof(piInput.achName) / sizeof(piInput.achName[0]));
lstrcpynW(piInput.achName, wcsInputPinName, sizeof(piInput.achName) / sizeof(piInput.achName[0]));
hr = DSoundRender_InputPin_Construct(&piInput, DSoundRender_Sample, (LPVOID)pDSoundRender, DSoundRender_QueryAccept, &pDSoundRender->csFilter, (IPin **)&pDSoundRender->pInputPin);
if (SUCCEEDED(hr))
......
......@@ -78,7 +78,7 @@ HRESULT Parser_Create(ParserImpl* pParser, const CLSID* pClsid, PFN_PROCESS_SAMP
/* construct input pin */
piInput.dir = PINDIR_INPUT;
piInput.pFilter = (IBaseFilter *)pParser;
strncpyW(piInput.achName, wcsInputPinName, sizeof(piInput.achName) / sizeof(piInput.achName[0]));
lstrcpynW(piInput.achName, wcsInputPinName, sizeof(piInput.achName) / sizeof(piInput.achName[0]));
hr = Parser_InputPin_Construct(&piInput, fnProcessSample, (LPVOID)pParser, fnQueryAccept, &pParser->csFilter, (IPin **)&pParser->pInputPin);
......
......@@ -196,10 +196,10 @@ HRESULT TransformFilter_Create(TransformFilterImpl* pTransformFilter, const CLSI
/* construct input pin */
piInput.dir = PINDIR_INPUT;
piInput.pFilter = (IBaseFilter *)pTransformFilter;
strncpyW(piInput.achName, wcsInputPinName, sizeof(piInput.achName) / sizeof(piInput.achName[0]));
lstrcpynW(piInput.achName, wcsInputPinName, sizeof(piInput.achName) / sizeof(piInput.achName[0]));
piOutput.dir = PINDIR_OUTPUT;
piOutput.pFilter = (IBaseFilter *)pTransformFilter;
strncpyW(piOutput.achName, wcsOutputPinName, sizeof(piOutput.achName) / sizeof(piOutput.achName[0]));
lstrcpynW(piOutput.achName, wcsOutputPinName, sizeof(piOutput.achName) / sizeof(piOutput.achName[0]));
hr = TransformFilter_InputPin_Construct(&piInput, TransformFilter_Sample, (LPVOID)pTransformFilter, TransformFilter_Input_QueryAccept, &pTransformFilter->csFilter, &pTransformFilter->ppPins[0]);
......
......@@ -352,7 +352,7 @@ HRESULT VideoRenderer_create(IUnknown * pUnkOuter, LPVOID * ppv)
/* construct input pin */
piInput.dir = PINDIR_INPUT;
piInput.pFilter = (IBaseFilter *)pVideoRenderer;
strncpyW(piInput.achName, wcsInputPinName, sizeof(piInput.achName) / sizeof(piInput.achName[0]));
lstrcpynW(piInput.achName, wcsInputPinName, sizeof(piInput.achName) / sizeof(piInput.achName[0]));
hr = VideoRenderer_InputPin_Construct(&piInput, VideoRenderer_Sample, (LPVOID)pVideoRenderer, VideoRenderer_QueryAccept, &pVideoRenderer->csFilter, (IPin **)&pVideoRenderer->pInputPin);
......
......@@ -228,7 +228,7 @@ static HRESULT WAVEParser_InputPin_PreConnect(IPin * iface, IPin * pConnectPin)
piOutput.dir = PINDIR_OUTPUT;
piOutput.pFilter = (IBaseFilter *)This;
strncpyW(piOutput.achName, wcsOutputPinName, sizeof(piOutput.achName) / sizeof(piOutput.achName[0]));
lstrcpynW(piOutput.achName, wcsOutputPinName, sizeof(piOutput.achName) / sizeof(piOutput.achName[0]));
hr = IAsyncReader_SyncRead(This->pReader, pos, sizeof(list), (BYTE *)&list);
pos += sizeof(list);
......
......@@ -959,15 +959,13 @@ static HCRYPTPROV new_key_container(PCHAR pszContainerName, DWORD dwFlags, PVTab
destroy_key_container, (OBJECTHDR**)&pKeyContainer);
if (hKeyContainer != (HCRYPTPROV)INVALID_HANDLE_VALUE)
{
strncpy(pKeyContainer->szName, pszContainerName, MAX_PATH);
pKeyContainer->szName[MAX_PATH-1] = '\0';
lstrcpynA(pKeyContainer->szName, pszContainerName, MAX_PATH);
pKeyContainer->dwFlags = dwFlags;
pKeyContainer->dwEnumAlgsCtr = 0;
pKeyContainer->hKeyExchangeKeyPair = (HCRYPTKEY)INVALID_HANDLE_VALUE;
pKeyContainer->hSignatureKeyPair = (HCRYPTKEY)INVALID_HANDLE_VALUE;
if (pVTable && pVTable->pszProvName) {
strncpy(pKeyContainer->szProvName, pVTable->pszProvName, MAX_PATH);
pKeyContainer->szProvName[MAX_PATH-1] = '\0';
lstrcpynA(pKeyContainer->szProvName, pVTable->pszProvName, MAX_PATH);
if (!strcmp(pVTable->pszProvName, MS_DEF_PROV_A)) {
pKeyContainer->dwPersonality = RSAENH_PERSONALITY_BASE;
} else if (!strcmp(pVTable->pszProvName, MS_ENHANCED_PROV_A)) {
......
......@@ -891,7 +891,7 @@ static HDEVINFO SETUP_CreateSerialDeviceList(void)
{
if (!strncmpW(comW, ptr, sizeof(comW) / sizeof(comW[0]) - 1))
{
strncpyW(list->names[list->numPorts].name, ptr,
lstrcpynW(list->names[list->numPorts].name, ptr,
sizeof(list->names[list->numPorts].name) /
sizeof(list->names[list->numPorts].name[0]));
TRACE("Adding %s to list\n",
......
......@@ -363,9 +363,7 @@ static INT_PTR sc_FNNOTIFY_A(FDINOTIFICATIONTYPE fdint, PFDINOTIFICATION pfdin)
} else {
if (mysterio[0]) {
/* some easy paranoia. no such carefulness exists on the wide API IIRC */
mysterio[SIZEOF_MYSTERIO - 1] = '\0';
strncpy(pfdin->psz3, &(mysterio[0]), 255);
mysterio[255] = '\0';
lstrcpynA(pfdin->psz3, &(mysterio[0]), SIZEOF_MYSTERIO);
}
return 0;
}
......
......@@ -168,14 +168,14 @@ LPWSTR WINAPI PathCombineW(LPWSTR lpszDest, LPCWSTR lpszDir, LPCWSTR lpszFile)
if (!lpszFile || !*lpszFile)
{
/* Use dir only */
strncpyW(szTemp, lpszDir, MAX_PATH);
lstrcpynW(szTemp, lpszDir, MAX_PATH);
}
else if (!lpszDir || !*lpszDir || !PathIsRelativeW(lpszFile))
{
if (!lpszDir || !*lpszDir || *lpszFile != '\\' || PathIsUNCW(lpszFile))
{
/* Use file only */
strncpyW(szTemp, lpszFile, MAX_PATH);
lstrcpynW(szTemp, lpszFile, MAX_PATH);
}
else
{
......@@ -188,7 +188,7 @@ LPWSTR WINAPI PathCombineW(LPWSTR lpszDest, LPCWSTR lpszDir, LPCWSTR lpszFile)
if (bUseBoth)
{
strncpyW(szTemp, lpszDir, MAX_PATH);
lstrcpynW(szTemp, lpszDir, MAX_PATH);
if (bStrip)
{
PathStripToRootW(szTemp);
......@@ -2845,7 +2845,7 @@ BOOL WINAPI PathCompactPathW(HDC hDC, LPWSTR lpszPath, UINT dx)
* the file name as possible, allowing for the ellipses, e.g:
* c:\some very long path\filename ==> c:\some v...\filename
*/
strncpyW(buff, sFile, MAX_PATH);
lstrcpynW(buff, sFile, MAX_PATH);
do
{
......@@ -3397,8 +3397,8 @@ BOOL WINAPI PathRelativePathToW(LPWSTR lpszPath, LPCWSTR lpszFrom, DWORD dwAttrF
return FALSE;
*lpszPath = '\0';
strncpyW(szFrom, lpszFrom, MAX_PATH);
strncpyW(szTo, lpszTo, MAX_PATH);
lstrcpynW(szFrom, lpszFrom, MAX_PATH);
lstrcpynW(szTo, lpszTo, MAX_PATH);
if(!(dwAttrFrom & FILE_ATTRIBUTE_DIRECTORY))
PathRemoveFileSpecW(szFrom);
......@@ -3746,7 +3746,7 @@ BOOL WINAPI PathIsDirectoryEmptyW(LPCWSTR lpszPath)
if (!lpszPath || !PathIsDirectoryW(lpszPath))
return FALSE;
strncpyW(szSearch, lpszPath, MAX_PATH);
lstrcpynW(szSearch, lpszPath, MAX_PATH);
PathAddBackslashW(szSearch);
dwLen = strlenW(szSearch);
if (dwLen > MAX_PATH - 4)
......
......@@ -1577,7 +1577,7 @@ LPSTR WINAPI StrFormatKBSizeA(LONGLONG llBytes, LPSTR lpszDest, UINT cchMax)
ulKB = (ulKB - ulNextDigit) / 10;
} while (ulKB > 0);
strncpy(lpszDest, szOut + 1, cchMax);
lstrcpynA(lpszDest, szOut + 1, cchMax);
return lpszDest;
}
......@@ -1605,7 +1605,7 @@ LPWSTR WINAPI StrFormatKBSizeW(LONGLONG llBytes, LPWSTR lpszDest, UINT cchMax)
ulKB = (ulKB - ulNextDigit) / 10;
} while (ulKB > 0);
strncpyW(lpszDest, szOut + 1, cchMax);
lstrcpynW(lpszDest, szOut + 1, cchMax);
return lpszDest;
}
......@@ -2027,7 +2027,7 @@ INT WINAPI StrFromTimeIntervalW(LPWSTR lpszStr, UINT cchMax, DWORD dwMS,
if (iDigits) /* Always write seconds if we have significant digits */
SHLWAPI_WriteTimeClass(szCopy, dwMS, szSec, iDigits);
strncpyW(lpszStr, szCopy, cchMax);
lstrcpynW(lpszStr, szCopy, cchMax);
iRet = strlenW(lpszStr);
}
return iRet;
......@@ -2301,7 +2301,7 @@ LPWSTR WINAPI StrFormatByteSizeW(LONGLONG llBytes, LPWSTR lpszDest, UINT cchMax)
sprintfW(wszBuff, bfFormats[i].lpwszFormat, dBytes);
wszAdd[1] = bfFormats[i].wPrefix;
strcatW(wszBuff, wszAdd);
strncpyW(lpszDest, wszBuff, cchMax);
lstrcpynW(lpszDest, wszBuff, cchMax);
return lpszDest;
}
......@@ -2638,9 +2638,6 @@ DWORD WINAPI SHAnsiToAnsi(LPCSTR lpszSrc, LPSTR lpszDst, int iLen)
TRACE("(%s,%p,0x%08x)\n", debugstr_a(lpszSrc), lpszDst, iLen);
/* Our original version used lstrncpy/lstrlen, incorrectly filling up all
* of lpszDst with extra NULs. This version is correct, and faster too.
*/
lpszRet = StrCpyNXA(lpszDst, lpszSrc, iLen);
return lpszRet - lpszDst + 1;
}
......
......@@ -329,7 +329,7 @@ HRESULT WINAPI UrlCanonicalizeW(LPCWSTR pszUrl, LPWSTR pszCanonicalized,
DWORD EscapeFlags;
LPWSTR lpszUrlCpy, wk1, wk2, mp, root;
INT nByteLen, state;
DWORD nLen;
DWORD nLen, nWkLen;
TRACE("(%s %p %p 0x%08lx)\n", debugstr_w(pszUrl), pszCanonicalized,
pcchCanonicalized, dwFlags);
......@@ -379,9 +379,10 @@ HRESULT WINAPI UrlCanonicalizeW(LPCWSTR pszUrl, LPWSTR pszCanonicalized,
state = 4;
break;
case 3:
strcpyW(wk2, wk1);
wk1 += strlenW(wk1);
wk2 += strlenW(wk2);
nWkLen = strlenW(wk1);
memcpy(wk2, wk1, (nWkLen + 1) * sizeof(WCHAR));
wk1 += nWkLen;
wk2 += nWkLen;
break;
case 4:
if (!isalnumW(*wk1) && (*wk1 != L'-') && (*wk1 != L'.')) {state = 3; break;}
......@@ -401,13 +402,14 @@ HRESULT WINAPI UrlCanonicalizeW(LPCWSTR pszUrl, LPWSTR pszCanonicalized,
TRACE("wk1=%c\n", (CHAR)*wk1);
mp = strchrW(wk1, L'/');
if (!mp) {
strcpyW(wk2, wk1);
wk1 += strlenW(wk1);
wk2 += strlenW(wk2);
nWkLen = strlenW(wk1);
memcpy(wk2, wk1, (nWkLen + 1) * sizeof(WCHAR));
wk1 += nWkLen;
wk2 += nWkLen;
continue;
}
nLen = mp - wk1 + 1;
strncpyW(wk2, wk1, nLen);
memcpy(wk2, wk1, nLen * sizeof(WCHAR));
wk2 += nLen;
wk1 += nLen;
if (*wk1 == L'.') {
......
......@@ -53,8 +53,7 @@ DWORD WINAPI tapiGetLocationInfoA(LPSTR lpszCountryCode, LPSTR lpszCityCode)
bufsize=sizeof(buf);
if( !RegQueryValueExA( hsubkey, "AreaCode", 0, &type, buf,
&bufsize) && type == REG_SZ) {
strncpy( lpszCityCode, (char *) buf, 8);
if(bufsize > 8) lpszCityCode[7] = '\0';
lstrcpynA( lpszCityCode, (char *) buf, 8);
} else
lpszCityCode[0] = '\0';
}
......
......@@ -189,8 +189,7 @@ void PSDRV_AFM2C(const AFM *afm)
FILE *of;
int i;
strncpy(buffer, afm->FontName, sizeof(buffer) - 3);
buffer[sizeof(buffer) - 3] = '\0';
lstrcpynA(buffer, afm->FontName, sizeof(buffer) - 2);
for (i = 0; i < strlen(buffer); ++i)
if (buffer[i] == '-')
......
......@@ -410,6 +410,7 @@ BOOL WINAPI InternetSetCookieW(LPCWSTR lpszUrl, LPCWSTR lpszCookieName,
WCHAR *ourCookieName, *ourCookieData;
int ourCookieNameSize;
BOOL ret;
if (!(ourCookieData = strchrW(lpCookieData, '=')))
{
TRACE("something terribly wrong with cookie data %s\n",
......@@ -420,7 +421,7 @@ BOOL WINAPI InternetSetCookieW(LPCWSTR lpszUrl, LPCWSTR lpszCookieName,
ourCookieData += 1;
ourCookieName = HeapAlloc(GetProcessHeap(), 0,
(ourCookieNameSize + 1)*sizeof(WCHAR));
strncpyW(ourCookieName, ourCookieData, ourCookieNameSize);
memcpy(ourCookieName, ourCookieData, ourCookieNameSize * sizeof(WCHAR));
ourCookieName[ourCookieNameSize] = '\0';
TRACE("setting (hacked) cookie of %s, %s\n",
debugstr_w(ourCookieName), debugstr_w(ourCookieData));
......
......@@ -2777,7 +2777,7 @@ BOOL FTP_ConvertFileProp(LPFILEPROPERTIESW lpafp, LPWIN32_FIND_DATAW lpFindFileD
lpFindFileData->dwFileAttributes |= FILE_ATTRIBUTE_DIRECTORY;
if (lpafp->lpszName)
strncpyW(lpFindFileData->cFileName, lpafp->lpszName, MAX_PATH);
lstrcpynW(lpFindFileData->cFileName, lpafp->lpszName, MAX_PATH);
bSuccess = TRUE;
}
......
......@@ -178,8 +178,7 @@ static BOOL WINAPI HTTP_HttpAddRequestHeadersW(LPWININETHTTPREQW lpwhr,
else
len = dwHeaderLength;
buffer = HeapAlloc( GetProcessHeap(), 0, sizeof(WCHAR)*(len+1) );
strncpyW( buffer, lpszHeader, len );
buffer[len]=0;
lstrcpynW( buffer, lpszHeader, len + 1);
lpszStart = buffer;
......@@ -1722,14 +1721,12 @@ BOOL WINAPI HTTP_HttpSendRequestW(LPWININETHTTPREQW lpwhr, LPCWSTR lpszHeaders,
nDomainPosStart = strlenW(szDomain);
nDomainLength = (nDomainPosEnd - nDomainPosStart) + 1;
domain = HeapAlloc(GetProcessHeap(), 0, (nDomainLength + 1)*sizeof(WCHAR));
strncpyW(domain, &lpszDomain[nDomainPosStart], nDomainLength);
domain[nDomainLength] = '\0';
lstrcpynW(domain, &lpszDomain[nDomainPosStart], nDomainLength + 1);
}
}
if (setCookieHeader->lpszValue[nPosEnd] == '\0') break;
buf_cookie = HeapAlloc(GetProcessHeap(), 0, ((nPosEnd - nPosStart) + 1)*sizeof(WCHAR));
strncpyW(buf_cookie, &setCookieHeader->lpszValue[nPosStart], (nPosEnd - nPosStart));
buf_cookie[(nPosEnd - nPosStart)] = '\0';
lstrcpynW(buf_cookie, &setCookieHeader->lpszValue[nPosStart], (nPosEnd - nPosStart) + 1);
TRACE("%s\n", debugstr_w(buf_cookie));
while (buf_cookie[nEqualPos] != '=' && buf_cookie[nEqualPos] != '\0')
{
......@@ -1742,8 +1739,7 @@ BOOL WINAPI HTTP_HttpSendRequestW(LPWININETHTTPREQW lpwhr, LPCWSTR lpszHeaders,
}
cookie_name = HeapAlloc(GetProcessHeap(), 0, (nEqualPos + 1)*sizeof(WCHAR));
strncpyW(cookie_name, buf_cookie, nEqualPos);
cookie_name[nEqualPos] = '\0';
lstrcpynW(cookie_name, buf_cookie, nEqualPos + 1);
cookie_data = &buf_cookie[nEqualPos + 1];
......
......@@ -1163,8 +1163,7 @@ static INTERNET_SCHEME GetInternetSchemeW(LPCWSTR lpszScheme, DWORD nMaxCmp)
return INTERNET_SCHEME_UNKNOWN;
tempBuffer=HeapAlloc(GetProcessHeap(),0,(nMaxCmp+1)*sizeof(WCHAR));
strncpyW(tempBuffer,lpszScheme,nMaxCmp);
tempBuffer[nMaxCmp]=0;
lstrcpynW(tempBuffer,lpszScheme,nMaxCmp+1);
strlwrW(tempBuffer);
if (nMaxCmp==strlenW(lpszFtp) && !strncmpW(lpszFtp, tempBuffer, nMaxCmp))
iScheme=INTERNET_SCHEME_FTP;
......
......@@ -1959,8 +1959,7 @@ INT WINAPI WSAIoctl(SOCKET s,
struct ifreq ifInfo;
/* Socket Status Flags */
strncpy(ifInfo.ifr_name, ptr->AdapterName, IFNAMSIZ);
ifInfo.ifr_name[IFNAMSIZ-1] = '\0';
lstrcpynA(ifInfo.ifr_name, ptr->AdapterName, IFNAMSIZ);
if (ioctl(fd, SIOCGIFFLAGS, &ifInfo) < 0)
{
ERR("Error obtaining status flags for socket!\n");
......
......@@ -145,7 +145,7 @@ static LPWSTR build_properties(struct string_list *property_list)
continue;
len = value - list->str;
*p++ = ' ';
strncpyW(p, list->str, len);
memcpy(p, list->str, len * sizeof(WCHAR));
p += len;
*p++ = '=';
......@@ -155,7 +155,7 @@ static LPWSTR build_properties(struct string_list *property_list)
if(needs_quote)
*p++ = '"';
len = lstrlenW(value);
strncpyW(p, value, len);
memcpy(p, value, len * sizeof(WCHAR));
p += len;
if(needs_quote)
*p++ = '"';
......
......@@ -528,7 +528,7 @@ HKEY getRegClass(LPSTR lpClass)
if (lpClass == NULL)
return (HKEY)ERROR_INVALID_PARAMETER;
strncpy(lpClassCopy, lpClass, KEY_MAX_LEN);
lstrcpynA(lpClassCopy, lpClass, KEY_MAX_LEN);
classNameEnd = strchr(lpClassCopy, '\\'); /* The class name ends by '\' */
if (!classNameEnd) /* or the whole string */
......@@ -792,8 +792,7 @@ void processQueryValue(LPSTR cmdline)
if (hRes == ERROR_SUCCESS) {
lpsRes = HeapAlloc( GetProcessHeap(), 0, lLen);
strncpy(lpsRes, lpsData, lLen);
lpsRes[lLen-1]='\0';
lstrcpynA(lpsRes, lpsData, lLen);
}
} else {
DWORD dwLen = KEY_MAX_LEN;
......@@ -823,8 +822,7 @@ void processQueryValue(LPSTR cmdline)
case REG_SZ:
case REG_EXPAND_SZ: {
lpsRes = HeapAlloc( GetProcessHeap(), 0, dwLen);
strncpy(lpsRes, lpbData, dwLen);
lpsRes[dwLen-1]='\0';
lstrcpynA(lpsRes, lpbData, dwLen);
break;
}
case REG_DWORD: {
......
......@@ -230,7 +230,7 @@ void load_drives()
WINE_TRACE("serial: '0x%lX'\n", serial);
/* build rootpath for GetDriveType() */
strncpy(rootpath, devices, sizeof(rootpath));
lstrcpynA(rootpath, devices, sizeof(rootpath));
pathlen = strlen(rootpath);
/* ensure that we have a backslash on the root path */
......@@ -240,8 +240,8 @@ void load_drives()
rootpath[pathlen + 1] = 0;
}
strncpy(simplepath, devices, 2); /* QueryDosDevice() requires no trailing backslash */
simplepath[2] = 0;
/* QueryDosDevice() requires no trailing backslash */
lstrcpynA(simplepath, devices, 3);
QueryDosDevice(simplepath, targetpath, sizeof(targetpath));
/* targetpath may have forward slashes rather than backslashes, so correct */
......
......@@ -242,8 +242,7 @@ BOOL memory_get_string(HANDLE hp, void* addr, BOOL in_debuggee, BOOL unicode,
}
else
{
strncpy(buffer, addr, size);
buffer[size - 1] = 0;
lstrcpynA(buffer, addr, size);
}
return TRUE;
}
......
......@@ -390,7 +390,7 @@ void SaveBoard( BOARD *p_board )
for( i = 0; i < 3; i++ ) {
wsprintf( key_name, "Name%u", i );
strncpy( data, p_board->best_name[i], sizeof( data ) );
lstrcpyn( data, p_board->best_name[i], sizeof( data ) );
RegSetValueEx( hkey, key_name, 0, REG_SZ, (LPBYTE) data, strlen(data)+1 );
}
......
......@@ -2047,7 +2047,7 @@ static void SPY_GetMsgStuff( SPY_INSTANCE *sp_e )
p = SPY_Bsearch_Msg (cc_array[i].classmsg, cc_array[i].lastmsg,
sp_e->msgnum);
if (p) {
strncpy (sp_e->msg_name, p->name, sizeof(sp_e->msg_name)-1);
lstrcpynA (sp_e->msg_name, p->name, sizeof(sp_e->msg_name));
sp_e->data_len = p->len;
return;
}
......@@ -2059,8 +2059,7 @@ static void SPY_GetMsgStuff( SPY_INSTANCE *sp_e )
}
else
{
strncpy(sp_e->msg_name, msg_name, sizeof(sp_e->msg_name)-1);
sp_e->msg_name[sizeof(sp_e->msg_name)-1] = 0;
lstrcpynA(sp_e->msg_name, msg_name, sizeof(sp_e->msg_name));
}
}
......
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