smbd: Convert set_share_mode to return bool for success
authorVolker Lendecke <vl@samba.org>
Sat, 14 Sep 2013 11:49:14 +0000 (13:49 +0200)
committerJeremy Allison <jra@samba.org>
Tue, 8 Oct 2013 21:42:25 +0000 (14:42 -0700)
Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
source3/locking/locking.c
source3/locking/proto.h
source3/smbd/open.c

index f584e0cf6526465d30da4c1e94a9a982230a4efa..055d0f8245c069c93de3bc3d2600a135d57048f9 100644 (file)
@@ -734,12 +734,12 @@ static bool add_share_mode_entry(struct share_mode_data *d,
        return true;
 }
 
-void set_share_mode(struct share_mode_lock *lck, files_struct *fsp,
+bool set_share_mode(struct share_mode_lock *lck, files_struct *fsp,
                    uid_t uid, uint64_t mid, uint16 op_type)
 {
        struct share_mode_entry entry;
        fill_share_mode_entry(&entry, fsp, uid, mid, op_type);
-       add_share_mode_entry(lck->data, &entry);
+       return add_share_mode_entry(lck->data, &entry);
 }
 
 /*******************************************************************
index dde0be431d1611050efe1e4c043adf74da428a51..02e2bf530742088614f1013d127affe849761395 100644 (file)
@@ -171,7 +171,7 @@ void get_file_infos(struct file_id id,
                    struct timespec *write_time);
 bool is_valid_share_mode_entry(const struct share_mode_entry *e);
 bool share_mode_stale_pid(struct share_mode_data *d, uint32_t idx);
-void set_share_mode(struct share_mode_lock *lck, files_struct *fsp,
+bool set_share_mode(struct share_mode_lock *lck, files_struct *fsp,
                    uid_t uid, uint64_t mid, uint16 op_type);
 bool del_share_mode(struct share_mode_lock *lck, files_struct *fsp);
 bool mark_share_mode_disconnected(struct share_mode_lock *lck,
index 858d2befc2e44bb48c2cc221862552e577c40eda..55f2fb2164758d12134b0e5529e546df83789621 100644 (file)
@@ -2681,9 +2681,13 @@ static NTSTATUS open_file_ntcreate(connection_struct *conn,
                fsp->oplock_type = NO_OPLOCK;
        }
 
-       set_share_mode(lck, fsp, get_current_uid(conn),
-                       req ? req->mid : 0,
-                      fsp->oplock_type);
+       if (!set_share_mode(lck, fsp, get_current_uid(conn),
+                           req ? req->mid : 0,
+                           fsp->oplock_type)) {
+               TALLOC_FREE(lck);
+               fd_close(fsp);
+               return NT_STATUS_NO_MEMORY;
+       }
 
        /* Handle strange delete on close create semantics. */
        if (create_options & FILE_DELETE_ON_CLOSE) {
@@ -3173,8 +3177,13 @@ static NTSTATUS open_directory(connection_struct *conn,
                return status;
        }
 
-       set_share_mode(lck, fsp, get_current_uid(conn),
-                       req ? req->mid : 0, NO_OPLOCK);
+       if (!set_share_mode(lck, fsp, get_current_uid(conn),
+                           req ? req->mid : 0, NO_OPLOCK)) {
+               TALLOC_FREE(lck);
+               fd_close(fsp);
+               file_free(req, fsp);
+               return NT_STATUS_NO_MEMORY;
+       }
 
        /* For directories the delete on close bit at open time seems
           always to be honored on close... See test 19 in Samba4 BASE-DELETE. */