[nano] fix bugs introduced by patches added in 2.2.6-1 (#657875)

Kamil Dudka kdudka at fedoraproject.org
Sun Nov 28 20:03:19 UTC 2010


commit b5207be6553e43462c475db08f184e0656e608f7
Author: Kamil Dudka <kdudka at redhat.com>
Date:   Sun Nov 28 21:01:32 2010 +0100

    fix bugs introduced by patches added in 2.2.6-1 (#657875)

 ...s-result-and-avoid-calling-stat-on-a-NULL.patch |   24 +++++-----
 ...se-futimens-if-available-instead-of-utime.patch |   49 +++++++++++++++----
 nano.spec                                          |    5 ++-
 3 files changed, 54 insertions(+), 24 deletions(-)
---
diff --git a/0001-check-stat-s-result-and-avoid-calling-stat-on-a-NULL.patch b/0001-check-stat-s-result-and-avoid-calling-stat-on-a-NULL.patch
index b6ce9b1..9922877 100644
--- a/0001-check-stat-s-result-and-avoid-calling-stat-on-a-NULL.patch
+++ b/0001-check-stat-s-result-and-avoid-calling-stat-on-a-NULL.patch
@@ -1,14 +1,14 @@
-From de9e2d69f9ce3ec89ab499be96cda69509205ffd Mon Sep 17 00:00:00 2001
+From 63c92c82a8de237f22648d4ffef64b9ad23eb2e3 Mon Sep 17 00:00:00 2001
 From: Kamil Dudka <kdudka at redhat.com>
 Date: Thu, 19 Aug 2010 13:58:12 +0200
 Subject: [PATCH 1/2] check stat's result and avoid calling stat on a NULL pointer
 
 ---
- src/files.c |   33 ++++++++++++++++++++++-----------
- 1 files changed, 22 insertions(+), 11 deletions(-)
+ src/files.c |   33 +++++++++++++++++++++++++--------
+ 1 files changed, 25 insertions(+), 8 deletions(-)
 
 diff --git a/src/files.c b/src/files.c
-index c5b9d6a..49555a5 100644
+index c5b9d6a..656a684 100644
 --- a/src/files.c
 +++ b/src/files.c
 @@ -103,6 +103,24 @@ void initialize_buffer_text(void)
@@ -60,15 +60,15 @@ index c5b9d6a..49555a5 100644
  
      /* We backup only if the backup toggle is set, the file isn't
       * temporary, and the file already exists.  Furthermore, if we
-@@ -1891,10 +1905,7 @@ bool write_file(const char *name, FILE *f_open, bool tmp, append_type
- 
- #ifndef NANO_TINY
- 	/* Update current_stat to reference the file as it is now. */
--	if (openfile->current_stat == NULL)
--	    openfile->current_stat =
--		(struct stat *)nmalloc(sizeof(struct stat));
+@@ -1894,7 +1908,10 @@ bool write_file(const char *name, FILE *f_open, bool tmp, append_type
+ 	if (openfile->current_stat == NULL)
+ 	    openfile->current_stat =
+ 		(struct stat *)nmalloc(sizeof(struct stat));
 -	stat(realname, openfile->current_stat);
-+	stat_if_needed(realname, &openfile->current_stat);
++	if (stat(realname, openfile->current_stat)) {
++	    free(openfile->current_stat);
++	    openfile->current_stat = NULL;
++	}
  #endif
  
  	statusbar(P_("Wrote %lu line", "Wrote %lu lines",
diff --git a/0002-use-futimens-if-available-instead-of-utime.patch b/0002-use-futimens-if-available-instead-of-utime.patch
index 74bed4b..76901dc 100644
--- a/0002-use-futimens-if-available-instead-of-utime.patch
+++ b/0002-use-futimens-if-available-instead-of-utime.patch
@@ -1,4 +1,4 @@
-From ea6be4984d6fa72afb41dcb9f0039d0fd80dd5c1 Mon Sep 17 00:00:00 2001
+From e014ef2cf988a232a702292c82cd577719d08d8c Mon Sep 17 00:00:00 2001
 From: Kamil Dudka <kdudka at redhat.com>
 Date: Thu, 19 Aug 2010 15:23:06 +0200
 Subject: [PATCH 2/2] use futimens() if available, instead of utime()
@@ -7,8 +7,8 @@ Subject: [PATCH 2/2] use futimens() if available, instead of utime()
  config.h.in  |    3 +++
  configure    |    2 +-
  configure.ac |    2 +-
- src/files.c  |   26 +++++++++++++++++++++++++-
- 4 files changed, 30 insertions(+), 3 deletions(-)
+ src/files.c  |   46 +++++++++++++++++++++++++++++++++++-----------
+ 4 files changed, 40 insertions(+), 13 deletions(-)
 
 diff --git a/config.h.in b/config.h.in
 index 8fbe824..fb0e65d 100644
@@ -51,7 +51,7 @@ index 6388c03..255ec5d 100644
  if test x$enable_utf8 != xno; then
      AC_CHECK_FUNCS(iswalnum iswblank iswpunct iswspace nl_langinfo mblen mbstowcs mbtowc wctomb wcwidth)
 diff --git a/src/files.c b/src/files.c
-index 49555a5..a3917b7 100644
+index 656a684..889c4a8 100644
 --- a/src/files.c
 +++ b/src/files.c
 @@ -1434,6 +1434,29 @@ int copy_file(FILE *inn, FILE *out)
@@ -84,16 +84,43 @@ index 49555a5..a3917b7 100644
  /* Write a file out to disk.  If f_open isn't NULL, we assume that it is
   * a stream associated with the file, and we don't try to open it
   * ourselves.  If tmp is TRUE, we set the umask to disallow anyone else
-@@ -1677,7 +1700,8 @@ bool write_file(const char *name, FILE *f_open, bool tmp, append_type
- 	}
+@@ -1666,6 +1689,18 @@ bool write_file(const char *name, FILE *f_open, bool tmp, append_type
+ 	fprintf(stderr, "Backing up %s to %s\n", realname, backupname);
+ #endif
  
- 	/* And set its metadata. */
--	if (utime(backupname, &filetime) == -1 && !ISSET(INSECURE_BACKUP)) {
++	/* Set backup's file metadata. */
 +	if (utime_wrap(backup_fd, backupname, &filetime) == -1
 +		&& !ISSET(INSECURE_BACKUP)) {
- 	    statusbar(_("Error writing backup file %s: %s"), backupname,
- 			strerror(errno));
- 	    /* If we can't write to the backup, DONT go on, since
++	    statusbar(_("Error writing backup file %s: %s"), backupname,
++			strerror(errno));
++	    /* If we can't write to the backup, DONT go on, since
++	       whatever caused the backup file to fail (e.g. disk
++	       full may well cause the real file write to fail, which
++	       means we could lose both the backup and the original! */
++	    goto cleanup_and_exit;
++	}
++
+ 	/* Copy the file. */
+ 	copy_status = copy_file(f, backup_file);
+ 
+@@ -1676,17 +1711,6 @@ bool write_file(const char *name, FILE *f_open, bool tmp, append_type
+ 	    goto cleanup_and_exit;
+ 	}
+ 
+-	/* And set its metadata. */
+-	if (utime(backupname, &filetime) == -1 && !ISSET(INSECURE_BACKUP)) {
+-	    statusbar(_("Error writing backup file %s: %s"), backupname,
+-			strerror(errno));
+-	    /* If we can't write to the backup, DONT go on, since
+-	       whatever caused the backup file to fail (e.g. disk
+-	       full may well cause the real file write to fail, which
+-	       means we could lose both the backup and the original! */
+-	    goto cleanup_and_exit;
+-	}
+-
+ 	free(backupname);
+     }
+ 
 -- 
 1.7.3.2
 
diff --git a/nano.spec b/nano.spec
index 2d9fd2f..b666c44 100644
--- a/nano.spec
+++ b/nano.spec
@@ -1,7 +1,7 @@
 Summary:         A small text editor
 Name:            nano
 Version:         2.2.6
-Release:         1%{?dist}
+Release:         2%{?dist}
 License:         GPLv3+
 Group:           Applications/Editors
 URL:             http://www.nano-editor.org
@@ -94,6 +94,9 @@ rm -rf %{buildroot}
 %{_datadir}/nano
 
 %changelog
+* Sun Nov 28 2010 Kamil Dudka <kdudka at redhat.com> - 2.2.6-2
+- fix bugs introduced by patches added in 2.2.6-1 (#657875)
+
 * Mon Nov 22 2010 Kamil Dudka <kdudka at redhat.com> - 2.2.6-1
 - new upstream release (#655978)
 - increase code robustness (patches related to CVE-2010-1160, CVE-2010-1161)


More information about the scm-commits mailing list