Coverage Report

Created: 2026-07-25 07:00

next uncovered line (L), next uncovered region (R), next uncovered branch (B)
/src/samba/librpc/ndr/ndr_drsblobs.c
Line
Count
Source
1
/* 
2
   Unix SMB/CIFS implementation.
3
4
   Manually parsed structures found in the DRS protocol
5
6
   Copyright (C) Andrew Bartlett <abartlet@samba.org> 2008
7
   Copyright (C) Guenther Deschner <gd@samba.org> 2010
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 "librpc/gen_ndr/ndr_drsblobs.h"
25
#include "../lib/util/asn1.h"
26
27
_PUBLIC_ enum ndr_err_code ndr_push_AuthenticationInformationArray(struct ndr_push *ndr, ndr_flags_type ndr_flags, const struct AuthenticationInformationArray *r)
28
953
{
29
953
  uint32_t cntr_array_0;
30
953
  if (ndr_flags & NDR_SCALARS) {
31
953
    NDR_CHECK(ndr_push_align(ndr, 4));
32
15.6k
    for (cntr_array_0 = 0; cntr_array_0 < r->count; cntr_array_0++) {
33
14.6k
      NDR_CHECK(ndr_push_AuthenticationInformation(ndr, NDR_SCALARS, &r->array[cntr_array_0]));
34
14.6k
    }
35
953
    NDR_CHECK(ndr_push_align(ndr, 4));
36
953
  }
37
953
  if (ndr_flags & NDR_BUFFERS) {
38
585
  }
39
953
  return NDR_ERR_SUCCESS;
40
953
}
41
42
_PUBLIC_ enum ndr_err_code ndr_pull_AuthenticationInformationArray(struct ndr_pull *ndr, ndr_flags_type ndr_flags, struct AuthenticationInformationArray *r)
43
502
{
44
502
  if (ndr_flags & NDR_SCALARS) {
45
502
    r->count = 0;
46
502
    NDR_PULL_ALLOC_N(ndr, r->array, r->count);
47
    /* entry is at least 16 bytes large */
48
15.2k
    while (ndr->offset + 16 <= ndr->data_size) {
49
14.8k
      r->array = talloc_realloc(ndr, r->array, struct AuthenticationInformation, r->count + 1);
50
14.8k
      NDR_ERR_HAVE_NO_MEMORY(r->array);
51
14.8k
      NDR_CHECK(ndr_pull_AuthenticationInformation(ndr, NDR_SCALARS, &r->array[r->count]));
52
14.7k
      r->count++;
53
14.7k
    }
54
464
    NDR_CHECK(ndr_pull_align(ndr, 4));
55
464
  }
56
460
  if (ndr_flags & NDR_BUFFERS) {
57
138
  }
58
460
  return NDR_ERR_SUCCESS;
59
502
}
60
61
_PUBLIC_ enum ndr_err_code ndr_push_trustAuthInOutBlob(struct ndr_push *ndr, ndr_flags_type ndr_flags, const struct trustAuthInOutBlob *r)
62
189
{
63
189
  if (ndr_flags & NDR_SCALARS) {
64
189
    NDR_CHECK(ndr_push_align(ndr, 4));
65
189
    NDR_CHECK(ndr_push_uint32(ndr, NDR_SCALARS, r->count));
66
189
    NDR_CHECK(ndr_push_uint32(ndr, NDR_SCALARS, (r->count > 0)?12:0));
67
189
    NDR_CHECK(ndr_push_uint32(ndr, NDR_SCALARS, (r->count > 0)?12 + ndr_size_AuthenticationInformationArray(&r->current, 0):0));
68
189
    {
69
189
      struct ndr_push *_ndr_current;
70
189
      NDR_CHECK(ndr_push_subcontext_start(ndr, &_ndr_current, 0, ((r->count > 0)?12 + ndr_size_AuthenticationInformationArray(&r->current, 0):0) - ((r->count > 0)?12:0)));
71
189
      NDR_CHECK(ndr_push_AuthenticationInformationArray(_ndr_current, NDR_SCALARS, &r->current));
72
189
      NDR_CHECK(ndr_push_subcontext_end(ndr, _ndr_current, 0, ((r->count > 0)?12 + ndr_size_AuthenticationInformationArray(&r->current, 0):0) - ((r->count > 0)?12:0)));
73
189
    }
74
179
    {
75
179
      libndr_flags _flags_save_AuthenticationInformationArray = ndr->flags;
76
179
      ndr_set_flags(&ndr->flags, LIBNDR_FLAG_REMAINING);
77
179
      {
78
179
        struct ndr_push *_ndr_previous;
79
179
        NDR_CHECK(ndr_push_subcontext_start(ndr, &_ndr_previous, 0, -1));
80
179
        NDR_CHECK(ndr_push_AuthenticationInformationArray(_ndr_previous, NDR_SCALARS, &r->previous));
81
179
        NDR_CHECK(ndr_push_subcontext_end(ndr, _ndr_previous, 0, -1));
82
179
      }
83
179
      ndr->flags = _flags_save_AuthenticationInformationArray;
84
179
    }
85
179
    NDR_CHECK(ndr_push_trailer_align(ndr, 4));
86
179
  }
87
179
  if (ndr_flags & NDR_BUFFERS) {
88
163
  }
89
179
  return NDR_ERR_SUCCESS;
90
189
}
91
92
93
_PUBLIC_ enum ndr_err_code ndr_pull_trustDomainPasswords(struct ndr_pull *ndr, ndr_flags_type ndr_flags, struct trustDomainPasswords *r)
94
59
{
95
59
  if (ndr_flags & NDR_SCALARS) {
96
59
    uint32_t offset;
97
59
    NDR_PULL_ALIGN(ndr, 4);
98
59
    NDR_PULL_NEED_BYTES(ndr, 8);
99
    
100
54
    offset = ndr->offset;
101
54
    ndr->offset = ndr->data_size - 8;
102
103
54
    NDR_CHECK(ndr_pull_uint32(ndr, NDR_SCALARS, &r->outgoing_size));
104
54
    NDR_CHECK(ndr_pull_uint32(ndr, NDR_SCALARS, &r->incoming_size));
105
106
21
    ndr->offset = offset;
107
21
    NDR_CHECK(ndr_pull_array_uint8(ndr, NDR_SCALARS, r->confounder, 512));
108
20
    {
109
20
      struct ndr_pull *_ndr_outgoing;
110
20
      NDR_CHECK(ndr_pull_subcontext_start(ndr, &_ndr_outgoing, 0, r->outgoing_size));
111
19
      NDR_CHECK(ndr_pull_trustAuthInOutBlob(_ndr_outgoing, NDR_SCALARS|NDR_BUFFERS, &r->outgoing));
112
18
      NDR_CHECK(ndr_pull_subcontext_end(ndr, _ndr_outgoing, 0, r->outgoing_size));
113
18
    }
114
18
    {
115
18
      struct ndr_pull *_ndr_incoming;
116
18
      NDR_CHECK(ndr_pull_subcontext_start(ndr, &_ndr_incoming, 0, r->incoming_size));
117
17
      NDR_CHECK(ndr_pull_trustAuthInOutBlob(_ndr_incoming, NDR_SCALARS|NDR_BUFFERS, &r->incoming));
118
14
      NDR_CHECK(ndr_pull_subcontext_end(ndr, _ndr_incoming, 0, r->incoming_size));
119
14
    }
120
14
    NDR_CHECK(ndr_pull_uint32(ndr, NDR_SCALARS, &r->outgoing_size));
121
12
    NDR_CHECK(ndr_pull_uint32(ndr, NDR_SCALARS, &r->incoming_size));
122
12
  }
123
10
  if (ndr_flags & NDR_BUFFERS) {
124
10
  }
125
10
  return NDR_ERR_SUCCESS;
126
59
}
127
128
_PUBLIC_ void ndr_print_drsuapi_MSPrefixMap_Entry(struct ndr_print *ndr, const char *name, const struct drsuapi_MSPrefixMap_Entry *r)
129
6.66k
{
130
6.66k
  ndr_print_struct(ndr, name, "drsuapi_MSPrefixMap_Entry");
131
6.66k
  {
132
6.66k
    libndr_flags _flags_save_STRUCT = ndr->flags;
133
6.66k
    ndr_set_flags(&ndr->flags, LIBNDR_FLAG_NOALIGN);
134
6.66k
    ndr->depth++;
135
6.66k
    ndr_print_uint16(ndr, "entryID", r->entryID);
136
6.66k
    ndr->print(ndr, "%-25s: length=%"PRIu16, "oid", r->length);
137
6.66k
    if (r->binary_oid) {
138
6.66k
      char *partial_oid = NULL;
139
6.66k
      DATA_BLOB oid_blob = data_blob_const(r->binary_oid, r->length);
140
6.66k
      char *hex_str = data_blob_hex_string_upper(ndr, &oid_blob);
141
6.66k
      ber_read_partial_OID_String(ndr, oid_blob, &partial_oid);
142
6.66k
      ndr->depth++;
143
6.66k
      ndr->print(ndr, "%-25s: 0x%s (%s)", "binary_oid", hex_str, partial_oid);
144
6.66k
      ndr->depth--;
145
6.66k
      TALLOC_FREE(hex_str);
146
6.66k
      TALLOC_FREE(partial_oid);
147
6.66k
    }
148
6.66k
    ndr->depth--;
149
6.66k
    ndr->flags = _flags_save_STRUCT;
150
6.66k
  }
151
6.66k
}
152
153
_PUBLIC_ enum ndr_err_code ndr_push_supplementalCredentialsSubBlob(struct ndr_push *ndr, ndr_flags_type ndr_flags, const struct supplementalCredentialsSubBlob *r)
154
340
{
155
340
  uint32_t cntr_packages_0;
156
340
  NDR_PUSH_CHECK_FLAGS(ndr, ndr_flags);
157
340
  if (ndr_flags & NDR_SCALARS) {
158
340
    if ((r->signature != SUPPLEMENTAL_CREDENTIALS_SIGNATURE)
159
332
        && (r->num_packages == 0)) {
160
156
      return NDR_ERR_SUCCESS;
161
156
    }
162
184
    NDR_CHECK(ndr_push_align(ndr, 3));
163
184
    NDR_CHECK(ndr_push_charset(ndr, NDR_SCALARS, SUPPLEMENTAL_CREDENTIALS_PREFIX, 0x30, sizeof(uint16_t), CH_UTF16));
164
184
    NDR_CHECK(ndr_push_supplementalCredentialsSignature(ndr, NDR_SCALARS, SUPPLEMENTAL_CREDENTIALS_SIGNATURE));
165
184
    if (r->num_packages > 0) {
166
176
      NDR_CHECK(ndr_push_uint16(ndr, NDR_SCALARS, r->num_packages));
167
176
    }
168
45.1k
    for (cntr_packages_0 = 0; cntr_packages_0 < (r->num_packages); cntr_packages_0++) {
169
44.9k
      NDR_CHECK(ndr_push_supplementalCredentialsPackage(ndr, NDR_SCALARS, &r->packages[cntr_packages_0]));
170
44.9k
    }
171
184
    NDR_CHECK(ndr_push_trailer_align(ndr, 3));
172
184
  }
173
184
  if (ndr_flags & NDR_BUFFERS) {
174
138
  }
175
184
  return NDR_ERR_SUCCESS;
176
340
}
177
178
_PUBLIC_ enum ndr_err_code ndr_pull_supplementalCredentialsSubBlob(struct ndr_pull *ndr, ndr_flags_type ndr_flags, struct supplementalCredentialsSubBlob *r)
179
148
{
180
148
  uint32_t size_prefix_0 = 0;
181
148
  uint32_t size_packages_0 = 0;
182
148
  uint32_t cntr_packages_0;
183
148
  TALLOC_CTX *_mem_save_packages_0 = NULL;
184
148
  NDR_PULL_CHECK_FLAGS(ndr, ndr_flags);
185
148
  if (ndr_flags & NDR_SCALARS) {
186
148
    uint32_t remaining = 0;
187
148
    NDR_CHECK(ndr_pull_align(ndr, 3));
188
148
    size_prefix_0 = 0x30;
189
148
    remaining = ndr->data_size - ndr->offset;
190
148
    if (remaining >= size_prefix_0) {
191
54
      NDR_CHECK(ndr_pull_charset(ndr, NDR_SCALARS, &r->prefix, size_prefix_0, sizeof(uint16_t), CH_UTF16));
192
94
    } else {
193
94
      r->prefix = NULL;
194
94
    }
195
147
    remaining = ndr->data_size - ndr->offset;
196
147
    if (remaining >= 2) {
197
142
      NDR_CHECK(ndr_pull_supplementalCredentialsSignature(ndr, NDR_SCALARS, &r->signature));
198
142
    } else {
199
5
      r->signature = 0;
200
5
    }
201
147
    remaining = ndr->data_size - ndr->offset;
202
147
    if (remaining > 0) {
203
119
      NDR_CHECK(ndr_pull_uint16(ndr, NDR_SCALARS, &r->num_packages));
204
119
    } else {
205
28
      r->num_packages = 0;
206
28
    }
207
146
    size_packages_0 = r->num_packages;
208
146
    NDR_PULL_ALLOC_N(ndr, r->packages, size_packages_0);
209
146
    _mem_save_packages_0 = NDR_PULL_GET_MEM_CTX(ndr);
210
146
    NDR_PULL_SET_MEM_CTX(ndr, r->packages, 0);
211
20.5k
    for (cntr_packages_0 = 0; cntr_packages_0 < (size_packages_0); cntr_packages_0++) {
212
20.4k
      NDR_CHECK(ndr_pull_supplementalCredentialsPackage(ndr, NDR_SCALARS, &r->packages[cntr_packages_0]));
213
20.4k
    }
214
96
    NDR_PULL_SET_MEM_CTX(ndr, _mem_save_packages_0, 0);
215
96
    NDR_CHECK(ndr_pull_trailer_align(ndr, 3));
216
96
  }
217
96
  if (ndr_flags & NDR_BUFFERS) {
218
0
  }
219
96
  return NDR_ERR_SUCCESS;
220
148
}