* [PATCH] Fix use of invalid file descriptor
@ 2008-05-25 7:51 Vegard Nossum
0 siblings, 0 replies; only message in thread
From: Vegard Nossum @ 2008-05-25 7:51 UTC (permalink / raw)
To: linux-sparse
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
^ permalink raw reply related [flat|nested] only message in thread
only message in thread, other threads:[~2008-05-25 7:52 UTC | newest]
Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2008-05-25 7:51 [PATCH] Fix use of invalid file descriptor Vegard Nossum
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).