return NT_STATUS_OK;
}
-/**
- * The only way that the fsp->fsp_name field should ever be set.
- */
-NTSTATUS fsp_set_smb_fname(struct files_struct *fsp,
- const struct smb_filename *smb_fname_in)
+static NTSTATUS fsp_attach_smb_fname(struct files_struct *fsp,
+ struct smb_filename **_smb_fname)
{
- struct smb_filename *smb_fname_old = fsp->fsp_name;
- struct smb_filename *smb_fname_new = NULL;
+ struct smb_filename *smb_fname_new = *_smb_fname;
const char *name_str = NULL;
uint32_t name_hash = 0;
NTSTATUS status;
- smb_fname_new = cp_smb_filename(fsp, smb_fname_in);
- if (smb_fname_new == NULL) {
- return NT_STATUS_NO_MEMORY;
- }
-
name_str = smb_fname_str_dbg(smb_fname_new);
if (name_str == NULL) {
- TALLOC_FREE(smb_fname_new);
return NT_STATUS_NO_MEMORY;
}
name_str,
&name_hash);
if (!NT_STATUS_IS_OK(status)) {
- TALLOC_FREE(smb_fname_new);
return status;
}
&smb_fname_new->fsp_link,
&smb_fname_new->fsp);
if (!NT_STATUS_IS_OK(status)) {
- TALLOC_FREE(smb_fname_new);
return status;
}
fsp->name_hash = name_hash;
fsp->fsp_name = smb_fname_new;
+ *_smb_fname = NULL;
+ return NT_STATUS_OK;
+}
+
+/**
+ * The only way that the fsp->fsp_name field should ever be set.
+ */
+NTSTATUS fsp_set_smb_fname(struct files_struct *fsp,
+ const struct smb_filename *smb_fname_in)
+{
+ struct smb_filename *smb_fname_old = fsp->fsp_name;
+ struct smb_filename *smb_fname_new = NULL;
+ NTSTATUS status;
+
+ smb_fname_new = cp_smb_filename(fsp, smb_fname_in);
+ if (smb_fname_new == NULL) {
+ return NT_STATUS_NO_MEMORY;
+ }
+
+ status = fsp_attach_smb_fname(fsp, &smb_fname_new);
+ if (!NT_STATUS_IS_OK(status)) {
+ TALLOC_FREE(smb_fname_new);
+ return status;
+ }
if (smb_fname_old != NULL) {
smb_fname_fsp_unlink(smb_fname_old);