LCOV - code coverage report
Current view: top level - librpc/ndr - ndr_drsblobs.c (source / functions) Hit Total Coverage
Test: coverage report for vadcx-master-patch-75612 fe003de8 Lines: 119 139 85.6 %
Date: 2024-02-29 22:57:05 Functions: 6 7 85.7 %

          Line data    Source code
       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        5033 : _PUBLIC_ enum ndr_err_code ndr_push_AuthenticationInformationArray(struct ndr_push *ndr, ndr_flags_type ndr_flags, const struct AuthenticationInformationArray *r)
      28             : {
      29          50 :         uint32_t cntr_array_0;
      30        5033 :         if (ndr_flags & NDR_SCALARS) {
      31        5033 :                 NDR_CHECK(ndr_push_align(ndr, 4));
      32       10102 :                 for (cntr_array_0 = 0; cntr_array_0 < r->count; cntr_array_0++) {
      33        5069 :                         NDR_CHECK(ndr_push_AuthenticationInformation(ndr, NDR_SCALARS, &r->array[cntr_array_0]));
      34             :                 }
      35        5033 :                 NDR_CHECK(ndr_push_align(ndr, 4));
      36             :         }
      37        5033 :         if (ndr_flags & NDR_BUFFERS) {
      38          50 :         }
      39        5033 :         return NDR_ERR_SUCCESS;
      40             : }
      41             : 
      42        3428 : _PUBLIC_ enum ndr_err_code ndr_pull_AuthenticationInformationArray(struct ndr_pull *ndr, ndr_flags_type ndr_flags, struct AuthenticationInformationArray *r)
      43             : {
      44        3428 :         if (ndr_flags & NDR_SCALARS) {
      45        3428 :                 r->count = 0;
      46        3428 :                 NDR_PULL_ALLOC_N(ndr, r->array, r->count);
      47             :                 /* entry is at least 16 bytes large */
      48        9129 :                 while (ndr->offset + 16 <= ndr->data_size) {
      49        5701 :                         r->array = talloc_realloc(ndr, r->array, struct AuthenticationInformation, r->count + 1);
      50        5701 :                         NDR_ERR_HAVE_NO_MEMORY(r->array);
      51        5701 :                         NDR_CHECK(ndr_pull_AuthenticationInformation(ndr, NDR_SCALARS, &r->array[r->count]));
      52        5701 :                         r->count++;
      53             :                 }
      54        3428 :                 NDR_CHECK(ndr_pull_align(ndr, 4));
      55             :         }
      56        3428 :         if (ndr_flags & NDR_BUFFERS) {
      57          28 :         }
      58        3428 :         return NDR_ERR_SUCCESS;
      59             : }
      60             : 
      61        1021 : _PUBLIC_ enum ndr_err_code ndr_push_trustAuthInOutBlob(struct ndr_push *ndr, ndr_flags_type ndr_flags, const struct trustAuthInOutBlob *r)
      62             : {
      63        1021 :         if (ndr_flags & NDR_SCALARS) {
      64        1021 :                 NDR_CHECK(ndr_push_align(ndr, 4));
      65        1021 :                 NDR_CHECK(ndr_push_uint32(ndr, NDR_SCALARS, r->count));
      66        1021 :                 NDR_CHECK(ndr_push_uint32(ndr, NDR_SCALARS, (r->count > 0)?12:0));
      67        1021 :                 NDR_CHECK(ndr_push_uint32(ndr, NDR_SCALARS, (r->count > 0)?12 + ndr_size_AuthenticationInformationArray(&r->current, 0):0));
      68             :                 {
      69          10 :                         struct ndr_push *_ndr_current;
      70        1021 :                         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        1021 :                         NDR_CHECK(ndr_push_AuthenticationInformationArray(_ndr_current, NDR_SCALARS, &r->current));
      72        1021 :                         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             :                 }
      74             :                 {
      75        1021 :                         libndr_flags _flags_save_AuthenticationInformationArray = ndr->flags;
      76        1021 :                         ndr_set_flags(&ndr->flags, LIBNDR_FLAG_REMAINING);
      77             :                         {
      78          10 :                                 struct ndr_push *_ndr_previous;
      79        1021 :                                 NDR_CHECK(ndr_push_subcontext_start(ndr, &_ndr_previous, 0, -1));
      80        1021 :                                 NDR_CHECK(ndr_push_AuthenticationInformationArray(_ndr_previous, NDR_SCALARS, &r->previous));
      81        1021 :                                 NDR_CHECK(ndr_push_subcontext_end(ndr, _ndr_previous, 0, -1));
      82             :                         }
      83        1021 :                         ndr->flags = _flags_save_AuthenticationInformationArray;
      84             :                 }
      85        1021 :                 NDR_CHECK(ndr_push_trailer_align(ndr, 4));
      86             :         }
      87        1021 :         if (ndr_flags & NDR_BUFFERS) {
      88          10 :         }
      89        1021 :         return NDR_ERR_SUCCESS;
      90             : }
      91             : 
      92             : 
      93          68 : _PUBLIC_ enum ndr_err_code ndr_pull_trustDomainPasswords(struct ndr_pull *ndr, ndr_flags_type ndr_flags, struct trustDomainPasswords *r)
      94             : {
      95          68 :         if (ndr_flags & NDR_SCALARS) {
      96           2 :                 uint32_t offset;
      97          68 :                 NDR_PULL_ALIGN(ndr, 4);
      98          68 :                 NDR_PULL_NEED_BYTES(ndr, 8);
      99             :                 
     100          68 :                 offset = ndr->offset;
     101          68 :                 ndr->offset = ndr->data_size - 8;
     102             : 
     103          68 :                 NDR_CHECK(ndr_pull_uint32(ndr, NDR_SCALARS, &r->outgoing_size));
     104          68 :                 NDR_CHECK(ndr_pull_uint32(ndr, NDR_SCALARS, &r->incoming_size));
     105             : 
     106          68 :                 ndr->offset = offset;
     107          68 :                 NDR_CHECK(ndr_pull_array_uint8(ndr, NDR_SCALARS, r->confounder, 512));
     108             :                 {
     109           2 :                         struct ndr_pull *_ndr_outgoing;
     110          68 :                         NDR_CHECK(ndr_pull_subcontext_start(ndr, &_ndr_outgoing, 0, r->outgoing_size));
     111          68 :                         NDR_CHECK(ndr_pull_trustAuthInOutBlob(_ndr_outgoing, NDR_SCALARS|NDR_BUFFERS, &r->outgoing));
     112          68 :                         NDR_CHECK(ndr_pull_subcontext_end(ndr, _ndr_outgoing, 0, r->outgoing_size));
     113             :                 }
     114             :                 {
     115           2 :                         struct ndr_pull *_ndr_incoming;
     116          68 :                         NDR_CHECK(ndr_pull_subcontext_start(ndr, &_ndr_incoming, 0, r->incoming_size));
     117          68 :                         NDR_CHECK(ndr_pull_trustAuthInOutBlob(_ndr_incoming, NDR_SCALARS|NDR_BUFFERS, &r->incoming));
     118          68 :                         NDR_CHECK(ndr_pull_subcontext_end(ndr, _ndr_incoming, 0, r->incoming_size));
     119             :                 }
     120          68 :                 NDR_CHECK(ndr_pull_uint32(ndr, NDR_SCALARS, &r->outgoing_size));
     121          68 :                 NDR_CHECK(ndr_pull_uint32(ndr, NDR_SCALARS, &r->incoming_size));
     122             :         }
     123          68 :         if (ndr_flags & NDR_BUFFERS) {
     124           2 :         }
     125          68 :         return NDR_ERR_SUCCESS;
     126             : }
     127             : 
     128           0 : _PUBLIC_ void ndr_print_drsuapi_MSPrefixMap_Entry(struct ndr_print *ndr, const char *name, const struct drsuapi_MSPrefixMap_Entry *r)
     129             : {
     130           0 :         ndr_print_struct(ndr, name, "drsuapi_MSPrefixMap_Entry");
     131             :         {
     132           0 :                 libndr_flags _flags_save_STRUCT = ndr->flags;
     133           0 :                 ndr_set_flags(&ndr->flags, LIBNDR_FLAG_NOALIGN);
     134           0 :                 ndr->depth++;
     135           0 :                 ndr_print_uint16(ndr, "entryID", r->entryID);
     136           0 :                 ndr->print(ndr, "%-25s: length=%"PRIu16, "oid", r->length);
     137           0 :                 if (r->binary_oid) {
     138           0 :                         char *partial_oid = NULL;
     139           0 :                         DATA_BLOB oid_blob = data_blob_const(r->binary_oid, r->length);
     140           0 :                         char *hex_str = data_blob_hex_string_upper(ndr, &oid_blob);
     141           0 :                         ber_read_partial_OID_String(ndr, oid_blob, &partial_oid);
     142           0 :                         ndr->depth++;
     143           0 :                         ndr->print(ndr, "%-25s: 0x%s (%s)", "binary_oid", hex_str, partial_oid);
     144           0 :                         ndr->depth--;
     145           0 :                         talloc_free(hex_str);
     146           0 :                         talloc_free(partial_oid);
     147             :                 }
     148           0 :                 ndr->depth--;
     149           0 :                 ndr->flags = _flags_save_STRUCT;
     150             :         }
     151           0 : }
     152             : 
     153       84632 : _PUBLIC_ enum ndr_err_code ndr_push_supplementalCredentialsSubBlob(struct ndr_push *ndr, ndr_flags_type ndr_flags, const struct supplementalCredentialsSubBlob *r)
     154             : {
     155         844 :         uint32_t cntr_packages_0;
     156       84632 :         NDR_PUSH_CHECK_FLAGS(ndr, ndr_flags);
     157       84632 :         if (ndr_flags & NDR_SCALARS) {
     158       84632 :                 if ((r->signature != SUPPLEMENTAL_CREDENTIALS_SIGNATURE)
     159          56 :                     && (r->num_packages == 0)) {
     160          48 :                         return NDR_ERR_SUCCESS;
     161             :                 }
     162       84576 :                 NDR_CHECK(ndr_push_align(ndr, 3));
     163       84576 :                 NDR_CHECK(ndr_push_charset(ndr, NDR_SCALARS, SUPPLEMENTAL_CREDENTIALS_PREFIX, 0x30, sizeof(uint16_t), CH_UTF16));
     164       84576 :                 NDR_CHECK(ndr_push_supplementalCredentialsSignature(ndr, NDR_SCALARS, SUPPLEMENTAL_CREDENTIALS_SIGNATURE));
     165       84576 :                 if (r->num_packages > 0) {
     166       84548 :                         NDR_CHECK(ndr_push_uint16(ndr, NDR_SCALARS, r->num_packages));
     167             :                 }
     168      437920 :                 for (cntr_packages_0 = 0; cntr_packages_0 < (r->num_packages); cntr_packages_0++) {
     169      353344 :                         NDR_CHECK(ndr_push_supplementalCredentialsPackage(ndr, NDR_SCALARS, &r->packages[cntr_packages_0]));
     170             :                 }
     171       84576 :                 NDR_CHECK(ndr_push_trailer_align(ndr, 3));
     172             :         }
     173       84576 :         if (ndr_flags & NDR_BUFFERS) {
     174         836 :         }
     175       84576 :         return NDR_ERR_SUCCESS;
     176             : }
     177             : 
     178      303995 : _PUBLIC_ enum ndr_err_code ndr_pull_supplementalCredentialsSubBlob(struct ndr_pull *ndr, ndr_flags_type ndr_flags, struct supplementalCredentialsSubBlob *r)
     179             : {
     180      303995 :         uint32_t size_prefix_0 = 0;
     181      303995 :         uint32_t size_packages_0 = 0;
     182       10203 :         uint32_t cntr_packages_0;
     183      303995 :         TALLOC_CTX *_mem_save_packages_0 = NULL;
     184      303995 :         NDR_PULL_CHECK_FLAGS(ndr, ndr_flags);
     185      303995 :         if (ndr_flags & NDR_SCALARS) {
     186      303995 :                 uint32_t remaining = 0;
     187      303995 :                 NDR_CHECK(ndr_pull_align(ndr, 3));
     188      303995 :                 size_prefix_0 = 0x30;
     189      303995 :                 remaining = ndr->data_size - ndr->offset;
     190      303995 :                 if (remaining >= size_prefix_0) {
     191      303991 :                         NDR_CHECK(ndr_pull_charset(ndr, NDR_SCALARS, &r->prefix, size_prefix_0, sizeof(uint16_t), CH_UTF16));
     192             :                 } else {
     193           4 :                         r->prefix = NULL;
     194             :                 }
     195      303995 :                 remaining = ndr->data_size - ndr->offset;
     196      303995 :                 if (remaining >= 2) {
     197      303991 :                         NDR_CHECK(ndr_pull_supplementalCredentialsSignature(ndr, NDR_SCALARS, &r->signature));
     198             :                 } else {
     199           4 :                         r->signature = 0;
     200             :                 }
     201      303995 :                 remaining = ndr->data_size - ndr->offset;
     202      303995 :                 if (remaining > 0) {
     203      303989 :                         NDR_CHECK(ndr_pull_uint16(ndr, NDR_SCALARS, &r->num_packages));
     204             :                 } else {
     205           6 :                         r->num_packages = 0;
     206             :                 }
     207      303995 :                 size_packages_0 = r->num_packages;
     208      303995 :                 NDR_PULL_ALLOC_N(ndr, r->packages, size_packages_0);
     209      303995 :                 _mem_save_packages_0 = NDR_PULL_GET_MEM_CTX(ndr);
     210      303995 :                 NDR_PULL_SET_MEM_CTX(ndr, r->packages, 0);
     211     1640238 :                 for (cntr_packages_0 = 0; cntr_packages_0 < (size_packages_0); cntr_packages_0++) {
     212     1336243 :                         NDR_CHECK(ndr_pull_supplementalCredentialsPackage(ndr, NDR_SCALARS, &r->packages[cntr_packages_0]));
     213             :                 }
     214      303995 :                 NDR_PULL_SET_MEM_CTX(ndr, _mem_save_packages_0, 0);
     215      303995 :                 NDR_CHECK(ndr_pull_trailer_align(ndr, 3));
     216             :         }
     217      303995 :         if (ndr_flags & NDR_BUFFERS) {
     218       10203 :         }
     219      303995 :         return NDR_ERR_SUCCESS;
     220             : }

Generated by: LCOV version 1.14