From 07cd4501440a37474f2bd7aab78faac588790c43 Mon Sep 17 00:00:00 2001 From: Kamil Dudka Date: Tue, 2 Apr 2019 10:43:46 +0200 Subject: [PATCH] make sure that variables on stack are initialized upstream bug: https://savannah.gnu.org/bugs/?56023 --- 0001-nano-4.0-init-vars.patch | 42 +++++++++++++++++++++++++++++++++++ nano.spec | 9 +++++++- 2 files changed, 50 insertions(+), 1 deletion(-) create mode 100644 0001-nano-4.0-init-vars.patch diff --git a/0001-nano-4.0-init-vars.patch b/0001-nano-4.0-init-vars.patch new file mode 100644 index 0000000..ba7e6be --- /dev/null +++ b/0001-nano-4.0-init-vars.patch @@ -0,0 +1,42 @@ +From d1d0b8a5a3ceff069f144a5f8ac01a175d96b511 Mon Sep 17 00:00:00 2001 +From: Devin Hussey +Date: Thu, 28 Mar 2019 17:28:47 -0400 +Subject: [PATCH] files: initialize a variable before referencing it + +The lack of initialization caused a nasty bug on some targets (such as +ARMv7) which would make it so that ^S would just say "Cancelled". + +While x86 (both 64 and 32 bits) seems to initialize 'response' to zero or +a positive number, ARM does not, and there is usually a negative value in +its place, which triggers the 'if (response < 0)' check and, as a result, +the code says "Cancelled". + +This fixes https://savannah.gnu.org/bugs/?56023. +Reported-by: Devin Hussey + +Bug existed since version 4.0, commit 0f9d60a3. + +Signed-off-by: Devin Hussey + +Upstream-commit: 7ad232d71470cd8c4dc63aeb02f11c9e8df9ecdb +Signed-off-by: Kamil Dudka +--- + src/files.c | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +diff --git a/src/files.c b/src/files.c +index 84e3f68..fd54c16 100644 +--- a/src/files.c ++++ b/src/files.c +@@ -2101,7 +2101,7 @@ int do_writeout(bool exiting, bool withprompt) + + while (TRUE) { + const char *msg; +- int response, choice; ++ int response = 0, choice = 0; + functionptrtype func; + #ifndef NANO_TINY + const char *formatstr, *backupstr; +-- +2.17.2 + diff --git a/nano.spec b/nano.spec index c2f37c6..b1f8455 100644 --- a/nano.spec +++ b/nano.spec @@ -1,7 +1,7 @@ Summary: A small text editor Name: nano Version: 4.0 -Release: 1%{?dist} +Release: 2%{?dist} License: GPLv3+ URL: https://www.nano-editor.org Source: https://www.nano-editor.org/dist/latest/%{name}-%{version}.tar.xz @@ -17,6 +17,10 @@ BuildRequires: sed BuildRequires: texinfo Conflicts: filesystem < 3 +# make sure that variables on stack are initialized +# upstream bug: https://savannah.gnu.org/bugs/?56023 +Patch1: 0001-nano-4.0-init-vars.patch + %description GNU nano is a small and friendly text editor. @@ -64,6 +68,9 @@ install -m 0644 ./nanorc %{buildroot}%{_sysconfdir}/nanorc %{_datadir}/nano %changelog +* Tue Apr 02 2019 Kamil Dudka - 4.0-2 +- make sure that variables on stack are initialized + * Mon Mar 25 2019 Kamil Dudka - 4.0-1 - new upstream release