summaryrefslogtreecommitdiff
path: root/source4/libcli/raw
diff options
context:
space:
mode:
authorAndrew Tridgell <tridge@samba.org>2005-11-15 04:38:59 +0000
committerGerald (Jerry) Carter <jerry@samba.org>2007-10-10 13:46:18 -0500
commitb51703baf152c309ce325ce573c1683d7e503122 (patch)
tree89fb1a5bfd9a3659be89185c198430ab8c35f9a6 /source4/libcli/raw
parentf7732560eea1c5d1de316fb2d64b78ad7507549b (diff)
downloadsamba-b51703baf152c309ce325ce573c1683d7e503122.tar.gz
samba-b51703baf152c309ce325ce573c1683d7e503122.tar.bz2
samba-b51703baf152c309ce325ce573c1683d7e503122.zip
r11730: added parsing and tests for a bunch more SMB2 getinfo levels
(This used to be commit ca65bf0235cbfab451e5d5ceac9f714acc0cd46c)
Diffstat (limited to 'source4/libcli/raw')
-rw-r--r--source4/libcli/raw/rawfileinfo.c74
1 files changed, 46 insertions, 28 deletions
diff --git a/source4/libcli/raw/rawfileinfo.c b/source4/libcli/raw/rawfileinfo.c
index ede4391824..f631522182 100644
--- a/source4/libcli/raw/rawfileinfo.c
+++ b/source4/libcli/raw/rawfileinfo.c
@@ -34,6 +34,51 @@
return NT_STATUS_INFO_LENGTH_MISMATCH; \
}
+/*
+ parse a stream information structure
+*/
+NTSTATUS smbcli_parse_stream_info(DATA_BLOB blob, TALLOC_CTX *mem_ctx,
+ struct stream_information *io)
+{
+ uint32_t ofs = 0;
+ io->num_streams = 0;
+ io->streams = NULL;
+
+ while (blob.length - ofs >= 24) {
+ uint_t n = io->num_streams;
+ uint32_t nlen, len;
+ ssize_t size;
+ void *vstr;
+ io->streams =
+ talloc_realloc(mem_ctx, io->streams, struct stream_struct, n+1);
+ if (!io->streams) {
+ return NT_STATUS_NO_MEMORY;
+ }
+ nlen = IVAL(blob.data, ofs + 0x04);
+ io->streams[n].size = BVAL(blob.data, ofs + 0x08);
+ io->streams[n].alloc_size = BVAL(blob.data, ofs + 0x10);
+ if (nlen > blob.length - (ofs + 24)) {
+ return NT_STATUS_INFO_LENGTH_MISMATCH;
+ }
+ size = convert_string_talloc(io->streams, CH_UTF16, CH_UNIX,
+ blob.data+ofs+24, nlen, &vstr);
+ if (size == -1) {
+ return NT_STATUS_ILLEGAL_CHARACTER;
+ }
+ io->streams[n].stream_name.s = vstr;
+ io->streams[n].stream_name.private_length = nlen;
+ io->num_streams++;
+ len = IVAL(blob.data, ofs);
+ if (len > blob.length - ofs) {
+ return NT_STATUS_INFO_LENGTH_MISMATCH;
+ }
+ if (len == 0) break;
+ ofs += len;
+ }
+
+ return NT_STATUS_OK;
+}
+
/****************************************************************************
Handle qfileinfo/qpathinfo trans2 backend.
****************************************************************************/
@@ -42,8 +87,6 @@ static NTSTATUS smb_raw_info_backend(struct smbcli_session *session,
union smb_fileinfo *parms,
DATA_BLOB *blob)
{
- uint_t len, ofs;
-
switch (parms->generic.level) {
case RAW_FILEINFO_GENERIC:
case RAW_FILEINFO_GETATTR:
@@ -175,32 +218,7 @@ static NTSTATUS smb_raw_info_backend(struct smbcli_session *session,
case RAW_FILEINFO_STREAM_INFO:
case RAW_FILEINFO_STREAM_INFORMATION:
- ofs = 0;
- parms->stream_info.out.num_streams = 0;
- parms->stream_info.out.streams = NULL;
-
- while (blob->length - ofs >= 24) {
- uint_t n = parms->stream_info.out.num_streams;
- parms->stream_info.out.streams =
- talloc_realloc(mem_ctx,
- parms->stream_info.out.streams,
- struct stream_struct,
- n+1);
- if (!parms->stream_info.out.streams) {
- return NT_STATUS_NO_MEMORY;
- }
- parms->stream_info.out.streams[n].size = BVAL(blob->data, ofs + 8);
- parms->stream_info.out.streams[n].alloc_size = BVAL(blob->data, ofs + 16);
- smbcli_blob_pull_string(session, mem_ctx, blob,
- &parms->stream_info.out.streams[n].stream_name,
- ofs+4, ofs+24, STR_UNICODE);
- parms->stream_info.out.num_streams++;
- len = IVAL(blob->data, ofs);
- if (len > blob->length - ofs) return NT_STATUS_INFO_LENGTH_MISMATCH;
- if (len == 0) break;
- ofs += len;
- }
- return NT_STATUS_OK;
+ return smbcli_parse_stream_info(*blob, mem_ctx, &parms->stream_info.out);
case RAW_FILEINFO_INTERNAL_INFORMATION:
FINFO_CHECK_SIZE(8);