Compare commits

...
Sign in to create a new pull request.

4 commits

Author SHA1 Message Date
Kamil Dudka
f5d7371524 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
2019-05-28 15:03:57 +02:00
Kamil Dudka
33d1cc4784 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
2019-05-28 15:03:46 +02:00
Kamil Dudka
5c94725492 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
2019-05-28 15:03:32 +02:00
Kamil Dudka
a1a0e85294 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
2019-05-28 15:03:14 +02:00
5 changed files with 184 additions and 1 deletions

View file

@ -0,0 +1,49 @@
From c3bf9d981768bb1e96d73c9a001a6a77713a6245 Mon Sep 17 00:00:00 2001
From: David Lawrence Ramsey <pooka109@gmail.com>
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 <kdudka@redhat.com>
---
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, &quotereg, 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

View file

@ -0,0 +1,48 @@
From 8817d48ce9b2fccba83251f10cd7827412c9ef41 Mon Sep 17 00:00:00 2001
From: Brand Huntsman <alpha@qzx.com>
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 <mrkiko.rs@gmail.com>
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 <alpha@qzx.com>
Upstream-commit: a5ef013e826bfd10d530dabbd961f9044b95b53f
Signed-off-by: Kamil Dudka <kdudka@redhat.com>
---
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

View file

@ -0,0 +1,38 @@
From c03f2cc36a2539316437cff4313823c0a0882473 Mon Sep 17 00:00:00 2001
From: Benno Schulenberg <bensberg@telfort.nl>
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 <husseydevin@gmail.com>
Bug existed since around version 2.9.2.
Upstream-commit: 1c707d4f99cc919070104de09efe1e5a6302b6ce
Signed-off-by: Kamil Dudka <kdudka@redhat.com>
---
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

View file

@ -0,0 +1,30 @@
From 00351963c03818d058bfc355663fe0d7c86b9386 Mon Sep 17 00:00:00 2001
From: Benno Schulenberg <bensberg@telfort.nl>
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 <kdudka@redhat.com>
---
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

View file

@ -1,7 +1,7 @@
Summary: A small text editor
Name: nano
Version: 2.9.8
Release: 1%{?dist}
Release: 2%{?dist}
License: GPLv3+
URL: https://www.nano-editor.org
Source: https://www.nano-editor.org/dist/v2.9/%{name}-%{version}.tar.gz
@ -19,6 +19,18 @@ Conflicts: filesystem < 3
Requires(post): /sbin/install-info
Requires(preun): /sbin/install-info
# 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
# 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.
@ -80,6 +92,12 @@ exit 0
%{_datadir}/nano
%changelog
* Tue May 28 2019 Kamil Dudka <kdudka@redhat.com> - 2.9.8-2
- 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
* Mon Jun 04 2018 Kamil Dudka <kdudka@redhat.com> - 2.9.8-1
- new upstream release