[PATCH] Fix padding in strncpy
Jeff Johnston
jjohnstn@redhat.com
Mon Dec 4 20:24:00 GMT 2006
Patch checked in.
-- Jeff J.
Kazunori Asayama wrote:
> 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));
>
More information about the Newlib
mailing list