* [PATCH] debugfs: don't try to fclose NULL
@ 2009-06-26 18:57 Eric Sandeen
2009-06-29 5:07 ` Theodore Tso
2009-06-30 15:44 ` Thierry Vignaud
0 siblings, 2 replies; 5+ messages in thread
From: Eric Sandeen @ 2009-06-26 18:57 UTC (permalink / raw)
To: ext4 development
do_logdump may jump to errout if fopen(out_file) fails,
but in that case out_file is NULL, and fclose will segfault.
Signed-off-by: Eric Sandeen <sandeen@redhat.com>
---
diff --git a/debugfs/logdump.c b/debugfs/logdump.c
index 4818bc6..9a7108a 100644
--- a/debugfs/logdump.c
+++ b/debugfs/logdump.c
@@ -259,7 +259,7 @@ void do_logdump(int argc, char **argv)
close(journal_fd);
errout:
- if (out_file != stdout)
+ if (out_file && (out_file != stdout))
fclose(out_file);
return;
^ permalink raw reply related [flat|nested] 5+ messages in thread
* Re: [PATCH] debugfs: don't try to fclose NULL
2009-06-26 18:57 [PATCH] debugfs: don't try to fclose NULL Eric Sandeen
@ 2009-06-29 5:07 ` Theodore Tso
2009-06-30 15:44 ` Thierry Vignaud
1 sibling, 0 replies; 5+ messages in thread
From: Theodore Tso @ 2009-06-29 5:07 UTC (permalink / raw)
To: Eric Sandeen; +Cc: ext4 development
On Fri, Jun 26, 2009 at 01:57:39PM -0500, Eric Sandeen wrote:
> do_logdump may jump to errout if fopen(out_file) fails,
> but in that case out_file is NULL, and fclose will segfault.
>
> Signed-off-by: Eric Sandeen <sandeen@redhat.com>
Thanks, applied.
- Ted
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH] debugfs: don't try to fclose NULL
2009-06-26 18:57 [PATCH] debugfs: don't try to fclose NULL Eric Sandeen
2009-06-29 5:07 ` Theodore Tso
@ 2009-06-30 15:44 ` Thierry Vignaud
2009-06-30 16:39 ` Theodore Tso
1 sibling, 1 reply; 5+ messages in thread
From: Thierry Vignaud @ 2009-06-30 15:44 UTC (permalink / raw)
To: Eric Sandeen; +Cc: ext4 development
Eric Sandeen <sandeen@redhat.com> writes:
> do_logdump may jump to errout if fopen(out_file) fails,
> but in that case out_file is NULL, and fclose will segfault.
You should report that segfault to glibc authors too.
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH] debugfs: don't try to fclose NULL
2009-06-30 15:44 ` Thierry Vignaud
@ 2009-06-30 16:39 ` Theodore Tso
2009-06-30 16:46 ` Alex Buell
0 siblings, 1 reply; 5+ messages in thread
From: Theodore Tso @ 2009-06-30 16:39 UTC (permalink / raw)
To: Thierry Vignaud; +Cc: Eric Sandeen, ext4 development
On Tue, Jun 30, 2009 at 05:44:55PM +0200, Thierry Vignaud wrote:
> Eric Sandeen <sandeen@redhat.com> writes:
>
> > do_logdump may jump to errout if fopen(out_file) fails,
> > but in that case out_file is NULL, and fclose will segfault.
>
> You should report that segfault to glibc authors too.
It would be robust for glibc to code fclose() defensively such that it
would survive a null pointer, but I don't think it's technically
required by the ANSI or POSIX spec.
- Ted
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH] debugfs: don't try to fclose NULL
2009-06-30 16:39 ` Theodore Tso
@ 2009-06-30 16:46 ` Alex Buell
0 siblings, 0 replies; 5+ messages in thread
From: Alex Buell @ 2009-06-30 16:46 UTC (permalink / raw)
To: Theodore Tso; +Cc: Thierry Vignaud, Eric Sandeen, ext4 development
On Tue, 2009-06-30 at 12:39 -0400, Theodore Tso wrote:
> On Tue, Jun 30, 2009 at 05:44:55PM +0200, Thierry Vignaud wrote:
> > Eric Sandeen <sandeen@redhat.com> writes:
> >
> > > do_logdump may jump to errout if fopen(out_file) fails,
> > > but in that case out_file is NULL, and fclose will segfault.
> >
> > You should report that segfault to glibc authors too.
>
> It would be robust for glibc to code fclose() defensively such that it
> would survive a null pointer, but I don't think it's technically
> required by the ANSI or POSIX spec.
It's the programmer's responsibility to write the following:
if (fp)
fclose(fp);
--
http://www.munted.org.uk
One very high maintenance cat living here.
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2009-06-30 17:06 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2009-06-26 18:57 [PATCH] debugfs: don't try to fclose NULL Eric Sandeen
2009-06-29 5:07 ` Theodore Tso
2009-06-30 15:44 ` Thierry Vignaud
2009-06-30 16:39 ` Theodore Tso
2009-06-30 16:46 ` Alex Buell
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.