Perl / perl5

🐪 The Perl programming language
https://dev.perl.org/perl5/
Other
1.85k stars 527 forks source link

Text::Parsewords quotewords will die on really long strings #8860

Closed p5pRT closed 16 years ago

p5pRT commented 17 years ago

Migrated from rt.perl.org#42276 (status was 'resolved')

Searchable as RT42276$

p5pRT commented 17 years ago

From ruddatwork@yahoo.com

When using the Text​::Parsewords module\, and quotewords\, it will die when it encounters a really long string of text. Here is an example script. Increase the "7" in "$num \< 7" to force it to crash.

#!/usr/local/bin/perl -w # Generates a line "Section One"\,"01234567890123456789...etc" use Text​::ParseWords; my $line = "\"Section One\"\,\""; # "Section One"\," my $total = 0; my $num = 0; my $tens = 0; while ( $tens \< 3276 ) {   $line .= $num; # append the number 0-9 to end of string   $num++;   $total++;   if ( $num > 9 ) {   $tens++; # increase the tens by one   $num = 0; # reset the numbers back to zero.   } } # repeat until you have added 32760 characters while ( $num \< 7 ) {   $line .= $num; # append the numbers 0-7\, to push it over the edge   $num++;   $total++; } $line .= "\""; # put closing quote at end of string. print "TOTAL characters​: $total\n"; my @​Test = &quotewords('\,'\, 0\, $line) or die "Cannot quotewords​: $!\n";

Perl Info ``` Flags: category=core severity=medium Site configuration information for perl v5.6.1: Configured by ActiveState at Mon Jun 17 21:32:50 2002. Summary of my perl5 (revision 5 version 6 subversion 1) configuration: Platform: osname=MSWin32, osvers=4.0, archname=MSWin32-x86-multi-thread uname='' config_args='undef' hint=recommended, useposix=true, d_sigaction=undef usethreads=undef use5005threads=undef useithreads=define usemultiplicity=define useperlio=undef d_sfio=undef uselargefiles=undef usesocks=undef use64bitint=undef use64bitall=undef uselongdouble=undef Compiler: cc='cl', ccflags ='-nologo -O1 -MD -DNDEBUG -DWIN32 -D_CONSOLE -DNO_STRICT -DHAVE_DES_FCRYPT -DPERL_IMPLICIT_CONTEX T -DPERL_IMPLICIT_SYS -DPERL_MSVCRT_READFIX', optimize='-O1 -MD -DNDEBUG', cppflags='-DWIN32' ccversion='', gccversion='', gccosandvers='' intsize=4, longsize=4, ptrsize=4, doublesize=8, byteorder=1234 d_longlong=undef, longlongsize=8, d_longdbl=define, longdblsize=10 ivtype='long', ivsize=4, nvtype='double', nvsize=8, Off_t='off_t', lseeksize=4 alignbytes=8, usemymalloc=n, prototype=define Linker and Libraries: ld='link', ldflags ='-nologo -nodefaultlib -release -libpath:"C:/Perl\lib\CORE" -machine:x86' libpth="C:\Perl\lib\CORE" libs= oldnames.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib netapi32.lib uuid.lib wsock32.lib mpr.lib winmm.lib version.lib odbc32.lib odbccp32.lib msvcrt.lib perllibs= oldnames.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32. lib oleaut32.lib netapi32.lib uuid.lib wsock32.lib mpr.lib winmm.lib version.lib odbc32.lib odbccp32.lib msvcrt.lib libc=msvcrt.lib, so=dll, useshrplib=yes, libperl=perl56.lib Dynamic Linking: dlsrc=dl_win32.xs, dlext=dll, d_dlsymun=undef, ccdlflags=' ' cccdlflags=' ', lddlflags='-dll -nologo -nodefaultlib -release -libpath:"C:/Perl\lib\CORE" -machine:x86' Locally applied patches: ACTIVEPERL_LOCAL_PATCHES_ENTRY @INC for perl v5.6.1: C:/Perl/lib C:/Perl/site/lib . Environment for perl v5.6.1: HOME=U:/ LANG (unset) LANGUAGE (unset) LD_LIBRARY_PATH (unset) LOGDIR (unset) PATH=.;V:/Views/hardesty_rm_23snap/vip_common/config_mgmt/bin;V:/Views/hardesty_rm_23snap/vip_common/misc/win32_scri pts;V:/Views/hardesty_rm_23snap/tap_source/dev_tools/bin;C:/Program Files/Microsoft Visual Studio .NET 2003/Common7/IDE; C:/Program Files/Microsoft Visual Studio .NET 2003/Vc7/bin;C:/Program Files/Microsoft Visual Studio .NET 2003/Common7/To ols;C:/Program Files/Microsoft Visual Studio .NET 2003/Common7/Tools/bin;V:/Views/hardesty_rm_23snap/tap_config/Config/J RE/win32/bin/client;C:/Perl/bin/;C:/MKS/bin;C:/MKS/bin/x11;C:/MKS/mksnt;C:/WINDOWS/system32;C:/WINDOWS;C:/WINDOWS/System 32/Wbem;C:/Program Files/ATI Technologies/ATI Control Panel;C:/Program Files/Rational/ClearCase/bin;C:/Program Files/Rat ional/common;C:/Program Files/Hummingbird/Connectivity/10.00/Accessories/;C:/Program Files/Hummingbird/Connectivity/10.0 0/NFS Maestro/;r:/local/bin;C:/Program Files/Microsoft Visual Studio .NET 2003/Vc7/bin;C:/Program Files/Microsoft Visual Studio .NET 2003/Common7/Tools/bin;C:/Program Files/Microsoft Visual Studio .NET 2003/Common7/IDE;V:/Views/hardesty_rm_ 23snap/third_party/TrollTech/Qt/WINDOWS/bin;V:/Views/hardesty_rm_23snap/third_party/TrollTech/Qt/WINDOWS/lib PERL_BADLANG (unset) SHELL=C:/MKS/mksnt/sh.exe --------------------------------- Don't be flakey. Get Yahoo! Mail for Mobile and always stay connected to friends. ```
p5pRT commented 16 years ago

From @smpeters

On Mon Apr 02 10​:57​:59 2007\, ruddatwork \<!-- x --> at yahoo.com wrote​:

When using the Text​::Parsewords module\, and quotewords\, it will die when it encounters a really long string of text. Here is an example script. Increase the "7" in "$num \< 7" to force it to crash.

#!/usr/local/bin/perl -w # Generates a line "Section One"\,"01234567890123456789...etc" use Text​::ParseWords; my $line = "\"Section One\"\,\""; # "Section One"\," my $total = 0; my $num = 0; my $tens = 0; while ( $tens \< 3276 ) { $line .= $num; # append the number 0-9 to end of string $num++; $total++; if ( $num > 9 ) { $tens++; # increase the tens by one $num = 0; # reset the numbers back to zero. } } # repeat until you have added 32760 characters while ( $num \< 7 ) { $line .= $num; # append the numbers 0-7\, to push it over the edge $num++; $total++; } $line .= "\""; # put closing quote at end of string. print "TOTAL characters​: $total\n"; my @​Test = &quotewords('\,'\, 0\, $line) or die "Cannot quotewords​: $!\n";

Yes\, this blows up with bleadperl....

[steve@​sulu perl-current]$ /tmp/bleadperl/bin/perl5.9.5 foo.pl TOTAL characters​: 32767 Complex regular subexpression recursion limit (32766) exceeded at /tmp/bleadperl/lib/5.9.5/Text/ParseWords.pm line 64.

p5pRT commented 16 years ago

The RT System itself - Status changed from 'new' to 'open'

p5pRT commented 16 years ago

From p5p@spam.wizbit.be

On Mon Apr 02 10​:57​:59 2007\, ruddatwork@​yahoo.com wrote​:

When using the Text​::Parsewords module\, and quotewords\, it will die when it encounters a really long string of text. Here is an example script. Increase the "7" in "$num \< 7" to force it to crash.

This seems to be fixed in perl 5.10.0.

Kind regards\,

Bram

p5pRT commented 16 years ago

p5p@spam.wizbit.be - Status changed from 'open' to 'resolved'