LCOV - code coverage report
Current view: top level - libcli/util - doserr.c (source / functions) Hit Total Coverage
Test: coverage report for abartlet/fix-coverage dd10fb34 Lines: 21 22 95.5 %
Date: 2021-09-23 10:06:22 Functions: 2 2 100.0 %

          Line data    Source code
       1             : /* 
       2             :  *  Unix SMB/CIFS implementation.
       3             :  *  DOS error routines
       4             :  *  Copyright (C) Tim Potter 2002.
       5             :  *  
       6             :  *  This program is free software; you can redistribute it and/or modify
       7             :  *  it under the terms of the GNU General Public License as published by
       8             :  *  the Free Software Foundation; either version 3 of the License, or
       9             :  *  (at your option) any later version.
      10             :  *  
      11             :  *  This program is distributed in the hope that it will be useful,
      12             :  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
      13             :  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
      14             :  *  GNU General Public License for more details.
      15             :  *  
      16             :  *  You should have received a copy of the GNU General Public License
      17             :  *  along with this program; if not, see <http://www.gnu.org/licenses/>.
      18             :  */
      19             : 
      20             : /* DOS error codes.  please read doserr.h */
      21             : 
      22             : #include "includes.h"
      23             : 
      24             : struct werror_code_struct {
      25             :         const char *dos_errstr;
      26             :         WERROR werror;
      27             : };
      28             : 
      29             : struct werror_str_struct {
      30             :         WERROR werror;
      31             :         const char *friendly_errstr;
      32             : };
      33             : 
      34             : #include "werror_gen.c"
      35             : 
      36             : static const struct werror_code_struct special_errs[] =
      37             : {
      38             :         { "WERR_DNS_ERROR_NOT_ALLOWED_ON_ACTIVE_SKD", WERR_DNS_ERROR_NOT_ALLOWED_ON_ACTIVE_SKD },
      39             :         { "WERR_DNS_ERROR_INVALID_NSEC3_PARAMETERS", WERR_DNS_ERROR_INVALID_NSEC3_PARAMETERS },
      40             :         { "WERR_DNS_ERROR_DNSSEC_IS_DISABLED", WERR_DNS_ERROR_DNSSEC_IS_DISABLED },
      41             :         { "WERR_DNS_ERROR_NOT_ALLOWED_ON_UNSIGNED_ZONE", WERR_DNS_ERROR_NOT_ALLOWED_ON_UNSIGNED_ZONE },
      42             :         { "WERR_DNS_ERROR_KSP_DOES_NOT_SUPPORT_PROTECTION", WERR_DNS_ERROR_KSP_DOES_NOT_SUPPORT_PROTECTION },
      43             :         { "WERR_DNS_ERROR_BAD_KEYMASTER", WERR_DNS_ERROR_BAD_KEYMASTER },
      44             :         { "WERR_USER_APC", WERR_USER_APC },
      45             :         { "WERR_DNS_ERROR_UNEXPECTED_DATA_PROTECTION_ERROR", WERR_DNS_ERROR_UNEXPECTED_DATA_PROTECTION_ERROR },
      46             :         { "WERR_WAIT_2", WERR_WAIT_2 },
      47             :         { "WERR_WAIT_3", WERR_WAIT_3 },
      48             :         { "WERR_WAIT_1", WERR_WAIT_1 },
      49             :         { "WERR_DNS_ERROR_NSEC3_NAME_COLLISION", WERR_DNS_ERROR_NSEC3_NAME_COLLISION },
      50             :         { "WERR_DNS_ERROR_KSP_NOT_ACCESSIBLE", WERR_DNS_ERROR_KSP_NOT_ACCESSIBLE },
      51             :         { "WERR_DNS_ERROR_ROLLOVER_NOT_POKEABLE", WERR_DNS_ERROR_ROLLOVER_NOT_POKEABLE },
      52             :         { "WERR_DNS_ERROR_INVALID_KEY_SIZE", WERR_DNS_ERROR_INVALID_KEY_SIZE },
      53             :         { "WERR_DNS_ERROR_ROLLOVER_ALREADY_QUEUED", WERR_DNS_ERROR_ROLLOVER_ALREADY_QUEUED },
      54             :         { "WERR_DNS_ERROR_UNKNOWN_SIGNING_PARAMETER_VERSION", WERR_DNS_ERROR_UNKNOWN_SIGNING_PARAMETER_VERSION },
      55             :         { "WERR_DNS_ERROR_INVALID_INITIAL_ROLLOVER_OFFSET", WERR_DNS_ERROR_INVALID_INITIAL_ROLLOVER_OFFSET },
      56             :         { "WERR_DNS_ERROR_SIGNING_KEY_NOT_ACCESSIBLE", WERR_DNS_ERROR_SIGNING_KEY_NOT_ACCESSIBLE },
      57             :         { "WERR_DNS_REQUEST_PENDING", WERR_DNS_REQUEST_PENDING },
      58             :         { "WERR_LOG_HARD_ERROR", WERR_LOG_HARD_ERROR },
      59             :         { "WERR_DNS_ERROR_NOT_ALLOWED_ON_ZSK", WERR_DNS_ERROR_NOT_ALLOWED_ON_ZSK },
      60             :         { "WERR_OK", WERR_OK },
      61             :         { "WERR_DNS_ERROR_KEYMASTER_REQUIRED", WERR_DNS_ERROR_KEYMASTER_REQUIRED },
      62             :         { "WERR_STATUS_MORE_ENTRIES", WERR_STATUS_MORE_ENTRIES },
      63             :         { "WERR_DS_INVALID_ATTRIBUTE_SYNTAX", WERR_DS_INVALID_ATTRIBUTE_SYNTAX },
      64             :         { "WERR_ALERTED", WERR_ALERTED },
      65             :         { "WERR_DNS_ERROR_UNSUPPORTED_ALGORITHM", WERR_DNS_ERROR_UNSUPPORTED_ALGORITHM },
      66             :         { "WERR_DNS_ERROR_INVALID_NSEC3_ITERATION_COUNT", WERR_DNS_ERROR_INVALID_NSEC3_ITERATION_COUNT },
      67             :         { "WERR_DNS_ERROR_INVALID_XML", WERR_DNS_ERROR_INVALID_XML },
      68             :         { "WERR_DNS_ERROR_DELEGATION_REQUIRED", WERR_DNS_ERROR_DELEGATION_REQUIRED },
      69             :         { "WERR_ABANDONED_WAIT_63", WERR_ABANDONED_WAIT_63 },
      70             :         { "WERR_DNS_ERROR_UNEXPECTED_CNG_ERROR", WERR_DNS_ERROR_UNEXPECTED_CNG_ERROR },
      71             :         { "WERR_DNS_ERROR_DNAME_COLLISION", WERR_DNS_ERROR_DNAME_COLLISION },
      72             :         { "WERR_DNS_ERROR_INVALID_POLICY_TABLE", WERR_DNS_ERROR_INVALID_POLICY_TABLE },
      73             :         { "WERR_DNS_ERROR_NO_VALID_TRUST_ANCHORS", WERR_DNS_ERROR_NO_VALID_TRUST_ANCHORS },
      74             :         { "WERR_MULTIPLE_FAULT_VIOLATION", WERR_MULTIPLE_FAULT_VIOLATION },
      75             :         { "WERR_DNS_ERROR_INVALID_ROLLOVER_PERIOD", WERR_DNS_ERROR_INVALID_ROLLOVER_PERIOD },
      76             :         { "WERR_DNS_ERROR_INVALID_SIGNATURE_VALIDITY_PERIOD", WERR_DNS_ERROR_INVALID_SIGNATURE_VALIDITY_PERIOD },
      77             :         { "WERR_DNS_ERROR_NOT_ENOUGH_SIGNING_KEY_DESCRIPTORS", WERR_DNS_ERROR_NOT_ENOUGH_SIGNING_KEY_DESCRIPTORS },
      78             :         { "WERR_INVALID_PRIMARY_GROUP", WERR_INVALID_PRIMARY_GROUP },
      79             :         { "WERR_KERNEL_APC", WERR_KERNEL_APC },
      80             :         { "WERR_DNS_ERROR_NOT_ALLOWED_UNDER_DNAME", WERR_DNS_ERROR_NOT_ALLOWED_UNDER_DNAME },
      81             :         { "WERR_DNS_ERROR_TOO_MANY_SKDS", WERR_DNS_ERROR_TOO_MANY_SKDS },
      82             :         { "WERR_DNS_ERROR_NODE_IS_DNMAE", WERR_DNS_ERROR_NODE_IS_DNAME },
      83             :         { "WERR_DNS_ERROR_NODE_IS_DNAME", WERR_DNS_ERROR_NODE_IS_DNAME },
      84             :         { "WERR_SERVICE_NOTIFICATION", WERR_SERVICE_NOTIFICATION },
      85             :         { "WERR_WAIT_63", WERR_WAIT_63 },
      86             :         { "WERR_DNS_ERROR_STANDBY_KEY_NOT_PRESENT", WERR_DNS_ERROR_STANDBY_KEY_NOT_PRESENT },
      87             :         { "WERR_DNS_ERROR_ALIAS_LOOP", WERR_DNS_ERROR_ALIAS_LOOP },
      88             :         { "WERR_DNS_ERROR_ROLLOVER_IN_PROGRESS", WERR_DNS_ERROR_ROLLOVER_IN_PROGRESS },
      89             :         { "WERR_DNS_ERROR_NOT_ALLOWED_ON_SIGNED_ZONE", WERR_DNS_ERROR_NOT_ALLOWED_ON_SIGNED_ZONE },
      90             :         { 0, W_ERROR(0) }
      91             : };
      92             : 
      93             : /*****************************************************************************
      94             :  returns a windows error message.  not amazingly helpful, but better than a number.
      95             :  *****************************************************************************/
      96       18875 : const char *win_errstr(WERROR werror)
      97             : {
      98             :         static char msg[40];
      99       18875 :         int idx = 0;
     100             : 
     101      842819 :         while (special_errs[idx].dos_errstr != NULL) {
     102     1494560 :                 if (W_ERROR_V(special_errs[idx].werror) ==
     103      776057 :                     W_ERROR_V(werror))
     104        5535 :                         return special_errs[idx].dos_errstr;
     105      807380 :                 idx++;
     106             :         }
     107             : 
     108       12476 :         idx = 0;
     109             : 
     110     2952454 :         while (dos_errs[idx].dos_errstr != NULL) {
     111     5304610 :                 if (W_ERROR_V(dos_errs[idx].werror) ==
     112     2890382 :                     W_ERROR_V(werror))
     113       12424 :                         return dos_errs[idx].dos_errstr;
     114     2928339 :                 idx++;
     115             :         }
     116             : 
     117          58 :         slprintf(msg, sizeof(msg), "DOS code 0x%08x", W_ERROR_V(werror));
     118             : 
     119          55 :         return msg;
     120             : }
     121             : 
     122             : /*****************************************************************************
     123             :  Get friendly error string for WERRORs
     124             :  *****************************************************************************/
     125             : 
     126           9 : const char *get_friendly_werror_msg(WERROR werror)
     127             : {
     128           9 :         size_t i = 0;
     129             : 
     130         282 :         for (i = 0; i < ARRAY_SIZE(dos_err_strs); i++) {
     131         564 :                 if (W_ERROR_V(dos_err_strs[i].werror) ==
     132         282 :                     W_ERROR_V(werror)) {
     133           9 :                         return dos_err_strs[i].friendly_errstr;
     134             :                 }
     135             :         }
     136             : 
     137           0 :         return win_errstr(werror);
     138             : }

Generated by: LCOV version 1.13