summaryrefslogtreecommitdiff
path: root/pp_ctl.c
diff options
context:
space:
mode:
authorNicholas Clark <nick@ccl4.org>2012-06-27 18:25:50 +0200
committerNicholas Clark <nick@ccl4.org>2012-08-01 22:34:40 +0200
commit2fc7dfcbbf2c319e5b0c6f61e4925c97d972274d (patch)
treeecd8254c95bba2566317d92d37d567a859bcb62e /pp_ctl.c
parent1f64ae15647e757e817c923b2a9fcbc528c5f610 (diff)
downloadperl-2fc7dfcbbf2c319e5b0c6f61e4925c97d972274d.tar.gz
Avoid reading before the buffer start when generating errors from require.
In pp_require, the error reporting code treats file names ending /\.p?h\z/ specially. The detection code for this, as refactored in 2010 by commit 686c4ca09cf9d6ae, could read one or two bytes before the start of the filename for filenames less than 3 bytes long. (Note this cannot happen with module names given to use or require, as appending ".pm" will always make the filename at least 3 bytes long.)
Diffstat (limited to 'pp_ctl.c')
-rw-r--r--pp_ctl.c4
1 files changed, 2 insertions, 2 deletions
diff --git a/pp_ctl.c b/pp_ctl.c
index 1bec8400c9..ca953ad05e 100644
--- a/pp_ctl.c
+++ b/pp_ctl.c
@@ -3923,9 +3923,9 @@ PP(pp_require)
DIE(aTHX_
"Can't locate %s in @INC%s%s (@INC contains:%" SVf ")",
name,
- (memEQ(name + len - 2, ".h", 3)
+ (len >= 2 && memEQ(name + len - 2, ".h", 3)
? " (change .h to .ph maybe?) (did you run h2ph?)" : ""),
- (memEQ(name + len - 3, ".ph", 4)
+ (len >= 3 && memEQ(name + len - 3, ".ph", 4)
? " (did you run h2ph?)" : ""),
inc
);