[dlls/kernel/profile.c] Strncpy elimination.
Peter Berg Larsen
pebl at math.ku.dk
Sun Mar 27 13:01:04 CST 2005
Changelog:
Renaming f to buflen, l to tmplen. Replaced strncpy with memcpy.
Index: dlls/kernel/profile.c
===================================================================
RCS file: /home/wine/wine/dlls/kernel/profile.c,v
retrieving revision 1.20
diff -u -r1.20 profile.c
--- dlls/kernel/profile.c 4 Mar 2005 10:46:55 -0000 1.20
+++ dlls/kernel/profile.c 26 Mar 2005 09:40:37 -0000
@@ -899,7 +899,7 @@
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 @@
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;
}
@@ -1108,8 +1108,9 @@
int len = (int)(p - def_val);
LPWSTR p;
+ /* strdupW? */
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;
}
More information about the wine-patches
mailing list