New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
syswrite prints garbage if called with empty scalar and non-zero offset #9804
Comments
From dave.taylor.cpan@googlemail.comIn a stock 5.10.0 perl with the default build options, syswrite prints $ /usr/local/refperl/5.10.0/bin/perl -e 'my $foo = ""; syswrite |
From dave.taylor.cpan@googlemail.comFlags: Site configuration information for perl 5.10.0: Configured by dave at Mon Jul 27 09:34:33 SAST 2009. Summary of my perl5 (revision 5 version 10 subversion 0) configuration: Locally applied patches: @INC for perl 5.10.0: Environment for perl 5.10.0: |
From chromatic@wgz.orgOn Monday 27 July 2009 01:01:32 David Taylor wrote:
^@^@^@^@<89>^@^@^@<80><A6>^U^H^@^@^@^@^@<A6>^U^H^@^@^@^@<80><A7>^U^H^@^@^@^
<A7>^U^H^@^@^@^@<80><A8>^U^H^@^@^@^@^@<A9>^U^H^@^@^@^@^@<A5>^U^H^@^@^@^@<80
Confirmed in blead. This looks like a fencepost error. With the included $ ./perl -e 'my $foo = ""; syswrite I suspect that the comparison should be > instead of >=, but it's late here Inline Patchdiff --git a/pp_sys.c b/pp_sys.c
index 23f79ba..ec12cd4 100644
--- a/pp_sys.c
+++ b/pp_sys.c
@@ -1919,7 +1919,7 @@ PP(pp_send)
DIE(aTHX_ "Offset outside string");
}
offset += blen_chars;
- } else if (offset >= (IV)blen_chars && blen_chars > 0) {
+ } else if (offset >= (IV)blen_chars) {
Safefree(tmpbuf);
DIE(aTHX_ "Offset outside string");
}
-- c |
The RT System itself - Status changed from 'new' to 'open' |
From offer.kaye@gmail.comOn Mon, Jul 27, 2009 at 2:02 PM, chromatic wrote:
Maybe we should add a test for this, perhaps in t/op/sysio.t? I Unrelated question - looking at t/op/sysio.t I don't understand, why Cheers, |
From offer.kaye@gmail.com0001-Add-test-for-perl-ticket-67912-syswrite-with-empty-s.patchFrom 0ed53dcf1012f10c7acea14d04084bc3e1c582df Mon Sep 17 00:00:00 2001
From: Offer Kaye <offer@galaxy10.il.marvell.com>
Date: Mon, 27 Jul 2009 15:30:17 +0300
Subject: [PATCH] Add test for perl ticket #67912 - syswrite with empty string and non-zero offset.
---
t/op/sysio.t | 6 +++++-
1 files changed, 5 insertions(+), 1 deletions(-)
diff --git a/t/op/sysio.t b/t/op/sysio.t
index dd63a15..2ad41e4 100644
--- a/t/op/sysio.t
+++ b/t/op/sysio.t
@@ -1,6 +1,6 @@
#!./perl
-print "1..42\n";
+print "1..43\n";
chdir('op') || chdir('t/op') || die "sysio.t: cannot look for myself: $!";
@INC = '../../lib';
@@ -240,6 +240,10 @@ unlink $outfile;
chdir('..');
+eval { syswrite(STDOUT, '', 100, 1) };
+print 'not ' unless ($@ =~ /^Offset outside string/);
+print "ok 43\n";
+
1;
# eof
--
1.6.3.3
|
From perl@profvince.com
I think that's the cause too, so I've applied it as But I don't think >= should be replaced by >, because an offset of n is Vincent. |
bitcard@profvince.com - Status changed from 'open' to 'resolved' |
From zefram@fysh.orgVincent Pit wrote:
Offset of n is acceptable with a string of length n as long as you're not write_length >= 0 -zefram |
From @nwc10On Mon, Jul 27, 2009 at 03:35:02PM +0300, Offer Kaye wrote:
There's a bootstrapping order on tests. The initial tests run avoid relying Nicholas Clark |
Migrated from rt.perl.org#67912 (status was 'resolved')
Searchable as RT67912$
The text was updated successfully, but these errors were encountered: