LCOV - code coverage report
Current view: top level - auth - auth_util.c (source / functions) Hit Total Coverage
Test: coverage report for master 2b515b7d Lines: 13 23 56.5 %
Date: 2024-02-28 12:06:22 Functions: 1 1 100.0 %

          Line data    Source code
       1             : /*
       2             :    Unix SMB/CIFS implementation.
       3             :    Authentication utility functions
       4             : 
       5             :    Copyright (C) Andrew Bartlett <abartlet@samba.org> 2017
       6             : 
       7             :    This program is free software; you can redistribute it and/or modify
       8             :    it under the terms of the GNU General Public License as published by
       9             :    the Free Software Foundation; either version 3 of the License, or
      10             :    (at your option) any later version.
      11             : 
      12             :    This program is distributed in the hope that it will be useful,
      13             :    but WITHOUT ANY WARRANTY; without even the implied warranty of
      14             :    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
      15             :    GNU General Public License for more details.
      16             : 
      17             :    You should have received a copy of the GNU General Public License
      18             :    along with this program.  If not, see <http://www.gnu.org/licenses/>.
      19             : */
      20             : 
      21             : #include "includes.h"
      22             : #include "librpc/ndr/libndr.h"
      23             : #include "librpc/gen_ndr/ndr_auth.h"
      24             : #include "auth_util.h"
      25             : 
      26      205085 : struct auth_session_info *copy_session_info(TALLOC_CTX *mem_ctx,
      27             :                                             const struct auth_session_info *src)
      28             : {
      29      205085 :         TALLOC_CTX *frame = talloc_stackframe();
      30        4009 :         struct auth_session_info *dst;
      31        4009 :         DATA_BLOB blob;
      32        4009 :         enum ndr_err_code ndr_err;
      33             : 
      34      205085 :         ndr_err = ndr_push_struct_blob(
      35             :                 &blob,
      36             :                 frame,
      37             :                 src,
      38             :                 (ndr_push_flags_fn_t)ndr_push_auth_session_info);
      39      205085 :         if (!NDR_ERR_CODE_IS_SUCCESS(ndr_err)) {
      40           0 :                 DBG_ERR("copy_session_info(): ndr_push_auth_session_info "
      41             :                         "failed: %s\n",
      42             :                         ndr_errstr(ndr_err));
      43           0 :                 TALLOC_FREE(frame);
      44           0 :                 return NULL;
      45             :         }
      46             : 
      47      205085 :         dst = talloc_zero(mem_ctx, struct auth_session_info);
      48      205085 :         if (dst == NULL) {
      49           0 :                 DBG_ERR("talloc failed\n");
      50           0 :                 TALLOC_FREE(frame);
      51           0 :                 return NULL;
      52             :         }
      53             : 
      54      205085 :         ndr_err = ndr_pull_struct_blob(
      55             :                 &blob,
      56             :                 dst,
      57             :                 dst,
      58             :                 (ndr_pull_flags_fn_t)ndr_pull_auth_session_info);
      59             : 
      60      205085 :         if (!NDR_ERR_CODE_IS_SUCCESS(ndr_err)) {
      61           0 :                 DBG_ERR("copy_session_info(): ndr_pull_auth_session_info "
      62             :                         "failed: %s\n",
      63             :                         ndr_errstr(ndr_err));
      64           0 :                 TALLOC_FREE(dst);
      65           0 :                 TALLOC_FREE(frame);
      66           0 :                 return NULL;
      67             :         }
      68             : 
      69      205085 :         TALLOC_FREE(frame);
      70      201076 :         return dst;
      71             : }

Generated by: LCOV version 1.14