summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--pp_sys.c2
-rw-r--r--t/op/sysio.t10
2 files changed, 8 insertions, 4 deletions
diff --git a/pp_sys.c b/pp_sys.c
index d3430d1c0f..015fcdf4a6 100644
--- a/pp_sys.c
+++ b/pp_sys.c
@@ -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