[libs/wine/*] Strncpy elimination.
Peter Berg Larsen
pebl at math.ku.dk
Sun Mar 27 12:21:20 CST 2005
I have been checking the usage of strncpy, replacing where apropriate with
a memcpy or lstrcpyn[AW]. The first raw diff was 100kb, so there is bound
to be one or two slips. These are the first batch which I found to be
obvious, correct, and didnt need a special comment. Note with correct I
mean if there was a \0 bug before then it still there.
Changelog:
Janitorial Task: Check the usage of strncpy/strncpyW.
Index: libs/wine/debug.c
===================================================================
RCS file: /home/wine/wine/libs/wine/debug.c,v
retrieving revision 1.4
diff -u -r1.4 debug.c
--- libs/wine/debug.c 22 Sep 2004 02:46:38 -0000 1.4
+++ libs/wine/debug.c 26 Mar 2005 09:41:49 -0000
@@ -126,8 +126,7 @@
opt->next = NULL;
opt->set = set;
opt->clear = clear;
- strncpy( opt->name, name, sizeof(opt->name) );
- opt->name[sizeof(opt->name)-1] = 0;
+ lstrcpynA( opt->name, name, sizeof(opt->name) );
if (last_option) last_option->next = opt;
else first_option = opt;
last_option = opt;
Index: libs/wine/loader.c
===================================================================
RCS file: /home/wine/wine/libs/wine/loader.c,v
retrieving revision 1.23
diff -u -r1.23 loader.c
--- libs/wine/loader.c 23 Mar 2005 13:15:18 -0000 1.23
+++ libs/wine/loader.c 26 Mar 2005 09:41:50 -0000
@@ -567,18 +567,12 @@
ret = dlopen( filename, flag );
s = dlerror();
if (error)
- {
- strncpy( error, s ? s : "", errorsize );
- error[errorsize - 1] = '\0';
- }
+ lstrcpynA( error, s ? s : "", errorsize );
dlerror();
return ret;
#else
if (error)
- {
- strncpy( error, "dlopen interface not detected by configure", errorsize );
- error[errorsize - 1] = '\0';
- }
+ lstrcpynA( error, "dlopen interface not detected by configure", errorsize );
return NULL;
#endif
}
@@ -595,18 +589,12 @@
ret = dlsym( handle, symbol );
s = dlerror();
if (error)
- {
- strncpy( error, s ? s : "", errorsize );
- error[errorsize - 1] = '\0';
- }
+ lstrcpynA( error, s ? s : "", errorsize );
dlerror();
return ret;
#else
if (error)
- {
- strncpy( error, "dlopen interface not detected by configure", errorsize );
- error[errorsize - 1] = '\0';
- }
+ lstrcpynA( error, "dlopen interface not detected by configure", errorsize );
return NULL;
#endif
}
@@ -623,18 +611,12 @@
ret = dlclose( handle );
s = dlerror();
if (error)
- {
- strncpy( error, s ? s : "", errorsize );
- error[errorsize - 1] = '\0';
- }
+ lstrcpynA( error, s ? s : "", errorsize );
dlerror();
return ret;
#else
if (error)
- {
- strncpy( error, "dlopen interface not detected by configure", errorsize );
- error[errorsize - 1] = '\0';
- }
+ lstrcpynA( error, "dlopen interface not detected by configure", errorsize );
return 1;
#endif
}
More information about the wine-patches
mailing list