diff options
author | cinap_lenrek <cinap_lenrek@felloff.net> | 2015-10-05 04:31:31 +0200 |
---|---|---|
committer | cinap_lenrek <cinap_lenrek@felloff.net> | 2015-10-05 04:31:31 +0200 |
commit | 0e09795831f37b86206e4dc9b3a0ac8bcd90401e (patch) | |
tree | 22e593360937f5d58497f3aa46ee3791520ac767 /sys/src/cmd/dossrv/dosfs.c | |
parent | ec518776982d6d1173683a1108e7537fc329ed43 (diff) |
dossrv: handle file offsets > 2^31
maximum file size is 4GB-1 as the file length is stored in
a 32 bit long. make sure it doesnt overflow on write or
or truncate. interpret the file length as unsigned. pass
vlong to readfile()/writefile()/truncfile() so we can
handle overflows and not just ignore the upper bits.
Diffstat (limited to 'sys/src/cmd/dossrv/dosfs.c')
-rw-r--r-- | sys/src/cmd/dossrv/dosfs.c | 24 |
1 files changed, 9 insertions, 15 deletions
diff --git a/sys/src/cmd/dossrv/dosfs.c b/sys/src/cmd/dossrv/dosfs.c index eff5e2a8f..783e66d21 100644 --- a/sys/src/cmd/dossrv/dosfs.c +++ b/sys/src/cmd/dossrv/dosfs.c @@ -305,7 +305,7 @@ mk8dot3name(Xfile *f, Dosptr *ndp, char *name, char *sname) * fill in a directory entry for a new file */ static int -mkdentry(Xfs *xf, Dosptr *ndp, char *name, char *sname, int longtype, int nattr, long start, long length) +mkdentry(Xfs *xf, Dosptr *ndp, char *name, char *sname, int longtype, int nattr, long start, ulong length) { Dosdir *nd; @@ -333,10 +333,7 @@ mkdentry(Xfs *xf, Dosptr *ndp, char *name, char *sname, int longtype, int nattr, PSHORT(nd->ctime, GSHORT(nd->time)); nd->ctimetenth = 0; putstart(xf, nd, start); - nd->length[0] = length; - nd->length[1] = length>>8; - nd->length[2] = length>>16; - nd->length[3] = length>>24; + PLONG(nd->length, length); ndp->p->flags |= BMOD; @@ -506,16 +503,13 @@ rread(void) if (!(f=xfile(req->fid, Asis)) || !(f->flags&Oread)) goto error; if(req->count > sizeof repdata) - req->count = sizeof repdata; - if(f->qid.type & QTDIR){ - if(getfile(f) < 0) - goto error; + req->count = sizeof repdata; + if(getfile(f) < 0) + goto error; + if(f->qid.type & QTDIR) r = readdir(f, repdata, req->offset, req->count); - }else{ - if(getfile(f) < 0) - goto error; + else r = readfile(f, repdata, req->offset, req->count); - } putfile(f); if(r < 0){ error: @@ -711,8 +705,8 @@ rwstat(void) Iosect *parp; Dosdir *pard, *d, od; char sname[13]; - ulong oaddr, ooffset; - long start, length; + ulong oaddr, ooffset, length; + long start; int i, longtype, changes, attr; f = xfile(req->fid, Asis); |