tdb: Do early RDONLY error check for tdb_delete
authorVolker Lendecke <vl@samba.org>
Thu, 25 Oct 2018 13:59:48 +0000 (15:59 +0200)
committerJeremy Allison <jra@samba.org>
Mon, 29 Oct 2018 22:36:25 +0000 (23:36 +0100)
Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
lib/tdb/common/tdb.c

index 4e433c89e1e36cffcc05b28e5622bb5ae50f6987..2a6d8977002168d58ae35026bd711f68a85548a6 100644 (file)
@@ -463,6 +463,11 @@ static int tdb_delete_hash(struct tdb_context *tdb, TDB_DATA key, uint32_t hash)
        struct tdb_record rec;
        int ret;
 
+       if (tdb->read_only || tdb->traverse_read) {
+               tdb->ecode = TDB_ERR_RDONLY;
+               return -1;
+       }
+
        rec_ptr = tdb_find_lock_hash(tdb, key, hash, F_WRLCK, &rec);
        if (rec_ptr == 0) {
                return -1;