diff options
author | Tim Prouty <tprouty@samba.org> | 2009-07-10 10:38:56 -0700 |
---|---|---|
committer | Tim Prouty <tprouty@samba.org> | 2009-07-20 17:26:56 -0700 |
commit | 12a5db45e2814b6992210d8f30908ab3e8b6bc65 (patch) | |
tree | 0c435a55578eb253aea3d62c3dec7c9c1ba8fd3e | |
parent | 04c3dfde0f0bc12daf0922a0fe578e3bde587fc8 (diff) | |
download | samba-12a5db45e2814b6992210d8f30908ab3e8b6bc65.tar.gz samba-12a5db45e2814b6992210d8f30908ab3e8b6bc65.tar.xz samba-12a5db45e2814b6992210d8f30908ab3e8b6bc65.zip |
s3: Change file_structs to be allocated with talloc instead of malloc
-rw-r--r-- | source3/smbd/files.c | 25 |
1 files changed, 15 insertions, 10 deletions
diff --git a/source3/smbd/files.c b/source3/smbd/files.c index 0e6dd7e457e..48d2288468d 100644 --- a/source3/smbd/files.c +++ b/source3/smbd/files.c @@ -65,21 +65,26 @@ NTSTATUS file_new(struct smb_request *req, connection_struct *conn, return NT_STATUS_TOO_MANY_OPENED_FILES; } - fsp = SMB_MALLOC_P(files_struct); + /* + * Make a child of the connection_struct as an fsp can't exist + * indepenedent of a connection. + */ + fsp = talloc_zero(conn, struct files_struct); if (!fsp) { return NT_STATUS_NO_MEMORY; } - ZERO_STRUCTP(fsp); - - fsp->fh = SMB_MALLOC_P(struct fd_handle); + /* + * This can't be a child of fsp because the file_handle can be ref'd + * when doing a dos/fcb open, which will then share the file_handle + * across multiple fsps. + */ + fsp->fh = talloc_zero(conn, struct fd_handle); if (!fsp->fh) { - SAFE_FREE(fsp); + TALLOC_FREE(fsp); return NT_STATUS_NO_MEMORY; } - ZERO_STRUCTP(fsp->fh); - fsp->fh->ref_count = 1; fsp->fh->fd = -1; @@ -449,7 +454,7 @@ void file_free(struct smb_request *req, files_struct *fsp) TALLOC_FREE(fsp->fake_file_handle); if (fsp->fh->ref_count == 1) { - SAFE_FREE(fsp->fh); + TALLOC_FREE(fsp->fh); } else { fsp->fh->ref_count--; } @@ -495,7 +500,7 @@ void file_free(struct smb_request *req, files_struct *fsp) information */ ZERO_STRUCTP(fsp); - SAFE_FREE(fsp); + TALLOC_FREE(fsp); } /**************************************************************************** @@ -545,7 +550,7 @@ void dup_file_fsp(struct smb_request *req, files_struct *from, uint32 access_mask, uint32 share_access, uint32 create_options, files_struct *to) { - SAFE_FREE(to->fh); + TALLOC_FREE(to->fh); to->fh = from->fh; to->fh->ref_count++; |