1 |
commit: 5df696152a15ab827381d524c28ce87ee0568a00 |
2 |
Author: Sven Eden <yamakuzure <AT> gmx <DOT> net> |
3 |
AuthorDate: Tue Sep 24 17:45:47 2019 +0000 |
4 |
Commit: Sven Eden <sven.eden <AT> gmx <DOT> de> |
5 |
CommitDate: Tue Sep 24 17:57:12 2019 +0000 |
6 |
URL: https://gitweb.gentoo.org/proj/ufed.git/commit/?id=5df69615 |
7 |
|
8 |
Do not hand over overly long lines (Fixes bug #695262) |
9 |
|
10 |
ufed-curses-checklist.c:ufed_getline() is limited to LINE_MAX, which is 2048 |
11 |
bytes. Unfortunately local USE flags can blast this limit, as ufed.pl also |
12 |
transmit an alternative description with stripped keywords. |
13 |
|
14 |
This commit lets ufed.pl calculate whether a description has to be shorted, and |
15 |
does so if needed. |
16 |
|
17 |
Bug: https://bugs.gentoo.org/695262 |
18 |
Signed-off-by: Sven Eden <yamakuzure <AT> gmx.net> |
19 |
|
20 |
.gitignore | 2 ++ |
21 |
ufed.pl.in | 13 +++++++++++-- |
22 |
2 files changed, 13 insertions(+), 2 deletions(-) |
23 |
|
24 |
diff --git a/.gitignore b/.gitignore |
25 |
index c16694f..fc4c607 100644 |
26 |
--- a/.gitignore |
27 |
+++ b/.gitignore |
28 |
@@ -25,3 +25,5 @@ depcomp |
29 |
install-sh |
30 |
missing |
31 |
compile |
32 |
+ufed.workspace* |
33 |
+cb/* |
34 |
|
35 |
diff --git a/ufed.pl.in b/ufed.pl.in |
36 |
index 4cd2484..f01c8a2 100644 |
37 |
--- a/ufed.pl.in |
38 |
+++ b/ufed.pl.in |
39 |
@@ -109,9 +109,18 @@ sub flags_dialog { |
40 |
|
41 |
# Finally print the local description lines |
42 |
for my $pkg (sort keys %{$conf->{"local"}}) { |
43 |
+ # ufed handles up to 2048 bytes long lines, but local descriptions can be as long |
44 |
+ # as maintainers choose, so we have to do a bit more work here. |
45 |
+ my $extra_len = length($pkg) + 18; # +One for the NULL-Byte |
46 |
+ my $full_desc = $conf->{"local"}{$pkg}{descr}; |
47 |
+ my $alt_desc = $conf->{"local"}{$pkg}{descr_alt}; |
48 |
+ my $full_max = (2048 - $extra_len) / 3 * 2 - 19; # 19 is the length of the metadata hint |
49 |
+ my $alt_max = (2048 - $extra_len) / 3 - 1; |
50 |
$outTxt .= sprintf("\t%s\t%s\t (%s) [ %s%s%s%s%s%s]\n", |
51 |
- $conf->{"local"}{$pkg}{descr}, |
52 |
- $conf->{"local"}{$pkg}{descr_alt}, |
53 |
+ ( length($full_desc) > $full_max |
54 |
+ ? substr($full_desc, 0, $full_max) . " (See metadata.xml)" |
55 |
+ : $full_desc ), |
56 |
+ substr($alt_desc, 0, $alt_max), |
57 |
$pkg, |
58 |
$conf->{"local"}{$pkg}{installed} > 0 ? '+' : |
59 |
$conf->{"local"}{$pkg}{installed} < 0 ? '-' : ' ', |