From 5f868bc1acc9bdaed32ae70fb9906334663ccfff Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Wed, 17 Nov 2004 22:00:15 +0000 Subject: r3826: - added testing of ea lists in NTTRANS CREATE - fixed push/pull of chained ea lists - fixed a bug in the nttrans wire encoding (This used to be commit fcd09224076508f9c10095bf2e2c394232a4d297) --- source4/libcli/raw/raweas.c | 107 +++++++++++++++++++++++++++++++++++++++++--- 1 file changed, 102 insertions(+), 5 deletions(-) (limited to 'source4/libcli/raw/raweas.c') diff --git a/source4/libcli/raw/raweas.c b/source4/libcli/raw/raweas.c index 52c7832a6c..5bd90766aa 100644 --- a/source4/libcli/raw/raweas.c +++ b/source4/libcli/raw/raweas.c @@ -36,6 +36,23 @@ uint_t ea_list_size(uint_t num_eas, struct ea_struct *eas) return total; } +/* + work out how many bytes on the wire a chained ea list will consume. + This assumes the names are strict ascii, which should be a + reasonable assumption +*/ +uint_t ea_list_size_chained(uint_t num_eas, struct ea_struct *eas) +{ + uint_t total = 0; + int i; + for (i=0;i blob->length) { return NT_STATUS_INVALID_PARAMETER; } - - ofs = 4; + + ofs = 4; n = 0; *num_eas = 0; *eas = NULL; - while (ofs+6 < ea_size) { + while (ofs < ea_size) { uint_t len; DATA_BLOB blob2; @@ -146,3 +191,55 @@ NTSTATUS ea_pull_list(const DATA_BLOB *blob, return NT_STATUS_OK; } + +/* + pull a chained ea_list from a buffer +*/ +NTSTATUS ea_pull_list_chained(const DATA_BLOB *blob, + TALLOC_CTX *mem_ctx, + uint_t *num_eas, struct ea_struct **eas) +{ + int n; + uint32_t ofs; + + if (blob->length < 4) { + return NT_STATUS_INFO_LENGTH_MISMATCH; + } + + ofs = 0; + n = 0; + *num_eas = 0; + *eas = NULL; + + while (ofs < blob->length) { + uint_t len; + DATA_BLOB blob2; + uint32_t next_ofs = IVAL(blob->data, ofs); + + blob2.data = blob->data + ofs + 4; + blob2.length = blob->length - (ofs + 4); + + *eas = talloc_realloc(mem_ctx, *eas, sizeof(**eas) * (n+1)); + if (! *eas) return NT_STATUS_NO_MEMORY; + + len = ea_pull_struct(&blob2, mem_ctx, &(*eas)[n]); + if (len == 0) { + return NT_STATUS_INVALID_PARAMETER; + } + + ofs += next_ofs; + + if (ofs+4 > blob->length) { + return NT_STATUS_INVALID_PARAMETER; + } + n++; + if (next_ofs == 0) break; + } + + *num_eas = n; + + return NT_STATUS_OK; +} + + + -- cgit