diff options
-rw-r--r-- | pp_sys.c | 2 | ||||
-rw-r--r-- | t/op/sysio.t | 10 |
2 files changed, 8 insertions, 4 deletions
@@ -1918,7 +1918,7 @@ PP(pp_send) DIE(aTHX_ "Offset outside string"); } offset += blen_chars; - } else if (offset >= (IV)blen_chars) { + } else if (offset > (IV)blen_chars) { Safefree(tmpbuf); DIE(aTHX_ "Offset outside string"); } diff --git a/t/op/sysio.t b/t/op/sysio.t index 966a516997..f2c269ebaf 100644 --- a/t/op/sysio.t +++ b/t/op/sysio.t @@ -70,12 +70,16 @@ is($x, 'abc'); ok(!-s $outfile); # should not be able to write from after the buffer -eval { syswrite(O, $x, 1, 3) }; +eval { syswrite(O, $x, 1, 4) }; like($@, qr/^Offset outside string /); # $x still intact is($x, 'abc'); +# but it should be ok to write from the end of the buffer +syswrite(O, $x, 0, 3); +syswrite(O, $x, 1, 3); + # $outfile still intact if ($reopen) { # must close file to update EOF marker for stat close O; open(O, ">>$outfile") || die "sysio.t: cannot write $outfile: $!"; @@ -97,7 +101,7 @@ if ($reopen) { # must close file to update EOF marker for stat ok(!-s $outfile); # [perl #67912] syswrite prints garbage if called with empty scalar and non-zero offset -eval { my $buf = ''; syswrite(O, $buf, 1, 0) }; +eval { my $buf = ''; syswrite(O, $buf, 1, 1) }; like($@, qr/^Offset outside string /); # $x still intact @@ -109,7 +113,7 @@ if ($reopen) { # must close file to update EOF marker for stat } ok(!-s $outfile); -eval { my $buf = 'x'; syswrite(O, $buf, 1, 1) }; +eval { my $buf = 'x'; syswrite(O, $buf, 1, 2) }; like($@, qr/^Offset outside string /); # $x still intact |