lib: Remove unused tdb_trans_* functions
[samba.git] / source3 / lib / util_tdb.c
index 035daf8b7b77064a52951a94c2c3b0fcfe61b651..cbcca4df09fc05e2ce54b0ba68f3ba12ef35ace3 100644 (file)
 #undef calloc
 #undef strdup
 
-/* these are little tdb utility functions that are meant to make
-   dealing with a tdb database a little less cumbersome in Samba */
-
-int tdb_trans_store_bystring(TDB_CONTEXT *tdb, const char *keystr,
-                            TDB_DATA data, int flags)
-{
-       TDB_DATA key = string_term_tdb_data(keystr);
-
-       return tdb_trans_store(tdb, key, data, flags);
-}
-
 /****************************************************************************
  Useful pair of routines for packing/unpacking data consisting of
  integers and strings.
@@ -227,6 +216,9 @@ int tdb_unpack(const uint8_t *buf, int in_bufsize, const char *fmt, ...)
                                break;
                        }
                        len += *i;
+                       if (len < *i) {
+                               goto no_space;
+                       }
                        if (bufsize < len)
                                goto no_space;
                        *b = (char *)SMB_MALLOC(*i);
@@ -316,61 +308,6 @@ TDB_CONTEXT *tdb_open_log(const char *name, int hash_size, int tdb_flags,
        return tdb;
 }
 
-/****************************************************************************
- tdb_store, wrapped in a transaction. This way we make sure that a process
- that dies within writing does not leave a corrupt tdb behind.
-****************************************************************************/
-
-int tdb_trans_store(struct tdb_context *tdb, TDB_DATA key, TDB_DATA dbuf,
-                   int flag)
-{
-       int res;
-
-       if ((res = tdb_transaction_start(tdb)) != 0) {
-               DEBUG(5, ("tdb_transaction_start failed\n"));
-               return res;
-       }
-
-       if ((res = tdb_store(tdb, key, dbuf, flag)) != 0) {
-               DEBUG(10, ("tdb_store failed\n"));
-               tdb_transaction_cancel(tdb);
-               return res;
-       }
-
-       if ((res = tdb_transaction_commit(tdb)) != 0) {
-               DEBUG(5, ("tdb_transaction_commit failed\n"));
-       }
-
-       return res;
-}
-
-/****************************************************************************
- tdb_delete, wrapped in a transaction. This way we make sure that a process
- that dies within deleting does not leave a corrupt tdb behind.
-****************************************************************************/
-
-int tdb_trans_delete(struct tdb_context *tdb, TDB_DATA key)
-{
-       int res;
-
-       if ((res = tdb_transaction_start(tdb)) != 0) {
-               DEBUG(5, ("tdb_transaction_start failed\n"));
-               return res;
-       }
-
-       if ((res = tdb_delete(tdb, key)) != 0) {
-               DEBUG(10, ("tdb_delete failed\n"));
-               tdb_transaction_cancel(tdb);
-               return res;
-       }
-
-       if ((res = tdb_transaction_commit(tdb)) != 0) {
-               DEBUG(5, ("tdb_transaction_commit failed\n"));
-       }
-
-       return res;
-}
-
 int tdb_data_cmp(TDB_DATA t1, TDB_DATA t2)
 {
        int ret;