core/cfs: Disallow seeking past the end of a file if it is not writable
This commit is contained in:
parent
0e9234dce6
commit
19550f9f7f
|
@ -1055,7 +1055,12 @@ cfs_seek(int fd, cfs_offset_t offset, int whence)
|
||||||
}
|
}
|
||||||
|
|
||||||
if(fdp->file->end < new_offset) {
|
if(fdp->file->end < new_offset) {
|
||||||
fdp->file->end = new_offset;
|
if(FD_WRITABLE(fd)) {
|
||||||
|
fdp->file->end = new_offset;
|
||||||
|
} else {
|
||||||
|
/* Disallow seeking past the end of the file for read only FDs */
|
||||||
|
return (cfs_offset_t)-1;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return fdp->offset = new_offset;
|
return fdp->offset = new_offset;
|
||||||
|
|
Loading…
Reference in a new issue