summaryrefslogtreecommitdiff
path: root/sys/src/cmd/ratfs
diff options
context:
space:
mode:
authorkvik <kvik@a-b.xyz>2020-08-01 15:27:28 +0200
committerkvik <kvik@a-b.xyz>2020-08-01 15:27:28 +0200
commite5894dcceaedeaf7d4f5537dd306170b1b6d4814 (patch)
tree1cc00acf23373f15f69218ba1ccbb372a9cb3899 /sys/src/cmd/ratfs
parent88a468f205af2bfdaa015a5bc33424ae0d56de08 (diff)
pre-lib9p servers: fix incorrect Tversion handling
version(5) says: If the server does not understand the client's version string, it should respond with an Rversion message (not Rerror) with the version string the 7 characters ``unknown''. Pre-lib9p file servers -- all except cwfs(4) -- do return Rerror. lib9p(2) follows the above spec, although ignoring the next part concerning comparison after period-stripping. It assumes an Fcall.version starting with "9P" is correctly formed and returns the only supported version of the protocol, which seems alright. This patch brings pre-lib9p servers in accordance with the spec.
Diffstat (limited to 'sys/src/cmd/ratfs')
-rw-r--r--sys/src/cmd/ratfs/proto.c9
1 files changed, 8 insertions, 1 deletions
diff --git a/sys/src/cmd/ratfs/proto.c b/sys/src/cmd/ratfs/proto.c
index 8ca76ef40..dc6bbc707 100644
--- a/sys/src/cmd/ratfs/proto.c
+++ b/sys/src/cmd/ratfs/proto.c
@@ -131,9 +131,16 @@ newfid(int fid)
static void
rversion(Fcall *f)
{
- f->version = "9P2000";
+ if(f->msize < 256){
+ reply(f, "version: message size too small");
+ return;
+ }
if(f->msize > MAXRPC)
f->msize = MAXRPC;
+ if(strncmp(f->version, "9P", 2) != 0)
+ f->version = "unknown";
+ else
+ f->version = "9P2000";
reply(f, 0);
}