[LOSTWAGES] Add janitorial task to avoid using strncpy

Mike McCormack mike at codeweavers.com
Thu Jan 13 09:17:21 CST 2005

* Add janitorial task to avoid using strncpy
-------------- next part --------------
Index: templates/en/janitorial.template
RCS file: /home/wine/lostwages/templates/en/janitorial.template,v
retrieving revision 1.61
diff -u -r1.61 janitorial.template
--- templates/en/janitorial.template	11 Jan 2005 20:33:41 -0000	1.61
+++ templates/en/janitorial.template	13 Jan 2005 15:15:44 -0000
@@ -7,6 +7,24 @@
   Janitor's List</a>), and it's high time that we have one too.
   What is there to clean up? Well, lots of things! :)
+  <h2>Eliminate uses of strncpy/strncpyW</h2>
+  <i>strncpy(dst,src,n)</i> has two subtle
+  <a href="http://weblogs.asp.net/oldnewthing/archive/2005/01/07.aspx">
+  problems</a>.  The first is that it always fills the whole <i>dst</i>
+  buffer (<i>n</i> characters).  The second is that it doesn't always nul
+  terminate the <i>dst</i> buffer that it's filling.<p>
+  Wine code should avoid the use of strncpy for these reasons, and instead
+  use lstrcpyA/W or memcpy. You can use the following command to find
+  occurences of strncpy in the Wine source code:<p>
+  <tt>find . -name \*.c -exec grep strncpy {} \; -ls</tt><p>
+  The aim is to make sure that we only copy as many bytes as necessary into
+  the <i>dst</i> buffer, and always nul terminate the buffer when we
+  intended to.<p>
   <h2>Regedit fixes</h2>
   Regedit lacks a few features.  We need to improve regedit to:

More information about the wine-patches mailing list