From: Vegard Nossum <vegard.nossum@gmail.com>
To: linux-sparse@vger.kernel.org
Subject: [PATCH] Fix use of invalid file descriptor
Date: Sun, 25 May 2008 09:51:57 +0200 [thread overview]
Message-ID: <20080525075157.GA3681@damson.getinternet.no> (raw)
From: Vegard Nossum <vegardno@ifi.uio.no>
Date: Sun, 25 May 2008 09:41:29 +0200
Subject: [PATCH] Fix use of invalid file descriptor
tokenize_buffer() calls setup_stream() with a file descriptor argument of -1.
This number makes it all the way into nextchar_slow(), where -1 is used as an
actual file descriptor when calling read().
Check for the -1 before calling read() if the buffer is empty.
(By the way, that read() there is probably missing some additional error
handling. An EINTR at the right moment...)
Signed-off-by: Vegard Nossum <vegardno@ifi.uio.no>
---
tokenize.c | 2 ++
1 files changed, 2 insertions(+), 0 deletions(-)
diff --git a/tokenize.c b/tokenize.c
index e72c56e..d154882 100644
--- a/tokenize.c
+++ b/tokenize.c
@@ -213,6 +213,8 @@ restart:
repeat:
if (offset >= size) {
+ if (stream->fd < 0)
+ goto got_eof;
size = read(stream->fd, stream->buffer, BUFSIZE);
if (size <= 0)
goto got_eof;
--
1.5.4.1
reply other threads:[~2008-05-25 7:52 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=20080525075157.GA3681@damson.getinternet.no \
--to=vegard.nossum@gmail.com \
--cc=linux-sparse@vger.kernel.org \
/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).