This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
- the Free Software Foundation; either version 2 of the License, or
+ the Free Software Foundation; either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
- along with this program; if not, write to the Free Software
- Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+ along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
/* This module implements a tdb based byte range locking service,
}
/* Never get here. */
- smb_panic("brlock_posix_split_merge\n");
+ smb_panic("brlock_posix_split_merge");
/* Notreached. */
- abort();
+
/* Keep some compilers happy. */
return 0;
}
if (br_lck->num_locks) {
locks_copy = (struct lock_struct *)TALLOC_MEMDUP(br_lck, locks, br_lck->num_locks * sizeof(struct lock_struct));
if (!locks_copy) {
- smb_panic("brl_close_fnum: talloc fail.\n");
+ smb_panic("brl_close_fnum: talloc failed");
}
} else {
locks_copy = NULL;
if (!NT_STATUS_IS_OK(status)) {
DEBUG(0, ("delete_rec returned %s\n",
nt_errstr(status)));
- smb_panic("Could not delete byte range lock entry\n");
+ smb_panic("Could not delete byte range lock entry");
}
} else {
TDB_DATA data;
TDB_REPLACE);
if (!NT_STATUS_IS_OK(status)) {
DEBUG(0, ("store returned %s\n", nt_errstr(status)));
- smb_panic("Could not store byte range mode entry\n");
+ smb_panic("Could not store byte range mode entry");
}
}
br_lck->num_locks = data.dsize / sizeof(struct lock_struct);
br_lck->lock_data = SMB_MALLOC_ARRAY(struct lock_struct, br_lck->num_locks);
+ if ((br_lck->num_locks != 0) && (br_lck->lock_data == NULL)) {
+ DEBUG(0, ("malloc failed\n"));
+ TALLOC_FREE(br_lck);
+ return NULL;
+ }
+
memcpy(br_lck->lock_data, data.dptr, data.dsize);
if (!fsp->lockdb_clean) {
+ int orig_num_locks = br_lck->num_locks;
/* This is the first time we've accessed this. */
/* Go through and ensure all entries exist - remove any that don't. */
return NULL;
}
+ /* Ensure invalid locks are cleaned up in the destructor. */
+ if (orig_num_locks != br_lck->num_locks) {
+ br_lck->modified = True;
+ }
+
/* Mark the lockdb as "clean" as seen from this open file. */
fsp->lockdb_clean = True;
}