summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorcinap_lenrek <cinap_lenrek@felloff.net>2018-05-20 03:48:33 +0200
committercinap_lenrek <cinap_lenrek@felloff.net>2018-05-20 03:48:33 +0200
commit40f6e00b9c4b0f5bdca1cc7caf27af23a6b10786 (patch)
treeccaf896cfcf43fa8ad9994b94fdca9311e3754d7
parente684b2a3fbd7d077ba4dabbd7fb4c7d1ff09c30c (diff)
downloadplan9front-40f6e00b9c4b0f5bdca1cc7caf27af23a6b10786.tar.xz
ip/cifsd: limit response data count in TRANS2 for remotebuffersize, avoid empty filename for the root
-rw-r--r--sys/src/cmd/ip/cifsd/dir.c5
-rw-r--r--sys/src/cmd/ip/cifsd/smb.c7
2 files changed, 9 insertions, 3 deletions
diff --git a/sys/src/cmd/ip/cifsd/dir.c b/sys/src/cmd/ip/cifsd/dir.c
index 65707bcb8..7b6c013aa 100644
--- a/sys/src/cmd/ip/cifsd/dir.c
+++ b/sys/src/cmd/ip/cifsd/dir.c
@@ -65,8 +65,11 @@ xdirstat0(char **path, int (*namecmp)(char *, char *), char *err)
Dir *d, *t;
int n, i;
- if(d = dirstat(*path))
+ if(d = dirstat(*path)){
+ if(d->name[0] == 0)
+ d->name = "/";
return d;
+ }
if(!splitpath(*path, &base, &name))
return nil;
if((n = xdirread0(&base, namecmp, &t)) < 0)
diff --git a/sys/src/cmd/ip/cifsd/smb.c b/sys/src/cmd/ip/cifsd/smb.c
index 3dbf57b53..af2182097 100644
--- a/sys/src/cmd/ip/cifsd/smb.c
+++ b/sys/src/cmd/ip/cifsd/smb.c
@@ -1614,8 +1614,11 @@ unsup:
goto unsup;
}
if(57+((rsc+1)&~1)+((rpc+3)&~3)+((rdc+3)&~3) > remotebuffersize){
- logit("[%.4x] %s response doesnt fit in client buffer", t.cmd, t.name);
- goto unsup;
+ rdc = remotebuffersize-(57+((rsc+1)&~1)+((rpc+3)&~3)) & ~3;
+ if(rdc <= 0){
+ logit("[%.4x] %s response doesnt fit in client buffer", t.cmd, t.name);
+ goto unsup;
+ }
}
t.in.param.b = t.in.param.p = pa; t.in.param.e = pe;