diff options
author | Jeff Johnston <jjohnstn@redhat.com> | 2008-07-17 19:00:44 +0000 |
---|---|---|
committer | Jeff Johnston <jjohnstn@redhat.com> | 2008-07-17 19:00:44 +0000 |
commit | eb19b8f95a6a22ade6911ac98d1a76313ec99f53 (patch) | |
tree | 639f5a124bb435f373cd3b3bdadf04051957de05 /newlib/libc/machine/spu/strcpy.h | |
parent | 874149c80c9f8252a9b11e9f9c070bc2cbc966c1 (diff) | |
download | newlib-eb19b8f95a6a22ade6911ac98d1a76313ec99f53.zip newlib-eb19b8f95a6a22ade6911ac98d1a76313ec99f53.tar.gz newlib-eb19b8f95a6a22ade6911ac98d1a76313ec99f53.tar.bz2 |
2008-07-17 Ken Werner <ken.werner@de.ibm.com>
* libc/machine/spu/strcpy.h: Pad null bytes if necessary.
Diffstat (limited to 'newlib/libc/machine/spu/strcpy.h')
-rw-r--r-- | newlib/libc/machine/spu/strcpy.h | 4 |
1 files changed, 4 insertions, 0 deletions
diff --git a/newlib/libc/machine/spu/strcpy.h b/newlib/libc/machine/spu/strcpy.h index e2ec2b2..946148b 100644 --- a/newlib/libc/machine/spu/strcpy.h +++ b/newlib/libc/machine/spu/strcpy.h @@ -176,5 +176,9 @@ static inline void * _strncpy(char * __restrict__ dest, const char * */ dest[maxlen - spu_extract(curlen, 0)] = '\0'; } + + /* Pad null bytes if the length of the "src" is less than "n" (strncpy). */ + if (checklen && !lastzero && (maxlen != spu_extract(curlen,0))) + memset(dest + spu_extract(curlen, 0), 0, maxlen - spu_extract(curlen, 0)); return (dest); } |