Package: dialog
Version: 1.3-20190211-ca-003-1
Severity: normal
Tags: patch upstream

The --aspect and --tab-len options are processed in the process_common_options 
subroutine called from main. The code changes the corresponding members of the 
dialog_state structure. After this has happened, the code in main calls then
init_dialog routine which unconditionally sets both the aspect ratio and the
tab len to its default value, thereby overwriting any changes which happened
as part of options processing.

The patch fixes this by changing the init_dialog code such that it only sets
these members to their default values if they don't have a value already (ie,
if their value is 0). It also removes a redundant "set aspect ratio to default
if still 0" statement from process_common_options.

-- System Information:
Debian Release: 10.5
  APT prefers stable-updates
  APT policy: (500, 'stable-updates'), (500, 'stable')
Architecture: amd64 (x86_64)

Kernel: Linux 4.19.0-8-amd64 (SMP w/24 CPU cores)
Kernel taint flags: TAINT_OOT_MODULE, TAINT_UNSIGNED_MODULE
Locale: LANG=en_US.UTF-8, LC_CTYPE=en_US.UTF-8 (charmap=UTF-8), 
LANGUAGE=en_US.UTF-8 (charmap=UTF-8)
Shell: /bin/sh linked to /usr/bin/dash
Init: systemd (via /run/systemd/system)
LSM: AppArmor: enabled

Versions of packages dialog depends on:
ii  debianutils   4.8.6.1
ii  libc6         2.28-10
ii  libncursesw6  6.1+20181013-2+deb10u2
ii  libtinfo6     6.1+20181013-2+deb10u2

dialog recommends no packages.

dialog suggests no packages.

-- no debconf information
diff --git a/dialog.c b/dialog.c
index b6fa6d4..6ec740d 100644
--- a/dialog.c
+++ b/dialog.c
@@ -1827,9 +1827,6 @@ process_common_options(int argc, char **argv, int offset, 
bool output)
            offset++;
     }
 
-    if (dialog_state.aspect_ratio == 0)
-       dialog_state.aspect_ratio = DEFAULT_ASPECT_RATIO;
-
     return offset;
 }
 
diff --git a/util.c b/util.c
index 64b67d9..e0a5938 100644
--- a/util.c
+++ b/util.c
@@ -322,8 +322,10 @@ init_dialog(FILE *input, FILE *output)
     setlocale(LC_ALL, "");
 
     dialog_state.output = output;
-    dialog_state.tab_len = TAB_LEN;
-    dialog_state.aspect_ratio = DEFAULT_ASPECT_RATIO;
+    if (dialog_state.tab_len == 0)
+        dialog_state.tab_len = TAB_LEN;
+    if (dialog_state.aspect_ratio == 0)
+        dialog_state.aspect_ratio = DEFAULT_ASPECT_RATIO;
 #ifdef HAVE_COLOR
     dialog_state.use_colors = USE_COLORS;      /* use colors by default? */
     dialog_state.use_shadow = USE_SHADOW;      /* shadow dialog boxes by 
default? */

Reply via email to