This is the mail archive of the newlib@sourceware.org mailing list for the newlib project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[PATCH] Fix padding in strncpy


Attached is a patch to fix the following bug:

  - SPU strncpy does not pad the end of destination area.

2006-12-04  Kazunori Asayama  <asayama@sm.sony.co.jp>

	* libc/machine/spu/strncpy.c: Add padding.


Index: newlib/newlib/libc/machine/spu/strncpy.c
===================================================================
--- newlib.orig/newlib/libc/machine/spu/strncpy.c
+++ newlib/newlib/libc/machine/spu/strncpy.c
@@ -76,6 +76,11 @@ char * strncpy(char * __restrict__ dest,
    */
   len = spu_extract(spu_sel(spu_promote((unsigned int)len, 0), N, gt), 0);
 
+  /* Padding
+   */
+  if (len != n) {
+    memset(dest + len, 0, n - len);
+  }
   /* Perform a memcpy of the resulting length
    */
   return ((char *)memcpy((void *)dest, (const void *)src, len));


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]