From: schwarze@mandoc.bsd.lv
To: source@mandoc.bsd.lv
Subject: mandoc: Invalidate the tag_files.tfd after fclose(3)ing the stram
Date: Fri, 23 Feb 2018 11:47:40 -0500 (EST) [thread overview]
Message-ID: <84f4c45ed345292c@fantadrom.bsd.lv> (raw)
Log Message:
-----------
Invalidate the tag_files.tfd after fclose(3)ing the stram associated
with it. In main() assert that the tfd was actually invalidated.
This avoids closing an invalid fd.
From tb@; OK deraadt@ on an earlier version.
Modified Files:
--------------
mandoc:
main.c
tag.c
Revision Data
-------------
Index: tag.c
===================================================================
RCS file: /home/cvs/mandoc/mandoc/tag.c,v
retrieving revision 1.18
retrieving revision 1.19
diff -Ltag.c -Ltag.c -u -p -r1.18 -r1.19
--- tag.c
+++ tag.c
@@ -213,6 +213,9 @@ tag_write(void)
ohash_delete(&tag_data);
if (stream != NULL)
fclose(stream);
+ else
+ close(tag_files.tfd);
+ tag_files.tfd = -1;
}
void
Index: main.c
===================================================================
RCS file: /home/cvs/mandoc/mandoc/main.c,v
retrieving revision 1.302
retrieving revision 1.303
diff -Lmain.c -Lmain.c -u -p -r1.302 -r1.303
--- main.c
+++ main.c
@@ -1184,7 +1184,7 @@ spawn_pager(struct tag_files *tag_files)
if (dup2(tag_files->ofd, STDOUT_FILENO) == -1)
err((int)MANDOCLEVEL_SYSERR, "pager stdout");
close(tag_files->ofd);
- close(tag_files->tfd);
+ assert(tag_files->tfd == -1);
/* Do not start the pager before controlling the terminal. */
--
To unsubscribe send an email to source+unsubscribe@mandoc.bsd.lv
reply other threads:[~2018-02-23 16:47 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=84f4c45ed345292c@fantadrom.bsd.lv \
--to=schwarze@mandoc.bsd.lv \
--cc=source@mandoc.bsd.lv \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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 NNTP newsgroup(s).