summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSven Eden <yamakuzure@gmx.net>2019-09-24 19:45:47 +0200
committerSven Eden <yamakuzure@gmx.net>2019-09-24 19:57:12 +0200
commit5df696152a15ab827381d524c28ce87ee0568a00 (patch)
tree6683cca5c7efc7632239e860590c8e1db5dead7b
parentRename `getline` to `ufed_getline` to avoid clash (diff)
downloadufed-5df696152a15ab827381d524c28ce87ee0568a00.tar.gz
ufed-5df696152a15ab827381d524c28ce87ee0568a00.tar.bz2
ufed-5df696152a15ab827381d524c28ce87ee0568a00.zip
Do not hand over overly long lines (Fixes bug #695262)ufed-0.95
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: https://bugs.gentoo.org/695262 Signed-off-by: Sven Eden <yamakuzure@gmx.net>
-rw-r--r--.gitignore2
-rw-r--r--ufed.pl.in13
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 ? '-' : ' ',