aboutsummaryrefslogtreecommitdiff
path: root/src/cmd/9pserve.c
diff options
context:
space:
mode:
authorrsc <devnull@localhost>2006-05-04 19:10:11 +0000
committerrsc <devnull@localhost>2006-05-04 19:10:11 +0000
commitf2466297885cfdd3424033139d5aa14065791b84 (patch)
tree080cbbe11c46829a50ff58a0fd13ccc49cec68b8 /src/cmd/9pserve.c
parent1e22e8e41463896755b37d45bf76e14683e30f94 (diff)
downloadplan9port-f2466297885cfdd3424033139d5aa14065791b84.tar.gz
plan9port-f2466297885cfdd3424033139d5aa14065791b84.tar.bz2
plan9port-f2466297885cfdd3424033139d5aa14065791b84.zip
paranoia about extension
Diffstat (limited to 'src/cmd/9pserve.c')
-rw-r--r--src/cmd/9pserve.c7
1 files changed, 6 insertions, 1 deletions
diff --git a/src/cmd/9pserve.c b/src/cmd/9pserve.c
index 623b966a..3693164b 100644
--- a/src/cmd/9pserve.c
+++ b/src/cmd/9pserve.c
@@ -10,7 +10,8 @@ enum
{
STACK = 32768,
NHASH = 31,
- MAXMSG = 64 /* per connection */
+ MAXMSG = 64, /* per connection */
+ MAXMSGSIZE = 4*1024*1024
};
typedef struct Hash Hash;
@@ -231,6 +232,8 @@ mainproc(void *v)
if(n != nn)
sysfatal("error writing Tversion: %r\n");
n = read9pmsg(0, vbuf, sizeof vbuf);
+ if(n < 0)
+ sysfatal("read9pmsg failure"):
if(convM2S(vbuf, n, &f) != n)
sysfatal("convM2S failure");
if(f.msize < msize)
@@ -1220,6 +1223,8 @@ read9ppkt(Ioproc *io, int fd)
if(n != 4)
return nil;
n = GBIT32(buf);
+ if(n > MAXMSGSIZE)
+ return nil;
pkt = emalloc(n);
PBIT32(pkt, n);
nn = ioreadn(io, fd, pkt+4, n-4);