[dlls/kernel/*] Strncpy elimination
Peter Berg Larsen
pebl at math.ku.dk
Fri Apr 15 17:10:25 CDT 2005
I am really puzzle about the constanst in the code. Am I correct in the
first hunk that the country and language code is 2 wchars and a \0?
And in the second hunk, that the only reason to do a temporary name buffer
is that GetModuleName16 always adds an \0 to the name?
Changelog:
Eliminate some strncpys and remove some constants in the code.
Index: dlls/kernel/locale.c
===================================================================
RCS file: /home/wine/wine/dlls/kernel/locale.c,v
retrieving revision 1.58
diff -u -r1.58 locale.c
--- dlls/kernel/locale.c 29 Mar 2005 11:34:03 -0000 1.58
+++ dlls/kernel/locale.c 15 Apr 2005 20:14:15 -0000
@@ -395,8 +395,10 @@
found:
l_data->found_lang_id[l_data->n_found] = LangID;
- strncpyW(l_data->found_country[l_data->n_found], buf_country, 3);
- strncpyW(l_data->found_language[l_data->n_found], buf_language, 3);
+ lstrcpynW(l_data->found_country[l_data->n_found], buf_country,
+ sizeof(l_data->found_country[0])/sizeof(WCHAR));
+ lstrcpynW(l_data->found_language[l_data->n_found], buf_language,
+ sizeof(l_data->found_country[0])/sizeof(WCHAR));
l_data->n_found++;
TRACE("Found id %04X for lang %s\n", LangID, debugstr_w(l_data->lang));
return (l_data->n_found < NLS_MAX_LANGUAGES); /* continue search, unless we have enough */
Index: dlls/kernel/task.c
===================================================================
RCS file: /home/wine/wine/dlls/kernel/task.c,v
retrieving revision 1.19
diff -u -r1.19 task.c
--- dlls/kernel/task.c 3 Nov 2004 22:18:44 -0000 1.19
+++ dlls/kernel/task.c 15 Apr 2005 20:14:17 -0000
@@ -293,9 +293,9 @@
if (hModule)
{
- char name[10];
+ char name[sizeof(pTask->module_name)+1];
GetModuleName16( hModule, name, sizeof(name) );
- strncpy( pTask->module_name, name, sizeof(pTask->module_name) );
+ memcpy(pTask->module_name, name, sizeof(pTask->module_name));
pTask->compat_flags = GetProfileIntA( "Compatibility", name, 0 );
}
More information about the wine-patches
mailing list