summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--source3/lib/sharesec.c4
-rw-r--r--source3/printing/nt_printing.c6
-rw-r--r--source3/rpc_parse/parse_prs.c24
3 files changed, 21 insertions, 13 deletions
diff --git a/source3/lib/sharesec.c b/source3/lib/sharesec.c
index 7a6a425559..c4704dfc12 100644
--- a/source3/lib/sharesec.c
+++ b/source3/lib/sharesec.c
@@ -125,7 +125,7 @@ SEC_DESC *get_share_security( TALLOC_CTX *ctx, const char *servicename,
slprintf(key, sizeof(key)-1, "SECDESC/%s", servicename);
- if (tdb_prs_fetch(share_tdb, key, &ps, ctx)!=0 ||
+ if (tdb_prs_fetch_bystring(share_tdb, key, &ps, ctx)!=0 ||
!sec_io_desc("get_share_security", &psd, &ps, 1)) {
DEBUG(4, ("get_share_security: using default secdesc for %s\n",
@@ -167,7 +167,7 @@ BOOL set_share_security(const char *share_name, SEC_DESC *psd)
slprintf(key, sizeof(key)-1, "SECDESC/%s", share_name);
- if (tdb_prs_store(share_tdb, key, &ps)==0) {
+ if (tdb_prs_store_bystring(share_tdb, key, &ps)==0) {
ret = True;
DEBUG(5,("set_share_security: stored secdesc for %s\n", share_name ));
} else {
diff --git a/source3/printing/nt_printing.c b/source3/printing/nt_printing.c
index 78ba986214..967ea883a9 100644
--- a/source3/printing/nt_printing.c
+++ b/source3/printing/nt_printing.c
@@ -5159,7 +5159,7 @@ WERROR nt_printing_setsec(const char *sharename, SEC_DESC_BUF *secdesc_ctr)
key = make_printers_secdesc_tdbkey( sharename );
- if (tdb_prs_store(tdb_printers, key, &ps)==0) {
+ if (tdb_prs_store_bystring(tdb_printers, key, &ps)==0) {
status = WERR_OK;
} else {
DEBUG(1,("Failed to store secdesc for %s\n", sharename));
@@ -5280,7 +5280,7 @@ BOOL nt_printing_getsec(TALLOC_CTX *ctx, const char *sharename, SEC_DESC_BUF **s
key = make_printers_secdesc_tdbkey( sharename );
- if (tdb_prs_fetch(tdb_printers, key, &ps, ctx)!=0 ||
+ if (tdb_prs_fetch_bystring(tdb_printers, key, &ps, ctx)!=0 ||
!sec_io_desc_buf("nt_printing_getsec", secdesc_ctr, &ps, 1)) {
prs_mem_free(&ps);
@@ -5297,7 +5297,7 @@ BOOL nt_printing_getsec(TALLOC_CTX *ctx, const char *sharename, SEC_DESC_BUF **s
sizeof(SEC_DESC_BUF), ctx, MARSHALL);
if (sec_io_desc_buf("nt_printing_getsec", secdesc_ctr, &ps, 1)) {
- tdb_prs_store(tdb_printers, key, &ps);
+ tdb_prs_store_bystring(tdb_printers, key, &ps);
}
prs_mem_free(&ps);
diff --git a/source3/rpc_parse/parse_prs.c b/source3/rpc_parse/parse_prs.c
index 54bbe3adf6..ca46807932 100644
--- a/source3/rpc_parse/parse_prs.c
+++ b/source3/rpc_parse/parse_prs.c
@@ -1454,22 +1454,24 @@ BOOL prs_uint32_post(const char *name, prs_struct *ps, int depth, uint32 *data32
}
/* useful function to store a structure in rpc wire format */
-int tdb_prs_store(TDB_CONTEXT *tdb, char *keystr, prs_struct *ps)
+int tdb_prs_store(TDB_CONTEXT *tdb, TDB_DATA kbuf, prs_struct *ps)
{
- TDB_DATA kbuf, dbuf;
- kbuf.dptr = keystr;
- kbuf.dsize = strlen(keystr)+1;
+ TDB_DATA dbuf;
dbuf.dptr = ps->data_p;
dbuf.dsize = prs_offset(ps);
return tdb_trans_store(tdb, kbuf, dbuf, TDB_REPLACE);
}
+int tdb_prs_store_bystring(TDB_CONTEXT *tdb, char *keystr, prs_struct *ps)
+{
+ TDB_DATA kbuf = string_term_tdb_data(keystr);
+ return tdb_prs_store(tdb, kbuf, ps);
+}
+
/* useful function to fetch a structure into rpc wire format */
-int tdb_prs_fetch(TDB_CONTEXT *tdb, char *keystr, prs_struct *ps, TALLOC_CTX *mem_ctx)
+int tdb_prs_fetch(TDB_CONTEXT *tdb, TDB_DATA kbuf, prs_struct *ps, TALLOC_CTX *mem_ctx)
{
- TDB_DATA kbuf, dbuf;
- kbuf.dptr = keystr;
- kbuf.dsize = strlen(keystr)+1;
+ TDB_DATA dbuf;
prs_init(ps, 0, mem_ctx, UNMARSHALL);
@@ -1482,6 +1484,12 @@ int tdb_prs_fetch(TDB_CONTEXT *tdb, char *keystr, prs_struct *ps, TALLOC_CTX *me
return 0;
}
+int tdb_prs_fetch_bystring(TDB_CONTEXT *tdb, char *keystr, prs_struct *ps, TALLOC_CTX *mem_ctx)
+{
+ TDB_DATA kbuf = string_term_tdb_data(keystr);
+ return tdb_prs_fetch(tdb, kbuf, ps, mem_ctx);
+}
+
/*******************************************************************
hash a stream.
********************************************************************/