ip/cifsd: limit response data count in TRANS2 for remotebuffersize, avoid empty filename for the root

This commit is contained in:
cinap_lenrek 2018-05-20 03:48:33 +02:00
parent e684b2a3fb
commit 40f6e00b9c
2 changed files with 9 additions and 3 deletions

View file

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

View file

@ -1614,9 +1614,12 @@ unsup:
goto unsup;
}
if(57+((rsc+1)&~1)+((rpc+3)&~3)+((rdc+3)&~3) > remotebuffersize){
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;
t.in.data.b = t.in.data.p = da; t.in.data.e = de;