unofficial mirror of notmuch@notmuchmail.org
 help / color / mirror / code / Atom feed
* [PATCH] notmuch-dump.c: Fix output file being closed twice
@ 2019-07-23 20:30 Ralph Seichter
  2019-07-23 20:48 ` [PATCH] notmuch-dump.c: Fix output file being closed twice (V2) Ralph Seichter
  0 siblings, 1 reply; 5+ messages in thread
From: Ralph Seichter @ 2019-07-23 20:30 UTC (permalink / raw)
  To: notmuch

Fixed: If the output file for a dump was non-writeable, gzclose_w()
was called twice on the output file handle, resulting in SIGABRT.
---
 notmuch-dump.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/notmuch-dump.c b/notmuch-dump.c
index 505c1469..78282661 100644
--- a/notmuch-dump.c
+++ b/notmuch-dump.c
@@ -329,11 +329,12 @@ notmuch_database_dump (notmuch_database_t *notmuch,
 	}
     }
 
-    if (gzclose_w (output) != Z_OK) {
+    ret = gzclose_w (output);
+    output = NULL;
+    if (ret) {
 	fprintf (stderr, "Error closing %s: %s\n", name_for_error,
 		 gzerror (output, NULL));
 	ret = EXIT_FAILURE;
-	output = NULL;
 	goto DONE;
     }
 
-- 
2.21.0

^ permalink raw reply related	[flat|nested] 5+ messages in thread

* [PATCH] notmuch-dump.c: Fix output file being closed twice (V2)
  2019-07-23 20:30 [PATCH] notmuch-dump.c: Fix output file being closed twice Ralph Seichter
@ 2019-07-23 20:48 ` Ralph Seichter
  2019-07-23 20:48   ` [PATCH] notmuch-dump.c: Fix output file being closed twice Ralph Seichter
  0 siblings, 1 reply; 5+ messages in thread
From: Ralph Seichter @ 2019-07-23 20:48 UTC (permalink / raw)
  To: notmuch

This is version 2 of the patch, sorry for that. I had sent an older
version by mistake.

-Ralph

^ permalink raw reply	[flat|nested] 5+ messages in thread

* [PATCH] notmuch-dump.c: Fix output file being closed twice
  2019-07-23 20:48 ` [PATCH] notmuch-dump.c: Fix output file being closed twice (V2) Ralph Seichter
@ 2019-07-23 20:48   ` Ralph Seichter
  2019-07-23 22:26     ` David Bremner
  0 siblings, 1 reply; 5+ messages in thread
From: Ralph Seichter @ 2019-07-23 20:48 UTC (permalink / raw)
  To: notmuch

Fixed: If the output file for a dump was non-writeable, gzclose_w()
was called twice on the output file handle, resulting in SIGABRT.
---
 notmuch-dump.c | 8 +++++---
 1 file changed, 5 insertions(+), 3 deletions(-)

diff --git a/notmuch-dump.c b/notmuch-dump.c
index 505c1469..ca73d003 100644
--- a/notmuch-dump.c
+++ b/notmuch-dump.c
@@ -329,13 +329,15 @@ notmuch_database_dump (notmuch_database_t *notmuch,
 	}
     }
 
-    if (gzclose_w (output) != Z_OK) {
+    ret = gzclose_w (output);
+    if (ret) {
 	fprintf (stderr, "Error closing %s: %s\n", name_for_error,
 		 gzerror (output, NULL));
 	ret = EXIT_FAILURE;
-	output = NULL;
+        output = NULL;
 	goto DONE;
-    }
+    } else
+        output = NULL;
 
     if (output_file_name) {
 	ret = rename (tempname, output_file_name);
-- 
2.21.0

^ permalink raw reply related	[flat|nested] 5+ messages in thread

* Re: [PATCH] notmuch-dump.c: Fix output file being closed twice
  2019-07-23 20:48   ` [PATCH] notmuch-dump.c: Fix output file being closed twice Ralph Seichter
@ 2019-07-23 22:26     ` David Bremner
  2019-07-24 20:56       ` David Bremner
  0 siblings, 1 reply; 5+ messages in thread
From: David Bremner @ 2019-07-23 22:26 UTC (permalink / raw)
  To: Ralph Seichter, notmuch

Ralph Seichter <abbot@monksofcool.net> writes:

> Fixed: If the output file for a dump was non-writeable, gzclose_w()
> was called twice on the output file handle, resulting in SIGABRT.

LGTM, although I did have to revert one unrelated whitespace change.

I'll push that later if no-one objects.

d

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH] notmuch-dump.c: Fix output file being closed twice
  2019-07-23 22:26     ` David Bremner
@ 2019-07-24 20:56       ` David Bremner
  0 siblings, 0 replies; 5+ messages in thread
From: David Bremner @ 2019-07-24 20:56 UTC (permalink / raw)
  To: Ralph Seichter, notmuch

David Bremner <david@tethera.net> writes:

> Ralph Seichter <abbot@monksofcool.net> writes:
>
>> Fixed: If the output file for a dump was non-writeable, gzclose_w()
>> was called twice on the output file handle, resulting in SIGABRT.
>
> LGTM, although I did have to revert one unrelated whitespace change.
>
> I'll push that later if no-one objects.

No one objected, pushed,

d

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2019-07-27 23:39 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-07-23 20:30 [PATCH] notmuch-dump.c: Fix output file being closed twice Ralph Seichter
2019-07-23 20:48 ` [PATCH] notmuch-dump.c: Fix output file being closed twice (V2) Ralph Seichter
2019-07-23 20:48   ` [PATCH] notmuch-dump.c: Fix output file being closed twice Ralph Seichter
2019-07-23 22:26     ` David Bremner
2019-07-24 20:56       ` David Bremner

Code repositories for project(s) associated with this public inbox

	https://yhetil.org/notmuch.git/

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).