source: trunk/server/libcli/smb/smb2_create_blob.c@ 421

Last change on this file since 421 was 414, checked in by Herwig Bauernfeind, 16 years ago

Samba 3.5.0: Initial import

File size: 5.2 KB
Line 
1/*
2 Unix SMB/CIFS implementation.
3
4 SMB2 Create Context Blob handling
5
6 Copyright (C) Andrew Tridgell 2005
7 Copyright (C) Stefan Metzmacher 2008-2009
8
9 This program is free software; you can redistribute it and/or modify
10 it under the terms of the GNU General Public License as published by
11 the Free Software Foundation; either version 3 of the License, or
12 (at your option) any later version.
13
14 This program is distributed in the hope that it will be useful,
15 but WITHOUT ANY WARRANTY; without even the implied warranty of
16 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 GNU General Public License for more details.
18
19 You should have received a copy of the GNU General Public License
20 along with this program. If not, see <http://www.gnu.org/licenses/>.
21*/
22
23#include "includes.h"
24#include "../libcli/smb/smb_common.h"
25
26static size_t smb2_create_blob_padding(uint32_t offset, size_t n)
27{
28 if ((offset & (n-1)) == 0) return 0;
29 return n - (offset & (n-1));
30}
31
32/*
33 parse a set of SMB2 create blobs
34*/
35NTSTATUS smb2_create_blob_parse(TALLOC_CTX *mem_ctx, const DATA_BLOB buffer,
36 struct smb2_create_blobs *blobs)
37{
38 const uint8_t *data = buffer.data;
39 uint32_t remaining = buffer.length;
40
41 while (remaining > 0) {
42 uint32_t next;
43 uint32_t name_offset, name_length;
44 uint32_t reserved, data_offset;
45 uint32_t data_length;
46 char *tag;
47 DATA_BLOB b;
48 NTSTATUS status;
49
50 if (remaining < 16) {
51 return NT_STATUS_INVALID_PARAMETER;
52 }
53 next = IVAL(data, 0);
54 name_offset = SVAL(data, 4);
55 name_length = SVAL(data, 6);
56 reserved = SVAL(data, 8);
57 data_offset = SVAL(data, 10);
58 data_length = IVAL(data, 12);