For strings, shouldn't you still use strncpy?  I think it is better to use the strncpy because it will not copy beyond the \0 regardless of the value of n.<br><br><div class="gmail_quote">On Fri, Aug 27, 2010 at 3:10 AM, <a href="mailto:rtems-vc@rtems.org">rtems-vc@rtems.org</a> <span dir="ltr"><<a href="mailto:rtems-vc@rtems.org">rtems-vc@rtems.org</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="margin: 0pt 0pt 0pt 0.8ex; border-left: 1px solid rgb(204, 204, 204); padding-left: 1ex;">




<div text="#000000" bgcolor="#ffffff">
<a name="12ab26218e53c1dc_cs1"></a>
<table bgcolor="#eeeeee" border="0" cellpadding="5" cellspacing="0" width="100%">
<tbody><tr><td colspan="3" bgcolor="#dddddd">
 <font color="#bb2222"><b>sh</b></font>
</td></tr>
<tr><td colspan="3" bgcolor="#dddddd"><pre>2010-08-26     Sebastian Huber <<a href="mailto:sebastian.huber@embedded-brains.de" target="_blank">sebastian.huber@embedded-brains.de</a>>

        * libcsupport/src/mount.c: Avoid strcpy().
</pre></td></tr>
<tr><td width="1%"><a href="http://www.rtems.com/cgi-bin/viewcvs.cgi//rtems/cpukit/ChangeLog.diff?r1=text&tr1=1.2608&r2=text&tr2=1.2609&diff_format=h" target="_blank">M</a></td><td width="1%">1.2609</td><td width="100%">
cpukit/ChangeLog</td></tr>
<tr><td width="1%"><a href="http://www.rtems.com/cgi-bin/viewcvs.cgi//rtems/cpukit/libcsupport/src/mount.c.diff?r1=text&tr1=1.40&r2=text&tr2=1.41&diff_format=h" target="_blank">M</a></td><td width="1%">1.41</td>
<td width="100%">cpukit/libcsupport/src/mount.c</td></tr>
</tbody></table>
<pre><font color="#006600">diff -u rtems/cpukit/ChangeLog:1.2608 rtems/cpukit/ChangeLog:1.2609
--- rtems/cpukit/ChangeLog:1.2608       Thu Aug 26 16:42:21 2010
+++ rtems/cpukit/ChangeLog      Fri Aug 27 01:29:25 2010
</font><font color="#997700">@@ -1,3 +1,7 @@
</font><font color="#000088">+2010-08-26  Sebastian Huber <<a href="mailto:sebastian.huber@embedded-brains.de" target="_blank">sebastian.huber@embedded-brains.de</a>>
+
+       * libcsupport/src/mount.c: Avoid strcpy().
+
</font> 2010-08-26        Joel Sherrill <<a href="mailto:joel.sherrill@oarcorp.com" target="_blank">joel.sherrill@oarcorp.com</a>>
 
        * libcsupport/src/sync.c: Add comment explaining why the return value

<font color="#006600">diff -u rtems/cpukit/libcsupport/src/mount.c:1.40 rtems/cpukit/libcsupport/src/mount.c:1.41
--- rtems/cpukit/libcsupport/src/mount.c:1.40   Sun Jul  4 09:53:44 2010
+++ rtems/cpukit/libcsupport/src/mount.c        Fri Aug 27 01:29:26 2010
</font><font color="#997700">@@ -74,29 +74,27 @@
</font>   size_t filesystemtype_size = strlen( filesystemtype ) + 1;
   size_t source_size = source_or_null != NULL ?
     strlen( source_or_null ) + 1 : 0;
<font color="#880000">-  size_t target_length = strlen( target );
</font><font color="#000088">+  size_t target_size = strlen( target ) + 1;
</font>   size_t size = sizeof( rtems_filesystem_mount_table_entry_t )
<font color="#880000">-    + filesystemtype_size + source_size + target_length + 1;
</font><font color="#000088">+    + filesystemtype_size + source_size + target_size;
</font>   rtems_filesystem_mount_table_entry_t *mt_entry = calloc( 1, size );
 
   if ( mt_entry != NULL ) {
     char *str = (char *) mt_entry + sizeof( *mt_entry );
 
<font color="#880000">-    strcpy( str, filesystemtype );
</font><font color="#000088">+    memcpy( str, filesystemtype, filesystemtype_size );
</font>     mt_entry->type = str;
     str += filesystemtype_size;
 
<font color="#880000">-    if ( source_or_null != NULL ) {
-      strcpy( str, source_or_null );
-      mt_entry->dev = str;
-      str += source_size;
-    }
</font><font color="#000088">+    memcpy( str, source_or_null, source_size );
+    mt_entry->dev = str;
+    str += source_size;
</font> 
<font color="#880000">-    strcpy( str, target );
</font><font color="#000088">+    memcpy( str, target, target_size );
</font>     mt_entry->target = str;
   }
 
<font color="#880000">-  *target_length_ptr = target_length;
</font><font color="#000088">+  *target_length_ptr = target_size - 1;
</font> 
   return mt_entry;
 }
</pre>
<p> </p>
<a name="12ab26218e53c1dc_cs2"></a>
<table bgcolor="#eeeeee" border="0" cellpadding="5" cellspacing="0" width="100%">
<tbody><tr><td colspan="3" bgcolor="#dddddd">
 <font color="#bb2222"><b>sh</b></font>
</td></tr>
<tr><td colspan="3" bgcolor="#dddddd"><pre>2010-08-26     Sebastian Huber <<a href="mailto:sebastian.huber@embedded-brains.de" target="_blank">sebastian.huber@embedded-brains.de</a>>

        * libcsupport/src/mount.c, libcsupport/src/mount-mgr.c: Avoid
        strcpy().
</pre></td></tr>
<tr><td width="1%"><a href="http://www.rtems.com/cgi-bin/viewcvs.cgi//rtems/cpukit/ChangeLog.diff?r1=text&tr1=1.2609&r2=text&tr2=1.2610&diff_format=h" target="_blank">M</a></td><td width="1%">1.2610</td><td width="100%">
cpukit/ChangeLog</td></tr>
<tr><td width="1%"><a href="http://www.rtems.com/cgi-bin/viewcvs.cgi//rtems/cpukit/libcsupport/src/mount-mgr.c.diff?r1=text&tr1=1.5&r2=text&tr2=1.6&diff_format=h" target="_blank">M</a></td><td width="1%">
1.6</td><td width="100%">cpukit/libcsupport/src/mount-mgr.c</td></tr>
</tbody></table>
<pre><font color="#006600">diff -u rtems/cpukit/ChangeLog:1.2609 rtems/cpukit/ChangeLog:1.2610
--- rtems/cpukit/ChangeLog:1.2609       Fri Aug 27 01:29:25 2010
+++ rtems/cpukit/ChangeLog      Fri Aug 27 01:41:07 2010
</font><font color="#997700">@@ -1,6 +1,7 @@
</font> 2010-08-26        Sebastian Huber <<a href="mailto:sebastian.huber@embedded-brains.de" target="_blank">sebastian.huber@embedded-brains.de</a>>
 
<font color="#880000">- * libcsupport/src/mount.c: Avoid strcpy().
</font><font color="#000088">+    * libcsupport/src/mount.c, libcsupport/src/mount-mgr.c: Avoid
+       strcpy().
</font> 
 2010-08-26     Joel Sherrill <<a href="mailto:joel.sherrill@oarcorp.com" target="_blank">joel.sherrill@oarcorp.com</a>>
 

<font color="#006600">diff -u rtems/cpukit/libcsupport/src/mount-mgr.c:1.5 rtems/cpukit/libcsupport/src/mount-mgr.c:1.6
--- rtems/cpukit/libcsupport/src/mount-mgr.c:1.5        Sun Jul  4 09:53:44 2010
+++ rtems/cpukit/libcsupport/src/mount-mgr.c    Fri Aug 27 01:41:08 2010
</font><font color="#997700">@@ -110,14 +110,15 @@
</font>   rtems_filesystem_fsmount_me_t  mount_h
 )
 {
<font color="#880000">-  size_t fsn_size = sizeof( filesystem_node ) + strlen(type) + 1;
</font><font color="#000088">+  size_t type_size = strlen(type) + 1;
+  size_t fsn_size = sizeof( filesystem_node ) + type_size;
</font>   filesystem_node *fsn = malloc( fsn_size );
<font color="#880000">-  char *type_storage = (char *) fsn + sizeof( filesystem_node );
</font><font color="#000088">+  char *type_storage = (char *) fsn + sizeof( *fsn );
</font> 
   if ( fsn == NULL )
     rtems_set_errno_and_return_minus_one( ENOMEM );
 
<font color="#880000">-  strcpy(type_storage, type);
</font><font color="#000088">+  memcpy(type_storage, type, type_size);
</font>   fsn->entry.type = type_storage;
   fsn->entry.mount_h = mount_h;
 
</pre>
<p> </p>
<a name="12ab26218e53c1dc_cs3"></a>
<table bgcolor="#eeeeee" border="0" cellpadding="5" cellspacing="0" width="100%">
<tbody><tr><td colspan="3" bgcolor="#dddddd">
 <font color="#bb2222"><b>sh</b></font>
</td></tr>
<tr><td colspan="3" bgcolor="#dddddd"><pre>2010-08-26     Sebastian Huber <<a href="mailto:sebastian.huber@embedded-brains.de" target="_blank">sebastian.huber@embedded-brains.de</a>>

        * libfs/src/defaults/default_evalpath.c,
        libfs/src/defaults/default_evaluate_link.c: Removed superfluous
        assignment.
</pre></td></tr>
<tr><td width="1%"><a href="http://www.rtems.com/cgi-bin/viewcvs.cgi//rtems/cpukit/ChangeLog.diff?r1=text&tr1=1.2610&r2=text&tr2=1.2611&diff_format=h" target="_blank">M</a></td><td width="1%">1.2611</td><td width="100%">
cpukit/ChangeLog</td></tr>
<tr><td width="1%"><a href="http://www.rtems.com/cgi-bin/viewcvs.cgi//rtems/cpukit/libfs/src/defaults/default_evalpath.c.diff?r1=text&tr1=1.3&r2=text&tr2=1.4&diff_format=h" target="_blank">M</a></td><td width="1%">
1.4</td><td width="100%">cpukit/libfs/src/defaults/default_evalpath.c</td></tr>
<tr><td width="1%"><a href="http://www.rtems.com/cgi-bin/viewcvs.cgi//rtems/cpukit/libfs/src/defaults/default_evaluate_link.c.diff?r1=text&tr1=1.1&r2=text&tr2=1.2&diff_format=h" target="_blank">M</a></td>
<td width="1%">1.2</td><td width="100%">cpukit/libfs/src/defaults/default_evaluate_link.c</td></tr>
</tbody></table>
<pre><font color="#006600">diff -u rtems/cpukit/ChangeLog:1.2610 rtems/cpukit/ChangeLog:1.2611
--- rtems/cpukit/ChangeLog:1.2610       Fri Aug 27 01:41:07 2010
+++ rtems/cpukit/ChangeLog      Fri Aug 27 01:42:45 2010
</font><font color="#997700">@@ -1,5 +1,11 @@
</font> 2010-08-26        Sebastian Huber <<a href="mailto:sebastian.huber@embedded-brains.de" target="_blank">sebastian.huber@embedded-brains.de</a>>
 
<font color="#000088">+ * libfs/src/defaults/default_evalpath.c,
+       libfs/src/defaults/default_evaluate_link.c: Removed superfluous
+       assignment.
+
+2010-08-26     Sebastian Huber <<a href="mailto:sebastian.huber@embedded-brains.de" target="_blank">sebastian.huber@embedded-brains.de</a>>
+
</font>   * libcsupport/src/mount.c, libcsupport/src/mount-mgr.c: Avoid
        strcpy().
 

<font color="#006600">diff -u rtems/cpukit/libfs/src/defaults/default_evalpath.c:1.3 rtems/cpukit/libfs/src/defaults/default_evalpath.c:1.4
--- rtems/cpukit/libfs/src/defaults/default_evalpath.c:1.3      Tue Jun 29 14:37:28 2010
+++ rtems/cpukit/libfs/src/defaults/default_evalpath.c  Fri Aug 27 01:42:45 2010
</font><font color="#997700">@@ -20,7 +20,6 @@
</font>   rtems_filesystem_location_info_t  *pathloc        /* IN/OUT */
 )
 {
<font color="#880000">-  pathloc = NULL;
</font>   rtems_set_errno_and_return_minus_one( ENOTSUP );
 }
 

<font color="#006600">diff -u rtems/cpukit/libfs/src/defaults/default_evaluate_link.c:1.1 rtems/cpukit/libfs/src/defaults/default_evaluate_link.c:1.2
--- rtems/cpukit/libfs/src/defaults/default_evaluate_link.c:1.1 Tue Jun 29 14:37:28 2010
+++ rtems/cpukit/libfs/src/defaults/default_evaluate_link.c     Fri Aug 27 01:42:46 2010
</font><font color="#997700">@@ -18,7 +18,6 @@
</font>   int                               flags        /* IN     */
 )
 {
<font color="#880000">-  pathloc = NULL;
</font>   rtems_set_errno_and_return_minus_one( ENOTSUP );
 }
 
</pre><font color="#888888">
<p> </p>

<p>--<br>
<small>Generated by <a href="http://www.codewiz.org/projects/index.html#loginfo" target="_blank">Deluxe Loginfo</a> 2.122 by Bernardo Innocenti <<a href="mailto:bernie@develer.com" target="_blank">bernie@develer.com</a>></small></p>

</font></div>
<br>_______________________________________________<br>
rtems-vc mailing list<br>
<a href="mailto:rtems-vc@rtems.org">rtems-vc@rtems.org</a><br>
<a href="http://www.rtems.org/mailman/listinfo/rtems-vc" target="_blank">http://www.rtems.org/mailman/listinfo/rtems-vc</a><br>
<br></blockquote></div><br>