Strncpy elimination post process
Peter Berg Larsen
pebl at math.ku.dk
Fri Apr 22 06:07:23 CDT 2005
Hmm someone was faster than I to clean up the missing strncpy. Could I
suggest the following patch I had done as it seems cleaner and in the
style I have replace the others with?
Changelog:
Cleanup of the strncpy elimination.
Index: dlls/advapi32/security.c
===================================================================
RCS file: /home/wine/wine/dlls/advapi32/security.c,v
retrieving revision 1.101
diff -u -r1.101 security.c
--- dlls/advapi32/security.c 21 Apr 2005 17:18:51 -0000 1.101
+++ dlls/advapi32/security.c 22 Apr 2005 09:52:43 -0000
@@ -2669,7 +2669,7 @@
WCHAR tok[MAX_PATH];
LPCWSTR lptoken;
LPBYTE lpNext = NULL;
- DWORD len;
+ DWORD toklen;
*cBytes = 0;
@@ -2690,17 +2690,15 @@
StringSecurityDescriptor++;
/* Extract token */
+ toklen = 0;
lptoken = StringSecurityDescriptor;
while (*lptoken && *lptoken != ':')
- lptoken++;
+ tok[toklen++] = *lptoken++;
+ tok[toklen] = '\0';
- if (*lptoken)
+ if (*lptoken) /* e.g. *lptoken == ':' */
lptoken--;
- len = lptoken - StringSecurityDescriptor;
- memcpy( tok, StringSecurityDescriptor, len * sizeof(WCHAR) );
- tok[len] = 0;
-
switch (toktype)
{
case 'O':
Index: dlls/ntdll/time.c
===================================================================
RCS file: /home/wine/wine/dlls/ntdll/time.c,v
retrieving revision 1.67
diff -u -r1.67 time.c
--- dlls/ntdll/time.c 21 Apr 2005 17:18:51 -0000 1.67
+++ dlls/ntdll/time.c 22 Apr 2005 09:52:49 -0000
@@ -866,10 +866,10 @@
RtlInitUnicodeString( &nameW, valkey );\
if (!NtQueryValueKey( hkey, &nameW, KeyValuePartialInformation, KpInfo,\
sizeof(buf), &size )) { \
- size_t len = (strlenW( (WCHAR*)KpInfo->Data ) + 1) * sizeof(WCHAR); \
- if (len > sizeof(tofield)) len = sizeof(tofield); \
- memcpy( tofield, KpInfo->Data, len ); \
- tofield[(len/sizeof(WCHAR))-1] = 0; \
+ size_t len = min(strlenW( (WCHAR*)KpInfo->Data ), \
+ sizeof(tofield)/sizeof(WCHAR)-1); \
+ memcpy( tofield, KpInfo->Data, len * sizeof(WCHAR) ); \
+ tofield[len] = 0; \
}
GTZIFR_N( TZStandardStartW, tzinfo->StandardDate)
More information about the wine-patches
mailing list