xen-devel.lists.xenproject.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] xenconsole: merge pty access check into when it is opened
@ 2013-11-30  3:42 Matthew Daley
  2013-12-01 11:41 ` Andrew Cooper
  0 siblings, 1 reply; 13+ messages in thread
From: Matthew Daley @ 2013-11-30  3:42 UTC (permalink / raw)
  To: xen-devel; +Cc: Matthew Daley, Ian Jackson, Ian Campbell, Stefano Stabellini

This stops pty_path from being leaked, and removes the toctou race,
FWIW.

Not sure why it's a separate check to begin with...

Coverity-ID: 1056047
Signed-off-by: Matthew Daley <mattd@bugfuzz.com>
---
 tools/console/client/main.c |   10 +++++-----
 1 file changed, 5 insertions(+), 5 deletions(-)

diff --git a/tools/console/client/main.c b/tools/console/client/main.c
index 38c856a..c32d3eb 100644
--- a/tools/console/client/main.c
+++ b/tools/console/client/main.c
@@ -116,12 +116,12 @@ static int get_pty_fd(struct xs_handle *xs, char *path, int seconds)
 			 * disambiguate: just read the pty path */
 			pty_path = xs_read(xs, XBT_NULL, path, &len);
 			if (pty_path != NULL) {
-				if (access(pty_path, R_OK|W_OK) != 0)
-					continue;
 				pty_fd = open(pty_path, O_RDWR | O_NOCTTY);
-				if (pty_fd == -1) 
-					err(errno, "Could not open tty `%s'", 
-					    pty_path);
+				if (pty_fd == -1) {
+					if (errno != EACCES)
+						err(errno, "Could not open tty `%s'",
+							pty_path);
+				}
 				free(pty_path);
 			}
 		}
-- 
1.7.10.4

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

end of thread, other threads:[~2013-12-16 11:58 UTC | newest]

Thread overview: 13+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2013-11-30  3:42 [PATCH] xenconsole: merge pty access check into when it is opened Matthew Daley
2013-12-01 11:41 ` Andrew Cooper
2013-12-01 23:14   ` Matthew Daley
2013-12-01 23:29     ` Andrew Cooper
2013-12-02  2:41       ` [PATCH v2] " Matthew Daley
2013-12-02 10:30         ` Andrew Cooper
2013-12-13  5:59         ` Matthew Daley
2013-12-02 11:51       ` [PATCH] " Ian Jackson
2013-12-02 11:53         ` Andrew Cooper
2013-12-13 17:01     ` [PATCH] xenconsole: merge pty access check into when it is opened [and 1 more messages] Ian Jackson
2013-12-13 22:54       ` Matthew Daley
2013-12-14  1:04       ` [PATCH v3] xenconsole: adjust pty opening error checking and handling Matthew Daley
2013-12-16 11:58         ` Ian Jackson

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).