[SCM] Samba Shared Repository - branch master updated - 9361c73c2f4ce9a2f9a7e5515a9272ddd14eb2ed

Günther Deschner gd at samba.org
Thu Jan 15 23:29:23 GMT 2009


The branch, master has been updated
       via  9361c73c2f4ce9a2f9a7e5515a9272ddd14eb2ed (commit)
       via  b9d9832cc35c9c221e9cee5d7d46a83bbeea75df (commit)
       via  c3ac9a2977e1e8c3ebbd448582e477f14a1f2ee0 (commit)
       via  87fec1450f1ae78d9aea58f55bd22dda3d1f362a (commit)
       via  64d8eb0cee161417c3c97f1dc8d5b67171084152 (commit)
       via  0d2c0da7d2ca836efb6fa5b99181103768b3f141 (commit)
       via  6dc18f2cab3cf028c189ce870059f46c15f5593a (commit)
       via  288c4691952a4688f05ae3a5cd137db346a2a276 (commit)
      from  6c5a1b037261c99f60a2d42c4b53ebbf85abd756 (commit)

http://gitweb.samba.org/?p=samba.git;a=shortlog;h=master


- Log -----------------------------------------------------------------
commit 9361c73c2f4ce9a2f9a7e5515a9272ddd14eb2ed
Author: Günther Deschner <gd at samba.org>
Date:   Fri Jan 16 00:25:57 2009 +0100

    winreg: fix winreg_EnumValue callers.
    
    Guenther

commit b9d9832cc35c9c221e9cee5d7d46a83bbeea75df
Author: Günther Deschner <gd at samba.org>
Date:   Thu Jan 15 23:24:52 2009 +0100

    s3: re-run make samba3-idl.
    
    Guenther

commit c3ac9a2977e1e8c3ebbd448582e477f14a1f2ee0
Author: Günther Deschner <gd at samba.org>
Date:   Thu Jan 15 23:23:08 2009 +0100

    winreg: fix winreg_EnumValue by re-adding winreg_ValNameBuf from 3.3/3.2.
    
    This fixes viewing samba registry with windows tools like regedit and eventviewer.
    
    Michael, Jelmer, please check.
    
    Guenther

commit 87fec1450f1ae78d9aea58f55bd22dda3d1f362a
Author: Günther Deschner <gd at samba.org>
Date:   Fri Jan 16 00:25:31 2009 +0100

    lib: add strlen_m_term_null from s3.
    
    Guenther

commit 64d8eb0cee161417c3c97f1dc8d5b67171084152
Author: Günther Deschner <gd at samba.org>
Date:   Thu Jan 15 15:33:20 2009 +0100

    s3-util: for convenience, provide format comments in tdb_unpack().
    
    Guenther

commit 0d2c0da7d2ca836efb6fa5b99181103768b3f141
Author: Günther Deschner <gd at samba.org>
Date:   Thu Jan 15 20:01:30 2009 +0100

    s3-eventlog: remove whitespace.
    
    Guenther

commit 6dc18f2cab3cf028c189ce870059f46c15f5593a
Author: Günther Deschner <gd at samba.org>
Date:   Wed Jan 14 18:09:25 2009 +0100

    s3-eventlog: some minor code cleanup in eventlog server.
    
    Guenther

commit 288c4691952a4688f05ae3a5cd137db346a2a276
Author: Günther Deschner <gd at samba.org>
Date:   Wed Jan 14 16:59:42 2009 +0100

    s4-smbtorture: fix RPC-EVENTLOG test.
    
    Guenther

-----------------------------------------------------------------------

Summary of changes:
 lib/util/charset/charset.h            |    1 +
 lib/util/charset/util_unistr.c        |   19 +++++++
 librpc/gen_ndr/cli_winreg.c           |    2 +-
 librpc/gen_ndr/cli_winreg.h           |    2 +-
 librpc/gen_ndr/ndr_winreg.c           |   89 +++++++++++++++++++++++++++++---
 librpc/gen_ndr/ndr_winreg.h           |    1 +
 librpc/gen_ndr/winreg.h               |   10 +++-
 librpc/idl/winreg.idl                 |   13 ++++-
 source3/lib/util_tdb.c                |   14 +++---
 source3/rpc_server/srv_eventlog_lib.c |   90 ++++++++++++++++----------------
 source3/rpc_server/srv_eventlog_nt.c  |   33 ++++--------
 source3/utils/net_rpc_registry.c      |    2 +-
 source4/lib/registry/rpc.c            |    2 +-
 source4/torture/rpc/eventlog.c        |    8 ++-
 source4/torture/rpc/winreg.c          |    2 +-
 15 files changed, 193 insertions(+), 95 deletions(-)


Changeset truncated at 500 lines:

diff --git a/lib/util/charset/charset.h b/lib/util/charset/charset.h
index b69bef2..f027beb 100644
--- a/lib/util/charset/charset.h
+++ b/lib/util/charset/charset.h
@@ -84,6 +84,7 @@ struct smb_iconv_convenience;
 
 char *strchr_m(const char *s, char c);
 size_t strlen_m_term(const char *s);
+size_t strlen_m_term_null(const char *s);
 size_t strlen_m(const char *s);
 char *alpha_strcpy(char *dest, const char *src, const char *other_safe_chars, size_t maxlength);
 void string_replace_m(char *s, char oldc, char newc);
diff --git a/lib/util/charset/util_unistr.c b/lib/util/charset/util_unistr.c
index 86a76f8..41b9c94 100644
--- a/lib/util/charset/util_unistr.c
+++ b/lib/util/charset/util_unistr.c
@@ -297,6 +297,25 @@ _PUBLIC_ size_t strlen_m_term(const char *s)
 	return strlen_m(s) + 1;
 }
 
+/*
+ * Weird helper routine for the winreg pipe: If nothing is around, return 0,
+ * if a string is there, include the terminator.
+ */
+
+_PUBLIC_ size_t strlen_m_term_null(const char *s)
+{
+	size_t len;
+	if (!s) {
+		return 0;
+	}
+	len = strlen_m(s);
+	if (len == 0) {
+		return 0;
+	}
+
+	return len+1;
+}
+
 /**
  Strchr and strrchr_m are a bit complex on general multi-byte strings. 
 **/
diff --git a/librpc/gen_ndr/cli_winreg.c b/librpc/gen_ndr/cli_winreg.c
index 58eff22..00f9e2d 100644
--- a/librpc/gen_ndr/cli_winreg.c
+++ b/librpc/gen_ndr/cli_winreg.c
@@ -497,7 +497,7 @@ NTSTATUS rpccli_winreg_EnumValue(struct rpc_pipe_client *cli,
 				 TALLOC_CTX *mem_ctx,
 				 struct policy_handle *handle /* [in] [ref] */,
 				 uint32_t enum_index /* [in]  */,
-				 struct winreg_StringBuf *name /* [in,out] [ref] */,
+				 struct winreg_ValNameBuf *name /* [in,out] [ref] */,
 				 enum winreg_Type *type /* [in,out] [unique] */,
 				 uint8_t *value /* [in,out] [unique,length_is(*length),size_is(*size)] */,
 				 uint32_t *size /* [in,out] [unique] */,
diff --git a/librpc/gen_ndr/cli_winreg.h b/librpc/gen_ndr/cli_winreg.h
index a5a5fa2..20d2a75 100644
--- a/librpc/gen_ndr/cli_winreg.h
+++ b/librpc/gen_ndr/cli_winreg.h
@@ -68,7 +68,7 @@ NTSTATUS rpccli_winreg_EnumValue(struct rpc_pipe_client *cli,
 				 TALLOC_CTX *mem_ctx,
 				 struct policy_handle *handle /* [in] [ref] */,
 				 uint32_t enum_index /* [in]  */,
-				 struct winreg_StringBuf *name /* [in,out] [ref] */,
+				 struct winreg_ValNameBuf *name /* [in,out] [ref] */,
 				 enum winreg_Type *type /* [in,out] [unique] */,
 				 uint8_t *value /* [in,out] [unique,length_is(*length),size_is(*size)] */,
 				 uint32_t *size /* [in,out] [unique] */,
diff --git a/librpc/gen_ndr/ndr_winreg.c b/librpc/gen_ndr/ndr_winreg.c
index d37cf8f..fe76bca 100644
--- a/librpc/gen_ndr/ndr_winreg.c
+++ b/librpc/gen_ndr/ndr_winreg.c
@@ -275,7 +275,7 @@ static enum ndr_err_code ndr_push_winreg_StringBuf(struct ndr_push *ndr, int ndr
 {
 	if (ndr_flags & NDR_SCALARS) {
 		NDR_CHECK(ndr_push_align(ndr, 4));
-		NDR_CHECK(ndr_push_uint16(ndr, NDR_SCALARS, strlen_m_term(r->name) * 2));
+		NDR_CHECK(ndr_push_uint16(ndr, NDR_SCALARS, strlen_m_term_null(r->name) * 2));
 		NDR_CHECK(ndr_push_uint16(ndr, NDR_SCALARS, r->size));
 		NDR_CHECK(ndr_push_unique_ptr(ndr, r->name));
 	}
@@ -283,8 +283,8 @@ static enum ndr_err_code ndr_push_winreg_StringBuf(struct ndr_push *ndr, int ndr
 		if (r->name) {
 			NDR_CHECK(ndr_push_uint32(ndr, NDR_SCALARS, r->size / 2));
 			NDR_CHECK(ndr_push_uint32(ndr, NDR_SCALARS, 0));
-			NDR_CHECK(ndr_push_uint32(ndr, NDR_SCALARS, strlen_m_term(r->name) * 2 / 2));
-			NDR_CHECK(ndr_push_charset(ndr, NDR_SCALARS, r->name, strlen_m_term(r->name) * 2 / 2, sizeof(uint16_t), CH_UTF16));
+			NDR_CHECK(ndr_push_uint32(ndr, NDR_SCALARS, strlen_m_term_null(r->name) * 2 / 2));
+			NDR_CHECK(ndr_push_charset(ndr, NDR_SCALARS, r->name, strlen_m_term_null(r->name) * 2 / 2, sizeof(uint16_t), CH_UTF16));
 		}
 	}
 	return NDR_ERR_SUCCESS;
@@ -331,6 +331,77 @@ _PUBLIC_ void ndr_print_winreg_StringBuf(struct ndr_print *ndr, const char *name
 {
 	ndr_print_struct(ndr, name, "winreg_StringBuf");
 	ndr->depth++;
+	ndr_print_uint16(ndr, "length", (ndr->flags & LIBNDR_PRINT_SET_VALUES)?strlen_m_term_null(r->name) * 2:r->length);
+	ndr_print_uint16(ndr, "size", r->size);
+	ndr_print_ptr(ndr, "name", r->name);
+	ndr->depth++;
+	if (r->name) {
+		ndr_print_string(ndr, "name", r->name);
+	}
+	ndr->depth--;
+	ndr->depth--;
+}
+
+static enum ndr_err_code ndr_push_winreg_ValNameBuf(struct ndr_push *ndr, int ndr_flags, const struct winreg_ValNameBuf *r)
+{
+	if (ndr_flags & NDR_SCALARS) {
+		NDR_CHECK(ndr_push_align(ndr, 4));
+		NDR_CHECK(ndr_push_uint16(ndr, NDR_SCALARS, strlen_m_term(r->name) * 2));
+		NDR_CHECK(ndr_push_uint16(ndr, NDR_SCALARS, r->size));
+		NDR_CHECK(ndr_push_unique_ptr(ndr, r->name));
+	}
+	if (ndr_flags & NDR_BUFFERS) {
+		if (r->name) {
+			NDR_CHECK(ndr_push_uint32(ndr, NDR_SCALARS, r->size / 2));
+			NDR_CHECK(ndr_push_uint32(ndr, NDR_SCALARS, 0));
+			NDR_CHECK(ndr_push_uint32(ndr, NDR_SCALARS, strlen_m_term(r->name) * 2 / 2));
+			NDR_CHECK(ndr_push_charset(ndr, NDR_SCALARS, r->name, strlen_m_term(r->name) * 2 / 2, sizeof(uint16_t), CH_UTF16));
+		}
+	}
+	return NDR_ERR_SUCCESS;
+}
+
+static enum ndr_err_code ndr_pull_winreg_ValNameBuf(struct ndr_pull *ndr, int ndr_flags, struct winreg_ValNameBuf *r)
+{
+	uint32_t _ptr_name;
+	TALLOC_CTX *_mem_save_name_0;
+	if (ndr_flags & NDR_SCALARS) {
+		NDR_CHECK(ndr_pull_align(ndr, 4));
+		NDR_CHECK(ndr_pull_uint16(ndr, NDR_SCALARS, &r->length));
+		NDR_CHECK(ndr_pull_uint16(ndr, NDR_SCALARS, &r->size));
+		NDR_CHECK(ndr_pull_generic_ptr(ndr, &_ptr_name));
+		if (_ptr_name) {
+			NDR_PULL_ALLOC(ndr, r->name);
+		} else {
+			r->name = NULL;
+		}
+	}
+	if (ndr_flags & NDR_BUFFERS) {
+		if (r->name) {
+			_mem_save_name_0 = NDR_PULL_GET_MEM_CTX(ndr);
+			NDR_PULL_SET_MEM_CTX(ndr, r->name, 0);
+			NDR_CHECK(ndr_pull_array_size(ndr, &r->name));
+			NDR_CHECK(ndr_pull_array_length(ndr, &r->name));
+			if (ndr_get_array_length(ndr, &r->name) > ndr_get_array_size(ndr, &r->name)) {
+				return ndr_pull_error(ndr, NDR_ERR_ARRAY_SIZE, "Bad array size %u should exceed array length %u", ndr_get_array_size(ndr, &r->name), ndr_get_array_length(ndr, &r->name));
+			}
+			NDR_CHECK(ndr_pull_charset(ndr, NDR_SCALARS, &r->name, ndr_get_array_length(ndr, &r->name), sizeof(uint16_t), CH_UTF16));
+			NDR_PULL_SET_MEM_CTX(ndr, _mem_save_name_0, 0);
+		}
+		if (r->name) {
+			NDR_CHECK(ndr_check_array_size(ndr, (void*)&r->name, r->size / 2));
+		}
+		if (r->name) {
+			NDR_CHECK(ndr_check_array_length(ndr, (void*)&r->name, r->length / 2));
+		}
+	}
+	return NDR_ERR_SUCCESS;
+}
+
+_PUBLIC_ void ndr_print_winreg_ValNameBuf(struct ndr_print *ndr, const char *name, const struct winreg_ValNameBuf *r)
+{
+	ndr_print_struct(ndr, name, "winreg_ValNameBuf");
+	ndr->depth++;
 	ndr_print_uint16(ndr, "length", (ndr->flags & LIBNDR_PRINT_SET_VALUES)?strlen_m_term(r->name) * 2:r->length);
 	ndr_print_uint16(ndr, "size", r->size);
 	ndr_print_ptr(ndr, "name", r->name);
@@ -1458,7 +1529,7 @@ _PUBLIC_ enum ndr_err_code ndr_push_winreg_EnumValue(struct ndr_push *ndr, int f
 		if (r->in.name == NULL) {
 			return ndr_push_error(ndr, NDR_ERR_INVALID_POINTER, "NULL [ref] pointer");
 		}
-		NDR_CHECK(ndr_push_winreg_StringBuf(ndr, NDR_SCALARS|NDR_BUFFERS, r->in.name));
+		NDR_CHECK(ndr_push_winreg_ValNameBuf(ndr, NDR_SCALARS|NDR_BUFFERS, r->in.name));
 		NDR_CHECK(ndr_push_unique_ptr(ndr, r->in.type));
 		if (r->in.type) {
 			NDR_CHECK(ndr_push_winreg_Type(ndr, NDR_SCALARS, *r->in.type));
@@ -1483,7 +1554,7 @@ _PUBLIC_ enum ndr_err_code ndr_push_winreg_EnumValue(struct ndr_push *ndr, int f
 		if (r->out.name == NULL) {
 			return ndr_push_error(ndr, NDR_ERR_INVALID_POINTER, "NULL [ref] pointer");
 		}
-		NDR_CHECK(ndr_push_winreg_StringBuf(ndr, NDR_SCALARS|NDR_BUFFERS, r->out.name));
+		NDR_CHECK(ndr_push_winreg_ValNameBuf(ndr, NDR_SCALARS|NDR_BUFFERS, r->out.name));
 		NDR_CHECK(ndr_push_unique_ptr(ndr, r->out.type));
 		if (r->out.type) {
 			NDR_CHECK(ndr_push_winreg_Type(ndr, NDR_SCALARS, *r->out.type));
@@ -1536,7 +1607,7 @@ _PUBLIC_ enum ndr_err_code ndr_pull_winreg_EnumValue(struct ndr_pull *ndr, int f
 		}
 		_mem_save_name_0 = NDR_PULL_GET_MEM_CTX(ndr);
 		NDR_PULL_SET_MEM_CTX(ndr, r->in.name, LIBNDR_FLAG_REF_ALLOC);
-		NDR_CHECK(ndr_pull_winreg_StringBuf(ndr, NDR_SCALARS|NDR_BUFFERS, r->in.name));
+		NDR_CHECK(ndr_pull_winreg_ValNameBuf(ndr, NDR_SCALARS|NDR_BUFFERS, r->in.name));
 		NDR_PULL_SET_MEM_CTX(ndr, _mem_save_name_0, LIBNDR_FLAG_REF_ALLOC);
 		NDR_CHECK(ndr_pull_generic_ptr(ndr, &_ptr_type));
 		if (_ptr_type) {
@@ -1609,7 +1680,7 @@ _PUBLIC_ enum ndr_err_code ndr_pull_winreg_EnumValue(struct ndr_pull *ndr, int f
 		}
 		_mem_save_name_0 = NDR_PULL_GET_MEM_CTX(ndr);
 		NDR_PULL_SET_MEM_CTX(ndr, r->out.name, LIBNDR_FLAG_REF_ALLOC);
-		NDR_CHECK(ndr_pull_winreg_StringBuf(ndr, NDR_SCALARS|NDR_BUFFERS, r->out.name));
+		NDR_CHECK(ndr_pull_winreg_ValNameBuf(ndr, NDR_SCALARS|NDR_BUFFERS, r->out.name));
 		NDR_PULL_SET_MEM_CTX(ndr, _mem_save_name_0, LIBNDR_FLAG_REF_ALLOC);
 		NDR_CHECK(ndr_pull_generic_ptr(ndr, &_ptr_type));
 		if (_ptr_type) {
@@ -1695,7 +1766,7 @@ _PUBLIC_ void ndr_print_winreg_EnumValue(struct ndr_print *ndr, const char *name
 		ndr_print_uint32(ndr, "enum_index", r->in.enum_index);
 		ndr_print_ptr(ndr, "name", r->in.name);
 		ndr->depth++;
-		ndr_print_winreg_StringBuf(ndr, "name", r->in.name);
+		ndr_print_winreg_ValNameBuf(ndr, "name", r->in.name);
 		ndr->depth--;
 		ndr_print_ptr(ndr, "type", r->in.type);
 		ndr->depth++;
@@ -1729,7 +1800,7 @@ _PUBLIC_ void ndr_print_winreg_EnumValue(struct ndr_print *ndr, const char *name
 		ndr->depth++;
 		ndr_print_ptr(ndr, "name", r->out.name);
 		ndr->depth++;
-		ndr_print_winreg_StringBuf(ndr, "name", r->out.name);
+		ndr_print_winreg_ValNameBuf(ndr, "name", r->out.name);
 		ndr->depth--;
 		ndr_print_ptr(ndr, "type", r->out.type);
 		ndr->depth++;
diff --git a/librpc/gen_ndr/ndr_winreg.h b/librpc/gen_ndr/ndr_winreg.h
index bc6cad1..a8766f4 100644
--- a/librpc/gen_ndr/ndr_winreg.h
+++ b/librpc/gen_ndr/ndr_winreg.h
@@ -93,6 +93,7 @@ void ndr_print_KeySecurityData(struct ndr_print *ndr, const char *name, const st
 void ndr_print_winreg_SecBuf(struct ndr_print *ndr, const char *name, const struct winreg_SecBuf *r);
 void ndr_print_winreg_CreateAction(struct ndr_print *ndr, const char *name, enum winreg_CreateAction r);
 void ndr_print_winreg_StringBuf(struct ndr_print *ndr, const char *name, const struct winreg_StringBuf *r);
+void ndr_print_winreg_ValNameBuf(struct ndr_print *ndr, const char *name, const struct winreg_ValNameBuf *r);
 enum ndr_err_code ndr_push_winreg_NotifyChangeType(struct ndr_push *ndr, int ndr_flags, uint32_t r);
 enum ndr_err_code ndr_pull_winreg_NotifyChangeType(struct ndr_pull *ndr, int ndr_flags, uint32_t *r);
 void ndr_print_winreg_NotifyChangeType(struct ndr_print *ndr, const char *name, uint32_t r);
diff --git a/librpc/gen_ndr/winreg.h b/librpc/gen_ndr/winreg.h
index a98120c..79cf33e 100644
--- a/librpc/gen_ndr/winreg.h
+++ b/librpc/gen_ndr/winreg.h
@@ -84,6 +84,12 @@ enum winreg_CreateAction
 ;
 
 struct winreg_StringBuf {
+	uint16_t length;/* [value(strlen_m_term_null(name)*2)] */
+	uint16_t size;
+	const char *name;/* [unique,length_is(length/2),charset(UTF16),size_is(size/2)] */
+};
+
+struct winreg_ValNameBuf {
 	uint16_t length;/* [value(strlen_m_term(name)*2)] */
 	uint16_t size;
 	const char *name;/* [unique,length_is(length/2),charset(UTF16),size_is(size/2)] */
@@ -261,7 +267,7 @@ struct winreg_EnumValue {
 	struct {
 		struct policy_handle *handle;/* [ref] */
 		uint32_t enum_index;
-		struct winreg_StringBuf *name;/* [ref] */
+		struct winreg_ValNameBuf *name;/* [ref] */
 		enum winreg_Type *type;/* [unique] */
 		uint8_t *value;/* [unique,length_is(*length),size_is(*size)] */
 		uint32_t *size;/* [unique] */
@@ -269,7 +275,7 @@ struct winreg_EnumValue {
 	} in;
 
 	struct {
-		struct winreg_StringBuf *name;/* [ref] */
+		struct winreg_ValNameBuf *name;/* [ref] */
 		enum winreg_Type *type;/* [unique] */
 		uint8_t *value;/* [unique,length_is(*length),size_is(*size)] */
 		uint32_t *size;/* [unique] */
diff --git a/librpc/idl/winreg.idl b/librpc/idl/winreg.idl
index 2f108a0..b905bde 100644
--- a/librpc/idl/winreg.idl
+++ b/librpc/idl/winreg.idl
@@ -139,7 +139,7 @@ import "lsa.idl", "security.idl";
 	);
 
 	typedef struct {
-		[value(strlen_m_term(name)*2)] uint16 length; 
+		[value(strlen_m_term_null(name)*2)] uint16 length;
 		/* size cannot be auto-set by value() as it is the
 		   amount of space the server is allowed to use for this
 		   string in the reply, not its current size */
@@ -157,13 +157,22 @@ import "lsa.idl", "security.idl";
 		[in,out,unique] NTTIME           *last_changed_time
 	);
 
+	typedef struct {
+		[value(strlen_m_term(name)*2)] uint16 length;
+		/* size cannot be auto-set by value() as it is the
+		   amount of space the server is allowed to use for this
+		   string in the reply, not its current size */
+		uint16 size;
+		[size_is(size/2),length_is(length/2),charset(UTF16)] uint16 *name;
+	} winreg_ValNameBuf;
+
 	/******************/
 	/* Function: 0x0a */
 
 	[public] WERROR winreg_EnumValue(
 		[in,ref]        policy_handle *handle,
 		[in]            uint32 enum_index,
-		[in,out,ref]    winreg_StringBuf *name,
+		[in,out,ref]    winreg_ValNameBuf *name,
 		[in,out,unique] winreg_Type *type,
 		[in,out,unique,size_is(*size),length_is(*length)] uint8 *value,
 		[in,out,unique] uint32 *size,
diff --git a/source3/lib/util_tdb.c b/source3/lib/util_tdb.c
index 8ceaa46..03f72df 100644
--- a/source3/lib/util_tdb.c
+++ b/source3/lib/util_tdb.c
@@ -275,28 +275,28 @@ int tdb_unpack(const uint8 *buf, int bufsize, const char *fmt, ...)
 
 	while (*fmt) {
 		switch ((c=*fmt++)) {
-		case 'b':
+		case 'b': /* unsigned 8-bit integer */
 			len = 1;
 			bt = va_arg(ap, uint8 *);
 			if (bufsize < len)
 				goto no_space;
 			*bt = SVAL(buf, 0);
 			break;
-		case 'w':
+		case 'w': /* unsigned 16-bit integer */
 			len = 2;
 			w = va_arg(ap, uint16 *);
 			if (bufsize < len)
 				goto no_space;
 			*w = SVAL(buf, 0);
 			break;
-		case 'd':
+		case 'd': /* signed 32-bit integer (standard int in most systems) */
 			len = 4;
 			d = va_arg(ap, uint32 *);
 			if (bufsize < len)
 				goto no_space;
 			*d = IVAL(buf, 0);
 			break;
-		case 'p':
+		case 'p': /* pointer */
 			len = 4;
 			p = va_arg(ap, void **);
 			if (bufsize < len)
@@ -308,20 +308,20 @@ int tdb_unpack(const uint8 *buf, int bufsize, const char *fmt, ...)
 
 			*p = (void *)(IVAL(buf, 0) ? (void *)1 : NULL);
 			break;
-		case 'P':
+		case 'P': /* null-terminated string */
 			/* Return malloc'ed string. */
 			ps = va_arg(ap,char **);
 			len = strlen((const char *)buf) + 1;
 			*ps = SMB_STRDUP((const char *)buf);
 			break;
-		case 'f':
+		case 'f': /* null-terminated string */
 			s = va_arg(ap,char *);
 			len = strlen((const char *)buf) + 1;
 			if (bufsize < len || len > sizeof(fstring))
 				goto no_space;
 			memcpy(s, buf, len);
 			break;
-		case 'B':
+		case 'B': /* fixed-length string */
 			i = va_arg(ap, int *);
 			b = va_arg(ap, char **);
 			len = 4;
diff --git a/source3/rpc_server/srv_eventlog_lib.c b/source3/rpc_server/srv_eventlog_lib.c
index c4a7828..aa75fb1 100644
--- a/source3/rpc_server/srv_eventlog_lib.c
+++ b/source3/rpc_server/srv_eventlog_lib.c
@@ -1,20 +1,20 @@
-/* 
+/*
  *  Unix SMB/CIFS implementation.
  *  Eventlog utility  routines
  *  Copyright (C) Marcin Krzysztof Porwit    2005,
  *  Copyright (C) Brian Moran                2005.
  *  Copyright (C) Gerald (Jerry) Carter      2005.
- *  
+ *
  *  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 3 of the License, or
  *  (at your option) any later version.
- *  
+ *
  *  This program is distributed in the hope that it will be useful,
  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  *  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, see <http://www.gnu.org/licenses/>.
  */
@@ -26,7 +26,7 @@
 static ELOG_TDB *open_elog_list;
 
 /********************************************************************
- Init an Eventlog TDB, and return it. If null, something bad 
+ Init an Eventlog TDB, and return it. If null, something bad
  happened.
 ********************************************************************/
 
@@ -37,7 +37,7 @@ TDB_CONTEXT *elog_init_tdb( char *tdbfilename )
 	DEBUG(10,("elog_init_tdb: Initializing eventlog tdb (%s)\n",
 		tdbfilename));
 
-	tdb = tdb_open_log( tdbfilename, 0, TDB_DEFAULT, 
+	tdb = tdb_open_log( tdbfilename, 0, TDB_DEFAULT,
 		O_RDWR|O_CREAT|O_TRUNC, 0660 );
 
 	if ( !tdb ) {
@@ -58,7 +58,7 @@ TDB_CONTEXT *elog_init_tdb( char *tdbfilename )
 }
 
 /********************************************************************
- make the tdb file name for an event log, given destination buffer 
+ make the tdb file name for an event log, given destination buffer
  and size. Caller must free memory.
 ********************************************************************/
 
@@ -76,7 +76,7 @@ char *elog_tdbname(TALLOC_CTX *ctx, const char *name )
 
 
 /********************************************************************
- this function is used to count up the number of bytes in a 
+ this function is used to count up the number of bytes in a
  particular TDB
 ********************************************************************/
 
@@ -89,27 +89,27 @@ static int eventlog_tdb_size_fn( TDB_CONTEXT * tdb, TDB_DATA key, TDB_DATA data,
 			  void *state )
 {
 	struct trav_size_struct	 *tsize = (struct trav_size_struct *)state;
-	
+
 	tsize->size += data.dsize;
 	tsize->rec_count++;
-	
+
 	return 0;
 }
 
 /********************************************************************
- returns the size of the eventlog, and if MaxSize is a non-null 
- ptr, puts the MaxSize there. This is purely a way not to have yet 
- another function that solely reads the maxsize of the eventlog. 
+ returns the size of the eventlog, and if MaxSize is a non-null
+ ptr, puts the MaxSize there. This is purely a way not to have yet
+ another function that solely reads the maxsize of the eventlog.
  Yeah, that's it.
 ********************************************************************/
 
 int elog_tdb_size( TDB_CONTEXT * tdb, int *MaxSize, int *Retention )
 {
 	struct trav_size_struct tsize;
-	
+
 	if ( !tdb )
 		return 0;
-		
+
 	ZERO_STRUCT( tsize );
 
 	tdb_traverse( tdb, eventlog_tdb_size_fn, &tsize );
@@ -130,13 +130,13 @@ int elog_tdb_size( TDB_CONTEXT * tdb, int *MaxSize, int *Retention )
 
 /********************************************************************
  Discard early event logs until we have enough for 'needed' bytes...
- NO checking done beforehand to see that we actually need to do 
- this, and it's going to pluck records one-by-one. So, it's best 
- to determine that this needs to be done before doing it.  
+ NO checking done beforehand to see that we actually need to do
+ this, and it's going to pluck records one-by-one. So, it's best
+ to determine that this needs to be done before doing it.
 
- Setting whack_by_date to True indicates that eventlogs falling 
+ Setting whack_by_date to True indicates that eventlogs falling
  outside of the retention range need to go...
- 
+
  return True if we made enough room to accommodate needed bytes
 ********************************************************************/
 
@@ -210,8 +210,8 @@ static bool make_way_for_eventlogs( TDB_CONTEXT * the_tdb, int32_t needed,
 		SAFE_FREE( ret.dptr );
 
 		/* note that other servers may just stop writing records when the size limit
-		   is reached, and there are no records older than 'retention'. This doesn't 
-		   like a very useful thing to do, so instead we whack (as in sleeps with the 
+		   is reached, and there are no records older than 'retention'. This doesn't
+		   like a very useful thing to do, so instead we whack (as in sleeps with the
 		   fishes) just enough records to fit the what we need.  This behavior could
 		   be changed to 'match', if the need arises. */
 
@@ -240,8 +240,8 @@ static bool make_way_for_eventlogs( TDB_CONTEXT * the_tdb, int32_t needed,


-- 
Samba Shared Repository


More information about the samba-cvs mailing list