LCOV - code coverage report
Current view: top level - source4/torture/local - verif_trailer.c (source / functions) Hit Total Coverage
Test: coverage report for abartlet/fix-coverage dd10fb34 Lines: 28 28 100.0 %
Date: 2021-09-23 10:06:22 Functions: 2 2 100.0 %

          Line data    Source code
       1             : /*
       2             :    Unix SMB/CIFS implementation.
       3             : 
       4             :    test suite for DCE/RPC verification trailer parsing
       5             : 
       6             :    Copyright (C) David Disseldorp 2014
       7             : 
       8             :    This program is free software; you can redistribute it and/or modify
       9             :    it under the terms of the GNU General Public License as published by
      10             :    the Free Software Foundation; either version 3 of the License, or
      11             :    (at your option) any later version.
      12             : 
      13             :    This program is distributed in the hope that it will be useful,
      14             :    but WITHOUT ANY WARRANTY; without even the implied warranty of
      15             :    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
      16             :    GNU General Public License for more details.
      17             : 
      18             :    You should have received a copy of the GNU General Public License
      19             :    along with this program.  If not, see <http://www.gnu.org/licenses/>.
      20             : */
      21             : 
      22             : #include "includes.h"
      23             : #include <unistd.h>
      24             : 
      25             : #include "librpc/gen_ndr/security.h"
      26             : #include "lib/param/param.h"
      27             : #include "lib/util/dlinklist.h"
      28             : #include "libcli/resolve/resolve.h"
      29             : #include "librpc/gen_ndr/ndr_dcerpc.h"
      30             : #include "librpc/rpc/rpc_common.h"
      31             : #include "torture/torture.h"
      32             : #include "torture/local/proto.h"
      33             : 
      34             : /* VT blob obtained from an FSRVP request */
      35             : uint8_t test_vt[] = {0x8a, 0xe3, 0x13, 0x71, 0x02, 0xf4, 0x36, 0x71,
      36             :                      0x02, 0x40, 0x28, 0x00, 0x3c, 0x65, 0xe0, 0xa8,
      37             :                      0x44, 0x27, 0x89, 0x43, 0xa6, 0x1d, 0x73, 0x73,
      38             :                      0xdf, 0x8b, 0x22, 0x92, 0x01, 0x00, 0x00, 0x00,
      39             :                      0x33, 0x05, 0x71, 0x71, 0xba, 0xbe, 0x37, 0x49,
      40             :                      0x83, 0x19, 0xb5, 0xdb, 0xef, 0x9c, 0xcc, 0x36,
      41             :                      0x01, 0x00, 0x00, 0x00};
      42             : 
      43             : const char *vt_abstr_syntax = "a8e0653c-2744-4389-a61d-7373df8b2292/0x00000001";
      44             : const char *vt_trans_syntax = "71710533-beba-4937-8319-b5dbef9ccc36/0x00000001";
      45             : 
      46           1 : static bool test_verif_trailer_pctx(struct torture_context *tctx)
      47             : {
      48             :         DATA_BLOB blob;
      49             :         bool ok;
      50             :         struct dcerpc_sec_vt_pcontext pctx;
      51           1 :         struct dcerpc_sec_verification_trailer *vt = NULL;
      52             :         struct ndr_pull *ndr;
      53             :         enum ndr_err_code ndr_err;
      54             :         struct ndr_print *ndr_print;
      55           1 :         TALLOC_CTX *mem_ctx = talloc_new(tctx);
      56           1 :         torture_assert(tctx, mem_ctx != NULL, "mem");
      57             : 
      58           1 :         blob.data = test_vt;
      59           1 :         blob.length = ARRAY_SIZE(test_vt);
      60             : 
      61           1 :         ndr = ndr_pull_init_blob(&blob, mem_ctx);
      62           1 :         torture_assert(tctx, ndr != NULL, "ndr");
      63             : 
      64           1 :         ndr_err = ndr_pop_dcerpc_sec_verification_trailer(ndr, mem_ctx, &vt);
      65           1 :         torture_assert(tctx, NDR_ERR_CODE_IS_SUCCESS(ndr_err), "ndr");
      66             : 
      67           1 :         ndr_print = talloc_zero(mem_ctx, struct ndr_print);
      68           1 :         torture_assert(tctx, ndr_print != NULL, "mem");
      69           1 :         ndr_print->print = ndr_print_printf_helper;
      70           1 :         ndr_print->depth = 1;
      71             : 
      72           1 :         ndr_print_dcerpc_sec_verification_trailer(ndr_print,
      73             :                                                   "Verification Trailer", vt);
      74             : 
      75           1 :         ZERO_STRUCT(pctx);
      76           1 :         ok = ndr_syntax_id_from_string(vt_abstr_syntax, &pctx.abstract_syntax);
      77           1 :         torture_assert(tctx, ok, "vt_abstr_syntax");
      78           1 :         ok = ndr_syntax_id_from_string(vt_trans_syntax, &pctx.transfer_syntax);
      79           1 :         torture_assert(tctx, ok, "vt_trans_syntax");
      80             : 
      81           1 :         ok = dcerpc_sec_verification_trailer_check(vt, NULL, &pctx, NULL);
      82           1 :         torture_assert(tctx, ok, "VT check");
      83             : 
      84           1 :         talloc_free(mem_ctx);
      85             : 
      86           1 :         return true;
      87             : }
      88             : 
      89        2355 : struct torture_suite *torture_local_verif_trailer(TALLOC_CTX *mem_ctx)
      90             : {
      91        2355 :         struct torture_suite *suite = torture_suite_create(mem_ctx,
      92             :                                                            "verif_trailer");
      93             : 
      94        2355 :         torture_suite_add_simple_test(suite,
      95             :                                       "pctx",
      96             :                                       test_verif_trailer_pctx);
      97             : 
      98        2355 :         return suite;
      99             : }

Generated by: LCOV version 1.13