From 27d53256e4d2f3eab78aeb35eaa432d3d65895fc Mon Sep 17 00:00:00 2001 From: David van Moolenbroek Date: Mon, 8 Mar 2010 22:05:27 +0000 Subject: [PATCH] VFS fixes: - do not use uninitialized req_breadwrite results upon failure - improve ".." ELEAVEMOUNT correctness check --- servers/vfs/path.c | 3 ++- servers/vfs/read.c | 6 ++++-- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/servers/vfs/path.c b/servers/vfs/path.c index d6a1f5580..05706f7b8 100644 --- a/servers/vfs/path.c +++ b/servers/vfs/path.c @@ -262,7 +262,8 @@ node_details_t *node; * to the parent FS. That is, when we climb up the tree, we * must've encountered ".." in the path, and that is exactly * what we're going to feed to the parent */ - if(strncmp(user_fullpath, "..", 2) != 0) { + if(strncmp(user_fullpath, "..", 2) != 0 || + (user_fullpath[2] != '\0' && user_fullpath[2] != '/')) { printf("VFS: bogus path: %s\n", user_fullpath); return(ENOENT); } diff --git a/servers/vfs/read.c b/servers/vfs/read.c index fb82dcd62..819805a3d 100644 --- a/servers/vfs/read.c +++ b/servers/vfs/read.c @@ -105,8 +105,10 @@ int rw_flag; /* READING or WRITING */ } else if (block_spec) { /* Block special files. */ r = req_breadwrite(vp->v_bfs_e, who_e, vp->v_sdev, position, m_in.nbytes, m_in.buffer, rw_flag, &res_pos, &res_cum_io); - position = res_pos; - cum_io += res_cum_io; + if (r == OK) { + position = res_pos; + cum_io += res_cum_io; + } } else { /* Regular files */ if (rw_flag == WRITING && block_spec == 0) { /* Check for O_APPEND flag. */ -- 2.44.0