summaryrefslogtreecommitdiff
path: root/source3/lib
diff options
context:
space:
mode:
Diffstat (limited to 'source3/lib')
-rw-r--r--source3/lib/dbwrap/dbwrap.h3
-rw-r--r--source3/lib/dbwrap/dbwrap_util.c16
-rw-r--r--source3/lib/sharesec.c14
3 files changed, 23 insertions, 10 deletions
diff --git a/source3/lib/dbwrap/dbwrap.h b/source3/lib/dbwrap/dbwrap.h
index 13565f8b33..a549c84d8e 100644
--- a/source3/lib/dbwrap/dbwrap.h
+++ b/source3/lib/dbwrap/dbwrap.h
@@ -70,7 +70,8 @@ NTSTATUS dbwrap_store_bystring(struct db_context *db, const char *key,
NTSTATUS dbwrap_fetch_bystring(struct db_context *db, TALLOC_CTX *mem_ctx,
const char *key, TDB_DATA *value);
-int32_t dbwrap_fetch_int32(struct db_context *db, const char *keystr);
+NTSTATUS dbwrap_fetch_int32(struct db_context *db, const char *keystr,
+ int32_t *result);
int dbwrap_store_int32(struct db_context *db, const char *keystr, int32_t v);
bool dbwrap_fetch_uint32(struct db_context *db, const char *keystr,
uint32_t *val);
diff --git a/source3/lib/dbwrap/dbwrap_util.c b/source3/lib/dbwrap/dbwrap_util.c
index 59985479af..5c3940e97b 100644
--- a/source3/lib/dbwrap/dbwrap_util.c
+++ b/source3/lib/dbwrap/dbwrap_util.c
@@ -26,25 +26,29 @@
#include "dbwrap.h"
#include "util_tdb.h"
-int32_t dbwrap_fetch_int32(struct db_context *db, const char *keystr)
+NTSTATUS dbwrap_fetch_int32(struct db_context *db, const char *keystr,
+ int32_t *result)
{
TDB_DATA dbuf;
- int32 ret;
NTSTATUS status;
+ if (result == NULL) {
+ return NT_STATUS_INVALID_PARAMETER;
+ }
+
status = dbwrap_fetch_bystring(db, NULL, keystr, &dbuf);
if (!NT_STATUS_IS_OK(status)) {
- return -1;
+ return status;
}
if ((dbuf.dptr == NULL) || (dbuf.dsize != sizeof(int32_t))) {
TALLOC_FREE(dbuf.dptr);
- return -1;
+ return NT_STATUS_NOT_FOUND;
}
- ret = IVAL(dbuf.dptr, 0);
+ *result = IVAL(dbuf.dptr, 0);
TALLOC_FREE(dbuf.dptr);
- return ret;
+ return NT_STATUS_OK;
}
int dbwrap_store_int32(struct db_context *db, const char *keystr, int32_t v)
diff --git a/source3/lib/sharesec.c b/source3/lib/sharesec.c
index 53187c0435..9b3d5607fd 100644
--- a/source3/lib/sharesec.c
+++ b/source3/lib/sharesec.c
@@ -139,7 +139,7 @@ static int upgrade_v2_to_v3(struct db_record *rec, void *priv)
bool share_info_db_init(void)
{
const char *vstring = "INFO/version";
- int32 vers_id;
+ int32 vers_id = 0;
bool upgrade_ok = true;
NTSTATUS status;
@@ -155,7 +155,11 @@ bool share_info_db_init(void)
return False;
}
- vers_id = dbwrap_fetch_int32(share_db, vstring);
+ status = dbwrap_fetch_int32(share_db, vstring, &vers_id);
+ if (!NT_STATUS_IS_OK(status)) {
+ vers_id = 0;
+ }
+
if (vers_id == SHARE_DATABASE_VERSION_V3) {
return true;
}
@@ -166,7 +170,11 @@ bool share_info_db_init(void)
return false;
}
- vers_id = dbwrap_fetch_int32(share_db, vstring);
+ status = dbwrap_fetch_int32(share_db, vstring, &vers_id);
+ if (!NT_STATUS_IS_OK(status)) {
+ vers_id = 0;
+ }
+
if (vers_id == SHARE_DATABASE_VERSION_V3) {
/*
* Race condition