mirror of
https://github.com/samba-team/samba.git
synced 2025-01-26 10:04:02 +03:00
Fix bug #5990 - strict allocate should be checked before ftruncate
reported by and based on a patch by Yasuma Takeda <yasuma@osstech.co.jp>. Jeremy.
This commit is contained in:
parent
45db33e732
commit
5184baa959
@ -740,6 +740,20 @@ static int strict_allocate_ftruncate(vfs_handle_struct *handle, files_struct *fs
|
||||
if (st.st_size > len)
|
||||
return sys_ftruncate(fsp->fh->fd, len);
|
||||
|
||||
/* available disk space is enough or not? */
|
||||
if (lp_strict_allocate(SNUM(fsp->conn))){
|
||||
uint64_t space_avail;
|
||||
uint64_t bsize,dfree,dsize;
|
||||
|
||||
space_avail = get_dfree_info(conn,fsp->fsp_name,false,&bsize,&dfree,&dsize);
|
||||
/* space_avail is 1k blocks */
|
||||
if (space_avail == (SMB_BIG_UINT)-1 ||
|
||||
((SMB_BIG_UINT)space_to_write/1024 > space_avail) ) {
|
||||
errno = ENOSPC;
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
|
||||
/* Write out the real space on disk. */
|
||||
if (SMB_VFS_LSEEK(fsp, st.st_size, SEEK_SET) != st.st_size)
|
||||
return -1;
|
||||
|
Loading…
x
Reference in New Issue
Block a user