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
bug with index() matching beyond end of string when \0 bytes (00000000) are involved #9315
Comments
From insana@mediaglyphs.orgThis is a bug report for perl from insana@ebi.ac.uk, # by Giuseppe Insana <insana@ebi.ac.uk> $msg="aaZaa"; $msg="\0\0Z\0\0"; print "\n result is different, but actually for string2 index should Flags: Site configuration information for perl 5.10.0: Configured by SYSTEM at Thu Jan 10 11:00:30 2008. 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: PATH=D:\apps\Perl\site\bin;D:\apps\Perl\bin;D:\apps\PHP\;C:\WINDOWS\system32;C:\WINDOWS;C:\WINDOWS\System32\Wbem;C:\Program |
From p5p@spam.wizbit.beEasier example: perl5.8.8 -wle 'my $s = "\0\0\0"; print index("\0\0Z\0\0", $s, 0);' perl5.10.0 -wle 'my $s = "\0\0\0"; print index("\0\0Z\0\0", $s, 0);' perl-blead -wle 'my $s = "\0\0\0"; print index("\0\0Z\0\0", $s, 0);' Note that: perl-blead -wle 'print index("\0\0Z\0\0", "\0\0\0", 0);' perl-blead -wle 'my $s = "\0\0\0\0"; print index("\0\0Z\0\0", $s, 0);' |
The RT System itself - Status changed from 'new' to 'open' |
From @AbigailOn Mon, May 05, 2008 at 11:50:44AM -0700, Bram via RT wrote:
Attached is a set of tests. Abigail |
From @AbigailInline Patch--- t/op/index.t.orig 2008-05-06 14:08:20.000000000 +0200
+++ t/op/index.t 2008-05-06 14:56:41.000000000 +0200
@@ -7,7 +7,7 @@
}
use strict;
-plan( tests => 69 );
+plan( tests => 111 );
run_tests() unless caller;
@@ -160,4 +160,43 @@
is(index($t, 'xyz'), 4, "0xfffffffd and utf8cache");
}
+
+# Tests for NUL characters.
+{
+ my @tests = (
+ ["", -1, -1, -1],
+ ["foo", -1, -1, -1],
+ ["\0", 0, -1, -1],
+ ["\0\0", 0, 0, -1],
+ ["\0\0\0", 0, 0, 0],
+ ["foo\0", 3, -1, -1],
+ ["foo\0foo\0\0", 3, 7, -1],
+ );
+ foreach my $l (1 .. 3) {
+ my $q = "\0" x $l;
+ my $i = 0;
+ foreach my $test (@tests) {
+ $i ++;
+ my $str = $$test [0];
+ my $res = $$test [$l];
+
+ {
+ local $::TODO = ($l == 3 && $i == 7 ? "Bug #53746" : "");
+ is (index ($str, $q), $res, "Find NUL character(s)");
+ }
+
+ #
+ # Bug #53746 shows a difference between variables and literals,
+ # so test literals as well.
+ #
+ my $test_str = qq {is (index ("$str", "$q"), $res, } .
+ qq {"Find NUL character(s)")};
+ $test_str =~ s/\0/\\0/g;
+
+ eval $test_str;
+ die $@ if $@;
+ }
+ }
+}
+
} |
From @iabynOn Tue, May 06, 2008 at 02:57:36PM +0200, Abigail wrote:
Thanks, applied as change #33951. -- |
p5p@spam.wizbit.be - Status changed from 'open' to 'resolved' |
Migrated from rt.perl.org#53746 (status was 'resolved')
Searchable as RT53746$
The text was updated successfully, but these errors were encountered: