cifsd: handle bogus MaxCount in read, wstat archive attribute

front
cinap_lenrek 2012-01-15 14:31:27 +01:00
parent 260fcc61c0
commit c11bed9f41
1 changed files with 18 additions and 8 deletions

View File

@ -427,11 +427,14 @@ badsmb:
r->respond(r, STATUS_INVALID_SMB); r->respond(r, STATUS_INVALID_SMB);
goto out; goto out;
} }
re = rb + mincount;
if(re > r->re)
goto badsmb;
if(maxcount > mincount){
re = rb + maxcount; re = rb + maxcount;
if(re > r->re) if(re > r->re)
re = r->re; re = r->re;
if((rb + mincount) > re) }
goto badsmb;
n = 0; n = 0;
rp = rb; rp = rb;
while(rp < re){ while(rp < re){
@ -868,13 +871,20 @@ smbsetinformation(Req *r, uchar *h, uchar *p, uchar *e)
nulldir(&nd); nulldir(&nd);
if(mtime) if(mtime)
nd.mtime = mtime-tzoff; nd.mtime = mtime-tzoff;
nd.mode = d->mode;
if(attr & ATTR_READONLY){ if(attr & ATTR_READONLY){
if(d->mode & 0222) if(nd.mode & 0222)
nd.mode = d->mode & ~0222; nd.mode &= ~0222;
} else { }else{
if((d->mode & 0222) == 0) if((nd.mode & 0222) == 0)
nd.mode = d->mode | 0222; nd.mode |= 0222;
} }
if(attr & ATTR_ARCHIVE)
nd.mode &= ~DMTMP;
else
nd.mode |= DMTMP;
if(nd.mode == d->mode)
nd.mode = ~0;
if(dirwstat(path, &nd) < 0){ if(dirwstat(path, &nd) < 0){
r->respond(r, smbmkerror()); r->respond(r, smbmkerror());
goto out; goto out;