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_ODJ.c
Line
Count
Source
1
/*
2
   Unix SMB/CIFS implementation.
3
4
   routines for marshalling/unmarshalling special ODJ structures
5
6
   Copyright (C) Guenther Deschner 2021
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 "../librpc/gen_ndr/ndr_ODJ.h"
24
#include "../librpc/ndr/ndr_ODJ.h"
25
26
uint32_t odj_switch_level_from_guid(const struct GUID *r)
27
17.8k
{
28
17.8k
  struct {
29
17.8k
    uint16_t level;
30
17.8k
    const char *guid;
31
17.8k
  } levels[] = {
32
17.8k
    {
33
17.8k
      .level  = 1,
34
17.8k
      .guid = ODJ_GUID_JOIN_PROVIDER
35
17.8k
    },{
36
17.8k
      .level  = 2,
37
17.8k
      .guid = ODJ_GUID_JOIN_PROVIDER2
38
17.8k
    },{
39
17.8k
      .level  = 3,
40
17.8k
      .guid = ODJ_GUID_JOIN_PROVIDER3
41
17.8k
    },{
42
17.8k
      .level  = 4,
43
17.8k
      .guid = ODJ_GUID_CERT_PROVIDER
44
17.8k
    },{
45
17.8k
      .level  = 5,
46
17.8k
      .guid = ODJ_GUID_POLICY_PROVIDER
47
17.8k
    }
48
17.8k
  };
49
17.8k
  int i;
50
51
106k
  for (i = 0; i < ARRAY_SIZE(levels); i++) {
52
89.0k
    struct GUID guid;
53
89.0k
    NTSTATUS status;
54
55
89.0k
    status = GUID_from_string(levels[i].guid, &guid);
56
89.0k
    if (!NT_STATUS_IS_OK(status)) {
57
0
      return 0;
58
0
    }
59
89.0k
    if (GUID_equal(&guid, r)) {
60
193
      return levels[i].level;
61
193
    }
62
89.0k
  }
63
64
17.6k
  return 0;
65
17.8k
}