commit: 2242469d3d92ec35ca50ad7cdd394a0c59365997
Author: Sven Eden <yamakuzure <AT> gmx <DOT> net>
AuthorDate: Tue Sep 24 17:45:47 2019 +0000
Commit: Sven Eden <sven.eden <AT> gmx <DOT> de>
CommitDate: Tue Sep 24 17:45:47 2019 +0000
URL: https://gitweb.gentoo.org/proj/ufed.git/commit/?id=2242469d
Do not hand over overly long lines (Fixes bug #695262)
ufed-curses-checklist.c:ufed_getline() is limited to LINE_MAX, which is 2048
bytes. Unfortunately local USE flags can blast this limit, as ufed.pl also
transmit an alternative description with stripped keywords.
This commit lets ufed.pl calculate whether a description has to be shorted, and
does so if needed.
Bug: 695262
Signed-off-by: Sven Eden <yamakuzure <AT> gmx.net>
.gitignore | 2 ++
ufed.pl.in | 13 +++++++++++--
2 files changed, 13 insertions(+), 2 deletions(-)
diff --git a/.gitignore b/.gitignore
index c16694f..fc4c607 100644
--- a/.gitignore
+++ b/.gitignore
@@ -25,3 +25,5 @@ depcomp
install-sh
missing
compile
+ufed.workspace*
+cb/*
diff --git a/ufed.pl.in b/ufed.pl.in
index 4cd2484..f01c8a2 100644
--- a/ufed.pl.in
+++ b/ufed.pl.in
@@ -109,9 +109,18 @@ sub flags_dialog {
# Finally print the local description lines
for my $pkg (sort keys %{$conf->{"local"}}) {
+ # ufed handles up to 2048 bytes long lines, but local
descriptions can be as long
+ # as maintainers choose, so we have to do a bit more
work here.
+ my $extra_len = length($pkg) + 18; # +One for the
NULL-Byte
+ my $full_desc = $conf->{"local"}{$pkg}{descr};
+ my $alt_desc = $conf->{"local"}{$pkg}{descr_alt};
+ my $full_max = (2048 - $extra_len) / 3 * 2 - 19; # 19
is the length of the metadata hint
+ my $alt_max = (2048 - $extra_len) / 3 - 1;
$outTxt .= sprintf("\t%s\t%s\t (%s) [ %s%s%s%s%s%s]\n",
- $conf->{"local"}{$pkg}{descr},
-
$conf->{"local"}{$pkg}{descr_alt},
+ ( length($full_desc) > $full_max
+ ? substr($full_desc, 0,
$full_max) . " (See metadata.xml)"
+ : $full_desc ),
+ substr($alt_desc, 0, $alt_max),
$pkg,
$conf->{"local"}{$pkg}{installed} > 0 ? '+' :
$conf->{"local"}{$pkg}{installed} < 0 ? '-' : ' ',