summaryrefslogtreecommitdiff
path: root/pp_sys.c
diff options
context:
space:
mode:
authorKarl Williamson <khw@cpan.org>2017-03-25 14:50:48 -0600
committerKarl Williamson <khw@cpan.org>2017-11-06 14:31:45 -0700
commit5716a028c7461672700c451fd2f25daa794a88bd (patch)
tree1098545393a4e72ec2678268c10d8ecb77f45aed /pp_sys.c
parent320d4f1b610f3c392d21c3f0af229c6d31adc84a (diff)
downloadperl-5716a028c7461672700c451fd2f25daa794a88bd.tar.gz
pp_sys.c; Use memchr instead of strchr
This allows things to work properly in the face of embedded NULs. See the branch merge message for more information.
Diffstat (limited to 'pp_sys.c')
-rw-r--r--pp_sys.c3
1 files changed, 2 insertions, 1 deletions
diff --git a/pp_sys.c b/pp_sys.c
index 6d4dd86b7f..cd4deb803c 100644
--- a/pp_sys.c
+++ b/pp_sys.c
@@ -1509,10 +1509,11 @@ PP(pp_leavewrite)
if (IoFLAGS(io) & IOf_DIDTOP) { /* Oh dear. It still doesn't fit. */
I32 lines = IoLINES_LEFT(io);
const char *s = SvPVX_const(PL_formtarget);
+ const char *e = SvEND(PL_formtarget);
if (lines <= 0) /* Yow, header didn't even fit!!! */
goto forget_top;
while (lines-- > 0) {
- s = strchr(s, '\n');
+ s = (char *) memchr(s, '\n', e - s);
if (!s)
break;
s++;