mirror of
https://anongit.gentoo.org/git/repo/gentoo.git
synced 2025-12-19 00:18:26 +00:00
Text::WrapI18N has a bug that causes an infinite loop. The following
program demonstrates the issue:
> use Text::WrapI18N qw($columns);
> use Text::WrapI18N qw(wrap);
> $columns = 78;
>
> my $a="po/pod.cfg:1: ";
> my $b=" ";
> my $c="No PO files found in '/var/tmp/portage/app-text/po4a-0.74-r1/work/po4a-0.74'/'po/pod'.";
>
> print wrap($a, $b, $c);
This program will hang indefinitely until OOM. However, if change $columns to
any value greater than 78, it finishes quickly.
In po4a, $columns is set from $ENV{COLUMNS} ( see
https://github.com/mquinson/po4a/blob/master/lib/Locale/Po4a/Common.pm#L68),
so if your terminal width is <= 78, emerge will hang.
This is a very old bug that Debian found and fixed in 2008. See
https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=470250
and upstream issue:
https://rt.cpan.org/Public/Bug/Display.html?id=42102
Closes: https://bugs.gentoo.org/959830
Signed-off-by: Z. Liu <zhixu.liu@gmail.com>
Part-of: https://github.com/gentoo/gentoo/pull/44680
Closes: https://github.com/gentoo/gentoo/pull/44680
Signed-off-by: Sam James <sam@gentoo.org>
26 lines
1.1 KiB
Diff
26 lines
1.1 KiB
Diff
patch is extracted from debian:
|
|
https://deb.debian.org/debian/pool/main/libt/libtext-wrapi18n-perl/libtext-wrapi18n-perl_0.06-10.debian.tar.xz
|
|
|
|
Description: The infinite loop occurs in Text::WrapI18N when po4a tries to report an error in the PO files.
|
|
I could reproduce the problem in WrapI18N::wrap() and I propose the
|
|
attached patch to WrapI18N::wrap(). (A word should be placed on the
|
|
next line if it fits on this line, but the leading header must be taken
|
|
into account, thus $columns -> $columns - length $header)
|
|
Origin: vendor
|
|
Bug-Debian: https://bugs.debian.org/470250
|
|
Forwarded: unknown
|
|
Author: Nicolas François <nicolas.francois@centraliens.net>
|
|
Reviewed-by: gregor herrmann <gregoa@debian.org>
|
|
Last-Update: 2019-03-21
|
|
|
|
--- a/WrapI18N.pm 2003-06-25 11:14:25.000000000 +0200
|
|
+++ b/WrapI18N.pm 2008-03-13 02:04:02.628000837 +0100
|
|
@@ -88,7 +88,7 @@ sub wrap {
|
|
$len = 0;
|
|
$text = $top2 . $text;
|
|
$word = ''; $wlen = 0;
|
|
- } elsif ($wlen + $w <= $columns) {
|
|
+ } elsif ($wlen + $w <= $columns - length ($top2)) {
|
|
# the current word is sent to next line
|
|
$out .= $separator;
|
|
$len = 0;
|