summaryrefslogtreecommitdiff
path: root/ext
diff options
context:
space:
mode:
authorKarl Williamson <khw@cpan.org>2019-12-07 13:47:05 -0700
committerKarl Williamson <khw@cpan.org>2019-12-18 09:33:09 -0700
commit4aada8b9eda25f3f024283c0c27c1424b5ba40ff (patch)
tree2c0ded2d593e998be054336ebf9648e4e18877fb /ext
parentfcafb10c71dbfc03eacb02eeb0c567facc269a72 (diff)
downloadperl-4aada8b9eda25f3f024283c0c27c1424b5ba40ff.tar.gz
Add memCHRs() macro and use it
This replaces strchr("list", c) calls throughout the core. They don't work properly when 'c' is a NUL, returning the position of the terminating NUL in "list" instead of failure. This could lead to segfaults or even security issues.
Diffstat (limited to 'ext')
-rw-r--r--ext/B/B.pm2
-rw-r--r--ext/B/B.xs2
-rw-r--r--ext/VMS-Stdio/Stdio.pm2
-rw-r--r--ext/VMS-Stdio/Stdio.xs4
4 files changed, 5 insertions, 5 deletions
diff --git a/ext/B/B.pm b/ext/B/B.pm
index 8ee5a12228..8eb749cb77 100644
--- a/ext/B/B.pm
+++ b/ext/B/B.pm
@@ -20,7 +20,7 @@ sub import {
# walkoptree comes from B.xs
BEGIN {
- $B::VERSION = '1.77';
+ $B::VERSION = '1.78';
@B::EXPORT_OK = ();
# Our BOOT code needs $VERSION set, and will append to @EXPORT_OK.
diff --git a/ext/B/B.xs b/ext/B/B.xs
index d27eba33be..7bd83538e6 100644
--- a/ext/B/B.xs
+++ b/ext/B/B.xs
@@ -258,7 +258,7 @@ cstring(pTHX_ SV *sv, bool perlstyle)
sv_catpvs(sstr, "\\@");
else if (*s == '\\')
{
- if (strchr("nrftax\\",*(s+1)))
+ if (memCHRs("nrftax\\",*(s+1)))
sv_catpvn(sstr, s++, 2);
else
sv_catpvs(sstr, "\\\\");
diff --git a/ext/VMS-Stdio/Stdio.pm b/ext/VMS-Stdio/Stdio.pm
index 02ba8668ed..53c5f30bb8 100644
--- a/ext/VMS-Stdio/Stdio.pm
+++ b/ext/VMS-Stdio/Stdio.pm
@@ -12,7 +12,7 @@ use Carp '&croak';
use DynaLoader ();
use Exporter ();
-our $VERSION = '2.44';
+our $VERSION = '2.45';
our @ISA = qw( Exporter DynaLoader IO::File );
our @EXPORT = qw( &O_APPEND &O_CREAT &O_EXCL &O_NDELAY &O_NOWAIT
&O_RDONLY &O_RDWR &O_TRUNC &O_WRONLY );
diff --git a/ext/VMS-Stdio/Stdio.xs b/ext/VMS-Stdio/Stdio.xs
index 64e1ef344b..953f82cd0d 100644
--- a/ext/VMS-Stdio/Stdio.xs
+++ b/ext/VMS-Stdio/Stdio.xs
@@ -137,7 +137,7 @@ binmode(fh)
io = sv_2io(fh);
fp = io ? IoOFP(io) : NULL;
iotype = io ? IoTYPE(io) : '\0';
- if (fp == NULL || strchr(">was+-|",iotype) == NULL) {
+ if (fp == NULL || memCHRs(">was+-|",iotype) == NULL) {
set_errno(EBADF); set_vaxc_errno(SS$_IVCHAN); XSRETURN_UNDEF;
}
if (!PerlIO_getname(fp,filespec)) XSRETURN_UNDEF;
@@ -432,7 +432,7 @@ writeof(mysv)
struct dsc$descriptor devdsc = {0, DSC$K_DTYPE_T, DSC$K_CLASS_S, devnam};
IO *io = sv_2io(mysv);
PerlIO *fp = io ? IoOFP(io) : NULL;
- if (fp == NULL || strchr(">was+-|",IoTYPE(io)) == NULL) {
+ if (fp == NULL || memCHRs(">was+-|",IoTYPE(io)) == NULL) {
set_errno(EBADF); set_vaxc_errno(SS$_IVCHAN); XSRETURN_UNDEF;
}
if (PerlIO_getname(fp,devnam) == NULL) { ST(0) = &PL_sv_undef; XSRETURN(1); }