Commit 9c4279b6 authored by Paul Mackerras's avatar Paul Mackerras

PPC32: Make strncpy clear the unused part of the destination.

parent 7e85e094
...@@ -78,6 +78,8 @@ _GLOBAL(strcpy) ...@@ -78,6 +78,8 @@ _GLOBAL(strcpy)
bne 1b bne 1b
blr blr
/* This clears out any unused part of the destination buffer,
just as the libc version does. -- paulus */
_GLOBAL(strncpy) _GLOBAL(strncpy)
cmpwi 0,r5,0 cmpwi 0,r5,0
beqlr beqlr
...@@ -88,6 +90,12 @@ _GLOBAL(strncpy) ...@@ -88,6 +90,12 @@ _GLOBAL(strncpy)
cmpwi 0,r0,0 cmpwi 0,r0,0
stbu r0,1(r6) stbu r0,1(r6)
bdnzf 2,1b /* dec ctr, branch if ctr != 0 && !cr0.eq */ bdnzf 2,1b /* dec ctr, branch if ctr != 0 && !cr0.eq */
bnelr /* if we didn't hit a null char, we're done */
mfctr r5
cmpwi 0,r5,0 /* any space left in destination buffer? */
beqlr /* we know r0 == 0 here */
2: stbu r0,1(r6) /* clear it out if so */
bdnz 2b
blr blr
_GLOBAL(strcat) _GLOBAL(strcat)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment