Skip to content
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

PerlIO::encoding infinite loop decoding invalid JIS data #11133

Open
p5pRT opened this issue Feb 16, 2011 · 7 comments
Open

PerlIO::encoding infinite loop decoding invalid JIS data #11133

p5pRT opened this issue Feb 16, 2011 · 7 comments

Comments

@p5pRT
Copy link

p5pRT commented Feb 16, 2011

Migrated from rt.perl.org#84250 (status was 'open')

Searchable as RT84250$

@p5pRT
Copy link
Author

p5pRT commented Feb 16, 2011

From jgreely@dotclue.org

Created by jgreely@dotclue.org

Decoding JIS with PerlIO​::encoding results in an infinite loop when
fed strings that are not valid JIS. This could be the result of
attempting to pass another encoding like UTF8, SJIS, or EUC-JP through
it, but also any data that has become corrupted in transit. The Encode
module doesn't have this problem.

Fails (infinite loop)​:

perl -e 'print "\x{4f5c}"' |
  perl -e 'binmode(STDIN,"​:encoding(jis)");print <>'

Works (that is, "prints garbage")​:

perl -e 'print "\x{4f5c}"' |
  perl -e 'use Encode;while (<>) {print decode(jis,$_)}'

Perl Info

Flags:
    category=library
    severity=low
    module=PerlIO::encoding

Site configuration information for perl 5.12.3:

Configured by jgreely at Thu Feb  3 21:56:25 PST 2011.

Summary of my perl5 (revision 5 version 12 subversion 3) configuration:
   
  Platform:
    osname=darwin, osvers=10.6.0, archname=darwin-ld-2level
    uname='darwin togetsukyou.local 10.6.0 darwin kernel version 10.6.0: wed nov 10 18:13:17 pst 2010; root:xnu-1504.9.26~3release_i386 i386 '
    config_args='-Dprefix=/j -Duse64bitall -Dusemorebits -Uloclibpth -Dlibpth=/usr/lib'
    hint=recommended, useposix=true, d_sigaction=define
    useithreads=undef, usemultiplicity=undef
    useperlio=define, d_sfio=undef, uselargefiles=define, usesocks=undef
    use64bitint=define, use64bitall=define, uselongdouble=define
    usemymalloc=n, bincompat5005=undef
  Compiler:
    cc='cc', ccflags ='-fno-common -DPERL_DARWIN -no-cpp-precomp -arch x86_64 -fno-strict-aliasing -pipe -fstack-protector -I/usr/local/include -I/opt/local/include',
    optimize='-O3',
    cppflags='-no-cpp-precomp -arch x86_64 -fno-common -DPERL_DARWIN -no-cpp-precomp -arch x86_64 -fno-strict-aliasing -pipe -fstack-protector -I/usr/local/include -I/opt/local/include'
    ccversion='', gccversion='4.2.1 (Apple Inc. build 5664)', gccosandvers=''
    intsize=4, longsize=8, ptrsize=8, doublesize=8, byteorder=12345678
    d_longlong=define, longlongsize=8, d_longdbl=define, longdblsize=16
    ivtype='long', ivsize=8, nvtype='long double', nvsize=16, Off_t='off_t', lseeksize=8
    alignbytes=8, prototype=define
  Linker and Libraries:
    ld='env MACOSX_DEPLOYMENT_TARGET=10.3 cc -arch x86_64', ldflags =' -arch x86_64 -fstack-protector'
    libpth=/usr/lib
    libs=-ldbm -ldl -lm -lutil -lc
    perllibs=-ldl -lm -lutil -lc
    libc=/usr/lib/libc.dylib, so=dylib, useshrplib=false, libperl=libperl.a
    gnulibc_version=''
  Dynamic Linking:
    dlsrc=dl_dlopen.xs, dlext=bundle, d_dlsymun=undef, ccdlflags=' '
    cccdlflags=' ', lddlflags=' -bundle -undefined dynamic_lookup -fstack-protector'

Locally applied patches:
    


@INC for perl 5.12.3:
    /j/lib/perl5/site_perl/5.12.3/darwin-ld-2level
    /j/lib/perl5/site_perl/5.12.3
    /j/lib/perl5/5.12.3/darwin-ld-2level
    /j/lib/perl5/5.12.3
    .


Environment for perl 5.12.3:
    DYLD_LIBRARY_PATH=/oracle/instantclient_10_2
    HOME=/Users/jgreely
    LANG=en_US.UTF-8
    LANGUAGE (unset)
    LD_LIBRARY_PATH (unset)
    LOGDIR (unset)
    PATH=/j/bin:/usr/texbin:/bin:/usr/bin:/usr/sbin:/sbin:/usr/X11/bin:/Users/jgreely/bin:/usr/local/bin:.
    PERLDOC=-n proff
    PERL_BADLANG (unset)
    SHELL=/bin/bash



@p5pRT
Copy link
Author

p5pRT commented Feb 16, 2011

From perlbug@jgreely.com

(dupe of my own bug 73826, which didn't turn up in my search results because I didn't use "JIS"
in the subject line. Heh)

@p5pRT
Copy link
Author

p5pRT commented Dec 31, 2016

From @jkeenan

On Wed, 16 Feb 2011 16​:28​:22 GMT, jgreely@​dotclue.org wrote​:

This is a bug report for perl from jgreely@​dotclue.org,
generated with the help of perlbug 1.39 running under perl 5.12.3.

-----------------------------------------------------------------
[Please describe your issue here]

Decoding JIS with PerlIO​::encoding results in an infinite loop when
fed strings that are not valid JIS. This could be the result of
attempting to pass another encoding like UTF8, SJIS, or EUC-JP through
it, but also any data that has become corrupted in transit. The Encode
module doesn't have this problem.

Fails (infinite loop)​:

perl -e 'print "\x{4f5c}"' |
perl -e 'binmode(STDIN,"​:encoding(jis)");print <>'

Works (that is, "prints garbage")​:

perl -e 'print "\x{4f5c}"' |
perl -e 'use Encode;while (<>) {print decode(jis,$_)}'

Still present in perl-5.24.0​:

#####
$ perl -e 'print "\x{4f5c}"' | perl -e 'use Encode;while (<>) {print decode(jis,$_)}'
Wide character in print at -e line 1.
Wide character in print at -e line 1, <> line 1.
篏\x9C

$ perl -e 'print "\x{4f5c}"' | perl -e 'binmode(STDIN,"​:encoding(jis)");print <>'
Wide character in print at -e line 1.
[infinite loop]
^C
#####

--
James E Keenan (jkeenan@​cpan.org)

@p5pRT
Copy link
Author

p5pRT commented Dec 31, 2016

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

@khwilliamson
Copy link
Contributor

This isn't hanging in blead. I have emailed the OP separately since any reply here will not be forwarded.

@Leont
Copy link
Contributor

Leont commented Dec 3, 2019

This isn't hanging in blead. I have emailed the OP separately since any reply here will not be forwarded.

I think @tonycoz did some work in this area some months ago, but I'm not sure about the current status

@tonycoz
Copy link
Contributor

tonycoz commented Dec 3, 2019

It requires resolution of https://rt.cpan.org/Public/Bug/Display.html?id=129086

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

6 participants