From 858ba934efd64501d99a2161014f0ffbcfb89463 Mon Sep 17 00:00:00 2001 From: Kamil Dudka Date: Tue, 28 May 2019 14:21:58 +0200 Subject: [PATCH 1/4] do not crash on a bad quoting regex Suggested by Benno Schulenberg (upstream maintainer) at: http://lists.gnu.org/archive/html/nano-devel/2019-05/msg00027.html --- ...-nano-3.0-crash-on-bad-quoting-regex.patch | 49 +++++++++++++++++++ nano.spec | 8 ++- 2 files changed, 56 insertions(+), 1 deletion(-) create mode 100644 0002-nano-3.0-crash-on-bad-quoting-regex.patch diff --git a/0002-nano-3.0-crash-on-bad-quoting-regex.patch b/0002-nano-3.0-crash-on-bad-quoting-regex.patch new file mode 100644 index 0000000..097c6a6 --- /dev/null +++ b/0002-nano-3.0-crash-on-bad-quoting-regex.patch @@ -0,0 +1,49 @@ +From c3bf9d981768bb1e96d73c9a001a6a77713a6245 Mon Sep 17 00:00:00 2001 +From: David Lawrence Ramsey +Date: Mon, 10 Dec 2018 14:25:15 -0600 +Subject: [PATCH] options: exit on a bad quoting regex, instead of crashing + later + +The paragraph-jumping functions used the regex unverified... + +This fixes https://savannah.gnu.org/bugs/?55169. + +Upstream-commit: 6e3b9ac0587243460c1f8a19d3fcc4402f98808d +Signed-off-by: Kamil Dudka +--- + src/nano.c | 2 ++ + src/text.c | 5 ----- + 2 files changed, 2 insertions(+), 5 deletions(-) + +diff --git a/src/nano.c b/src/nano.c +index 74e1243..1900d3e 100644 +--- a/src/nano.c ++++ b/src/nano.c +@@ -2486,6 +2486,8 @@ int main(int argc, char **argv) + + quoteerr = charalloc(size); + regerror(quoterc, "ereg, quoteerr, size); ++ ++ die(_("Bad quoting regex \"%s\": %s\n"), quotestr, quoteerr); + } + #endif /* ENABLE_JUSTIFY */ + +diff --git a/src/text.c b/src/text.c +index 8919916..6e730b6 100644 +--- a/src/text.c ++++ b/src/text.c +@@ -2131,11 +2131,6 @@ bool find_paragraph(size_t *const quote, size_t *const par) + filestruct *current_save; + /* The line at the beginning of the paragraph we search for. */ + +- if (quoterc != 0) { +- statusline(ALERT, _("Bad quote string %s: %s"), quotestr, quoteerr); +- return FALSE; +- } +- + /* If we're at the end of the last line of the file, it means that + * there aren't any paragraphs left, so get out. */ + if (openfile->current == openfile->filebot && openfile->current_x == +-- +2.20.1 + diff --git a/nano.spec b/nano.spec index 8e7d756..b0ea019 100644 --- a/nano.spec +++ b/nano.spec @@ -1,7 +1,7 @@ Summary: A small text editor Name: nano Version: 3.0 -Release: 2%{?dist} +Release: 3%{?dist} License: GPLv3+ URL: https://www.nano-editor.org Source: https://www.nano-editor.org/dist/latest/%{name}-%{version}.tar.xz @@ -22,6 +22,9 @@ Requires(preun): /sbin/install-info # when Ctrl+Shift+Delete has no key code, do not fall back to KEY_BACKSPACE Patch1: 0001-nano-3.0-key-bsp.patch +# do not crash on a bad quoting regex +Patch2: 0002-nano-3.0-crash-on-bad-quoting-regex.patch + %description GNU nano is a small and friendly text editor. @@ -83,6 +86,9 @@ exit 0 %{_datadir}/nano %changelog +* Tue May 28 2019 Kamil Dudka - 3.0-3 +- do not crash on a bad quoting regex + * Fri Sep 14 2018 Kamil Dudka - 3.0-2 - when Ctrl+Shift+Delete has no key code, do not fall back to KEY_BACKSPACE From f0db2d58d12fb26425f5a1d993f1b76610b1623c Mon Sep 17 00:00:00 2001 From: Kamil Dudka Date: Tue, 28 May 2019 14:49:49 +0200 Subject: [PATCH 2/4] fix user-after-free bug on position_history Suggested by Benno Schulenberg (upstream maintainer) at: http://lists.gnu.org/archive/html/nano-devel/2019-05/msg00027.html --- 0003-nano-3.0-history-use-after-free.patch | 48 ++++++++++++++++++++++ nano.spec | 4 ++ 2 files changed, 52 insertions(+) create mode 100644 0003-nano-3.0-history-use-after-free.patch diff --git a/0003-nano-3.0-history-use-after-free.patch b/0003-nano-3.0-history-use-after-free.patch new file mode 100644 index 0000000..3a8bbb4 --- /dev/null +++ b/0003-nano-3.0-history-use-after-free.patch @@ -0,0 +1,48 @@ +From 8817d48ce9b2fccba83251f10cd7827412c9ef41 Mon Sep 17 00:00:00 2001 +From: Brand Huntsman +Date: Wed, 27 Feb 2019 02:40:18 -0700 +Subject: [PATCH] history: use an unfreed 'position_history' to avoid a + possible crash + +The reload_positions_if_needed() routine can free the existing +'position_history' and allocate a new one. Using the old one, +from before the reload, could lead to a crash. + +This fixes https://savannah.gnu.org/bugs/?55792. +Reported-by: Enrico Mioso + +Bug existed since the reloading of the position-history file was +introduced, a year and a half ago, in commit bfc53f30. + +Signed-off-by: Brand Huntsman + +Upstream-commit: a5ef013e826bfd10d530dabbd961f9044b95b53f +Signed-off-by: Kamil Dudka +--- + src/history.c | 3 ++- + 1 file changed, 2 insertions(+), 1 deletion(-) + +diff --git a/src/history.c b/src/history.c +index 5668038..ca8c60d 100644 +--- a/src/history.c ++++ b/src/history.c +@@ -593,7 +593,7 @@ void update_poshistory(char *filename, ssize_t lineno, ssize_t xpos) + * set line and column to the retrieved values. */ + bool has_old_position(const char *file, ssize_t *line, ssize_t *column) + { +- poshiststruct *posptr = position_history; ++ poshiststruct *posptr; + char *fullpath = get_full_path(file); + + if (fullpath == NULL) +@@ -601,6 +601,7 @@ bool has_old_position(const char *file, ssize_t *line, ssize_t *column) + + reload_positions_if_needed(); + ++ posptr = position_history; + while (posptr != NULL && strcmp(posptr->filename, fullpath) != 0) + posptr = posptr->next; + +-- +2.20.1 + diff --git a/nano.spec b/nano.spec index b0ea019..8a8f3f1 100644 --- a/nano.spec +++ b/nano.spec @@ -25,6 +25,9 @@ Patch1: 0001-nano-3.0-key-bsp.patch # do not crash on a bad quoting regex Patch2: 0002-nano-3.0-crash-on-bad-quoting-regex.patch +# fix user-after-free bug on position_history +Patch3: 0003-nano-3.0-history-use-after-free.patch + %description GNU nano is a small and friendly text editor. @@ -87,6 +90,7 @@ exit 0 %changelog * Tue May 28 2019 Kamil Dudka - 3.0-3 +- fix user-after-free bug on position_history - do not crash on a bad quoting regex * Fri Sep 14 2018 Kamil Dudka - 3.0-2 From 2236a37f628a75fd315e6fe5ca1a4b8f2d54e83e Mon Sep 17 00:00:00 2001 From: Kamil Dudka Date: Tue, 28 May 2019 14:53:07 +0200 Subject: [PATCH 3/4] display partial lines properly on unindent Suggested by Benno Schulenberg (upstream maintainer) at: http://lists.gnu.org/archive/html/nano-devel/2019-05/msg00027.html --- 0004-nano-3.0-unindent-partial-line.patch | 38 +++++++++++++++++++++++ nano.spec | 4 +++ 2 files changed, 42 insertions(+) create mode 100644 0004-nano-3.0-unindent-partial-line.patch diff --git a/0004-nano-3.0-unindent-partial-line.patch b/0004-nano-3.0-unindent-partial-line.patch new file mode 100644 index 0000000..8f1797c --- /dev/null +++ b/0004-nano-3.0-unindent-partial-line.patch @@ -0,0 +1,38 @@ +From c03f2cc36a2539316437cff4313823c0a0882473 Mon Sep 17 00:00:00 2001 +From: Benno Schulenberg +Date: Fri, 12 Apr 2019 14:00:14 +0200 +Subject: [PATCH] unindent: ensure that a partial line gets displayed properly + afterwards + +When only the trailing chunk of a line is displayed on the top row of +the screen, and the unindenting of this line leads to a reduction in +the number of chunks, then the starting point of the viewport needs +to be re-evaluated. For simplicity, do this always when something is +unindented. + +This fixes https://savannah.gnu.org/bugs/?56102. +Reported-by: Devin Hussey + +Bug existed since around version 2.9.2. + +Upstream-commit: 1c707d4f99cc919070104de09efe1e5a6302b6ce +Signed-off-by: Kamil Dudka +--- + src/text.c | 1 + + 1 file changed, 1 insertion(+) + +diff --git a/src/text.c b/src/text.c +index 6e730b6..eb0163e 100644 +--- a/src/text.c ++++ b/src/text.c +@@ -443,6 +443,7 @@ void do_unindent(void) + } + + set_modified(); ++ ensure_firstcolumn_is_aligned(); + refresh_needed = TRUE; + shift_held = TRUE; + } +-- +2.20.1 + diff --git a/nano.spec b/nano.spec index 8a8f3f1..2f2f584 100644 --- a/nano.spec +++ b/nano.spec @@ -28,6 +28,9 @@ Patch2: 0002-nano-3.0-crash-on-bad-quoting-regex.patch # fix user-after-free bug on position_history Patch3: 0003-nano-3.0-history-use-after-free.patch +# display partial lines properly on unindent +Patch4: 0004-nano-3.0-unindent-partial-line.patch + %description GNU nano is a small and friendly text editor. @@ -90,6 +93,7 @@ exit 0 %changelog * Tue May 28 2019 Kamil Dudka - 3.0-3 +- display partial lines properly on unindent - fix user-after-free bug on position_history - do not crash on a bad quoting regex From 7dd10c2d717583f1c6e76a35ecd2127f3f4e483f Mon Sep 17 00:00:00 2001 From: Kamil Dudka Date: Tue, 28 May 2019 14:14:25 +0200 Subject: [PATCH 4/4] fix possible crash while opening help Suggested by Benno Schulenberg (upstream maintainer) at: http://lists.gnu.org/archive/html/nano-devel/2019-05/msg00027.html --- 0005-nano-4.2-help-crash.patch | 30 ++++++++++++++++++++++++++++++ nano.spec | 4 ++++ 2 files changed, 34 insertions(+) create mode 100644 0005-nano-4.2-help-crash.patch diff --git a/0005-nano-4.2-help-crash.patch b/0005-nano-4.2-help-crash.patch new file mode 100644 index 0000000..0b55415 --- /dev/null +++ b/0005-nano-4.2-help-crash.patch @@ -0,0 +1,30 @@ +From 00351963c03818d058bfc355663fe0d7c86b9386 Mon Sep 17 00:00:00 2001 +From: Benno Schulenberg +Date: Thu, 23 May 2019 12:43:31 +0200 +Subject: [PATCH] help: don't check for confinement when opening a temporary + help-text file + +This fixes https://savannah.gnu.org/bugs/?56369. + +Upstream-commit: acd23551c3322f397dc43f97796273a8958f6ef9 +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 20bbd942..7952bc00 100644 +--- a/src/files.c ++++ b/src/files.c +@@ -420,7 +420,7 @@ bool open_buffer(const char *filename, bool new_buffer) + as_an_at = FALSE; + + #ifdef ENABLE_OPERATINGDIR +- if (outside_of_confinement(filename, FALSE)) { ++ if (!inhelp && outside_of_confinement(filename, FALSE)) { + statusline(ALERT, _("Can't read file from outside of %s"), + operating_dir); + return FALSE; +-- +2.20.1 + diff --git a/nano.spec b/nano.spec index 2f2f584..f25bf87 100644 --- a/nano.spec +++ b/nano.spec @@ -31,6 +31,9 @@ Patch3: 0003-nano-3.0-history-use-after-free.patch # display partial lines properly on unindent Patch4: 0004-nano-3.0-unindent-partial-line.patch +# fix possible crash while opening help +Patch5: 0005-nano-4.2-help-crash.patch + %description GNU nano is a small and friendly text editor. @@ -93,6 +96,7 @@ exit 0 %changelog * Tue May 28 2019 Kamil Dudka - 3.0-3 +- fix possible crash while opening help - display partial lines properly on unindent - fix user-after-free bug on position_history - do not crash on a bad quoting regex