Changeset 988 for vendor/current/libcli


Ignore:
Timestamp:
Nov 24, 2016, 1:14:11 PM (9 years ago)
Author:
Silvan Scherrer
Message:

Samba Server: update vendor to version 4.4.3

Location:
vendor/current/libcli
Files:
60 added
13 deleted
77 edited

Legend:

Unmodified
Added
Removed
  • vendor/current/libcli/auth/credentials.c

    r746 r988  
    1 /* 
     1/*
    22   Unix SMB/CIFS implementation.
    33
     
    66   Copyright (C) Andrew Tridgell 1997-2003
    77   Copyright (C) Andrew Bartlett <abartlet@samba.org> 2004
    8    
     8
    99   This program is free software; you can redistribute it and/or modify
    1010   it under the terms of the GNU General Public License as published by
    1111   the Free Software Foundation; either version 3 of the License, or
    1212   (at your option) any later version.
    13    
     13
    1414   This program is distributed in the hope that it will be useful,
    1515   but WITHOUT ANY WARRANTY; without even the implied warranty of
    1616   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    1717   GNU General Public License for more details.
    18    
     18
    1919   You should have received a copy of the GNU General Public License
    2020   along with this program.  If not, see <http://www.gnu.org/licenses/>.
     
    3131                                      struct netr_Credential *out)
    3232{
    33         des_crypt112(out->data, in->data, creds->session_key, 1);
     33        if (creds->negotiate_flags & NETLOGON_NEG_SUPPORTS_AES) {
     34                AES_KEY key;
     35                uint8_t iv[AES_BLOCK_SIZE];
     36
     37                AES_set_encrypt_key(creds->session_key, 128, &key);
     38                ZERO_STRUCT(iv);
     39
     40                aes_cfb8_encrypt(in->data, out->data, 8, &key, iv, AES_ENCRYPT);
     41        } else {
     42                des_crypt112(out->data, in->data, creds->session_key, 1);
     43        }
    3444}
    3545
     
    7686        memset(zero, 0, sizeof(zero));
    7787
    78         hmac_md5_init_rfc2104(machine_password->hash, sizeof(machine_password->hash), &ctx);   
     88        hmac_md5_init_rfc2104(machine_password->hash, sizeof(machine_password->hash), &ctx);
    7989        MD5Init(&md5);
    8090        MD5Update(&md5, zero, sizeof(zero));
     
    8696}
    8797
     98/*
     99  initialise the credentials state for AES/HMAC-SHA256-style 128 bit session keys
     100
     101  this call is made after the netr_ServerReqChallenge call
     102*/
     103static void netlogon_creds_init_hmac_sha256(struct netlogon_creds_CredentialState *creds,
     104                                            const struct netr_Credential *client_challenge,
     105                                            const struct netr_Credential *server_challenge,
     106                                            const struct samr_Password *machine_password)
     107{
     108        struct HMACSHA256Context ctx;
     109        uint8_t digest[SHA256_DIGEST_LENGTH];
     110
     111        ZERO_STRUCT(creds->session_key);
     112
     113        hmac_sha256_init(machine_password->hash,
     114                         sizeof(machine_password->hash),
     115                         &ctx);
     116        hmac_sha256_update(client_challenge->data, 8, &ctx);
     117        hmac_sha256_update(server_challenge->data, 8, &ctx);
     118        hmac_sha256_final(digest, &ctx);
     119
     120        memcpy(creds->session_key, digest, sizeof(creds->session_key));
     121
     122        ZERO_STRUCT(digest);
     123        ZERO_STRUCT(ctx);
     124}
     125
    88126static void netlogon_creds_first_step(struct netlogon_creds_CredentialState *creds,
    89127                                      const struct netr_Credential *client_challenge,
     
    105143        struct netr_Credential time_cred;
    106144
    107         DEBUG(5,("\tseed        %08x:%08x\n", 
     145        DEBUG(5,("\tseed        %08x:%08x\n",
    108146                 IVAL(creds->seed.data, 0), IVAL(creds->seed.data, 4)));
    109147
     
    115153        netlogon_creds_step_crypt(creds, &time_cred, &creds->client);
    116154
    117         DEBUG(5,("\tCLIENT      %08x:%08x\n", 
     155        DEBUG(5,("\tCLIENT      %08x:%08x\n",
    118156                 IVAL(creds->client.data, 0), IVAL(creds->client.data, 4)));
    119157
     
    121159        SIVAL(time_cred.data, 4, IVAL(creds->seed.data, 4));
    122160
    123         DEBUG(5,("\tseed+time+1 %08x:%08x\n", 
     161        DEBUG(5,("\tseed+time+1 %08x:%08x\n",
    124162                 IVAL(time_cred.data, 0), IVAL(time_cred.data, 4)));
    125163
    126164        netlogon_creds_step_crypt(creds, &time_cred, &creds->server);
    127165
    128         DEBUG(5,("\tSERVER      %08x:%08x\n", 
     166        DEBUG(5,("\tSERVER      %08x:%08x\n",
    129167                 IVAL(creds->server.data, 0), IVAL(creds->server.data, 4)));
    130168
     
    183221
    184222        data_blob_free(&session_key);
     223}
     224
     225/*
     226  AES encrypt a password buffer using the session key
     227*/
     228void netlogon_creds_aes_encrypt(struct netlogon_creds_CredentialState *creds, uint8_t *data, size_t len)
     229{
     230        AES_KEY key;
     231        uint8_t iv[AES_BLOCK_SIZE];
     232
     233        AES_set_encrypt_key(creds->session_key, 128, &key);
     234        ZERO_STRUCT(iv);
     235
     236        aes_cfb8_encrypt(data, data, len, &key, iv, AES_ENCRYPT);
     237}
     238
     239/*
     240  AES decrypt a password buffer using the session key
     241*/
     242void netlogon_creds_aes_decrypt(struct netlogon_creds_CredentialState *creds, uint8_t *data, size_t len)
     243{
     244        AES_KEY key;
     245        uint8_t iv[AES_BLOCK_SIZE];
     246
     247        AES_set_encrypt_key(creds->session_key, 128, &key);
     248        ZERO_STRUCT(iv);
     249
     250        aes_cfb8_encrypt(data, data, len, &key, iv, AES_DECRYPT);
    185251}
    186252
     
    194260  credentials
    195261*/
    196  
    197 struct netlogon_creds_CredentialState *netlogon_creds_client_init(TALLOC_CTX *mem_ctx, 
     262
     263struct netlogon_creds_CredentialState *netlogon_creds_client_init(TALLOC_CTX *mem_ctx,
    198264                                                                  const char *client_account,
    199                                                                   const char *client_computer_name,
     265                                                                  const char *client_computer_name,
     266                                                                  uint16_t secure_channel_type,
    200267                                                                  const struct netr_Credential *client_challenge,
    201268                                                                  const struct netr_Credential *server_challenge,
     
    205272{
    206273        struct netlogon_creds_CredentialState *creds = talloc_zero(mem_ctx, struct netlogon_creds_CredentialState);
    207        
     274
    208275        if (!creds) {
    209276                return NULL;
    210277        }
    211        
     278
    212279        creds->sequence = time(NULL);
    213280        creds->negotiate_flags = negotiate_flags;
     281        creds->secure_channel_type = secure_channel_type;
    214282
    215283        creds->computer_name = talloc_strdup(creds, client_computer_name);
     
    228296        dump_data_pw("Machine Pass", machine_password->hash, sizeof(machine_password->hash));
    229297
    230         if (negotiate_flags & NETLOGON_NEG_128BIT) {
     298        if (negotiate_flags & NETLOGON_NEG_SUPPORTS_AES) {
     299                netlogon_creds_init_hmac_sha256(creds,
     300                                                client_challenge,
     301                                                server_challenge,
     302                                                machine_password);
     303        } else if (negotiate_flags & NETLOGON_NEG_STRONG_KEYS) {
    231304                netlogon_creds_init_128bit(creds, client_challenge, server_challenge, machine_password);
    232305        } else {
     
    247320 */
    248321
    249 struct netlogon_creds_CredentialState *netlogon_creds_client_init_session_key(TALLOC_CTX *mem_ctx, 
     322struct netlogon_creds_CredentialState *netlogon_creds_client_init_session_key(TALLOC_CTX *mem_ctx,
    250323                                                                              const uint8_t session_key[16])
    251324{
     
    256329                return NULL;
    257330        }
    258        
     331
    259332        memcpy(creds->session_key, session_key, 16);
    260333
     
    266339  current client and server credentials and the seed
    267340
    268   produce the next authenticator in the sequence ready to send to 
     341  produce the next authenticator in the sequence ready to send to
    269342  the server
    270343*/
    271344void netlogon_creds_client_authenticator(struct netlogon_creds_CredentialState *creds,
    272345                                struct netr_Authenticator *next)
    273 {       
     346{
     347        uint32_t t32n = (uint32_t)time(NULL);
     348
     349        /*
     350         * we always increment and ignore an overflow here
     351         */
    274352        creds->sequence += 2;
     353
     354        if (t32n > creds->sequence) {
     355                /*
     356                 * we may increment more
     357                 */
     358                creds->sequence = t32n;
     359        } else {
     360                uint32_t d = creds->sequence - t32n;
     361
     362                if (d >= INT32_MAX) {
     363                        /*
     364                         * got an overflow of time_t vs. uint32_t
     365                         */
     366                        creds->sequence = t32n;
     367                }
     368        }
     369
    275370        netlogon_creds_step(creds);
    276371
     
    285380                        const struct netr_Credential *received_credentials)
    286381{
    287         if (!received_credentials || 
     382        if (!received_credentials ||
    288383            memcmp(received_credentials->data, creds->server.data, 8) != 0) {
    289384                DEBUG(2,("credentials check failed\n"));
     
    318413  credentials
    319414*/
    320 struct netlogon_creds_CredentialState *netlogon_creds_server_init(TALLOC_CTX *mem_ctx, 
     415struct netlogon_creds_CredentialState *netlogon_creds_server_init(TALLOC_CTX *mem_ctx,
    321416                                                                  const char *client_account,
    322                                                                   const char *client_computer_name, 
     417                                                                  const char *client_computer_name,
    323418                                                                  uint16_t secure_channel_type,
    324419                                                                  const struct netr_Credential *client_challenge,
    325420                                                                  const struct netr_Credential *server_challenge,
    326421                                                                  const struct samr_Password *machine_password,
    327                                                                   struct netr_Credential *credentials_in,
     422                                                                  const struct netr_Credential *credentials_in,
    328423                                                                  struct netr_Credential *credentials_out,
    329424                                                                  uint32_t negotiate_flags)
    330425{
    331        
     426
    332427        struct netlogon_creds_CredentialState *creds = talloc_zero(mem_ctx, struct netlogon_creds_CredentialState);
    333        
     428
    334429        if (!creds) {
    335430                return NULL;
    336431        }
    337        
     432
    338433        creds->negotiate_flags = negotiate_flags;
    339434        creds->secure_channel_type = secure_channel_type;
     435
     436        dump_data_pw("Client chall", client_challenge->data, sizeof(client_challenge->data));
     437        dump_data_pw("Server chall", server_challenge->data, sizeof(server_challenge->data));
     438        dump_data_pw("Machine Pass", machine_password->hash, sizeof(machine_password->hash));
    340439
    341440        creds->computer_name = talloc_strdup(creds, client_computer_name);
     
    350449        }
    351450
    352         if (negotiate_flags & NETLOGON_NEG_128BIT) {
    353                 netlogon_creds_init_128bit(creds, client_challenge, server_challenge,
     451        if (negotiate_flags & NETLOGON_NEG_SUPPORTS_AES) {
     452                netlogon_creds_init_hmac_sha256(creds,
     453                                                client_challenge,
     454                                                server_challenge,
     455                                                machine_password);
     456        } else if (negotiate_flags & NETLOGON_NEG_STRONG_KEYS) {
     457                netlogon_creds_init_128bit(creds, client_challenge, server_challenge,
    354458                                           machine_password);
    355459        } else {
    356                 netlogon_creds_init_64bit(creds, client_challenge, server_challenge, 
     460                netlogon_creds_init_64bit(creds, client_challenge, server_challenge,
    357461                                          machine_password);
    358462        }
    359463
    360464        netlogon_creds_first_step(creds, client_challenge, server_challenge);
     465
     466        dump_data_pw("Session key", creds->session_key, 16);
     467        dump_data_pw("Client Credential ", creds->client.data, 8);
     468        dump_data_pw("Server Credential ", creds->server.data, 8);
     469
     470        dump_data_pw("Credentials in", credentials_in->data, sizeof(credentials_in->data));
    361471
    362472        /* And before we leak information about the machine account
     
    369479        *credentials_out = creds->server;
    370480
     481        dump_data_pw("Credentials out", credentials_out->data, sizeof(credentials_out->data));
     482
    371483        return creds;
    372484}
    373485
    374486NTSTATUS netlogon_creds_server_step_check(struct netlogon_creds_CredentialState *creds,
    375                                  struct netr_Authenticator *received_authenticator,
    376                                  struct netr_Authenticator *return_authenticator) 
     487                                 const struct netr_Authenticator *received_authenticator,
     488                                 struct netr_Authenticator *return_authenticator)
    377489{
    378490        if (!received_authenticator || !return_authenticator) {
     
    384496        }
    385497
    386         /* TODO: this may allow the a replay attack on a non-signed
    387            connection. Should we check that this is increasing? */
    388498        creds->sequence = received_authenticator->timestamp;
    389499        netlogon_creds_step(creds);
    390500        if (netlogon_creds_server_check_internal(creds, &received_authenticator->cred)) {
    391501                return_authenticator->cred = creds->server;
    392                 return_authenticator->timestamp = creds->sequence;
     502                return_authenticator->timestamp = 0;
    393503                return NT_STATUS_OK;
    394504        } else {
     
    398508}
    399509
    400 void netlogon_creds_decrypt_samlogon(struct netlogon_creds_CredentialState *creds,
    401                             uint16_t validation_level,
    402                             union netr_Validation *validation)
     510static void netlogon_creds_crypt_samlogon_validation(struct netlogon_creds_CredentialState *creds,
     511                                                     uint16_t validation_level,
     512                                                     union netr_Validation *validation,
     513                                                     bool do_encrypt)
    403514{
    404515        static const char zeros[16];
    405 
    406516        struct netr_SamBaseInfo *base = NULL;
     517
     518        if (validation == NULL) {
     519                return;
     520        }
     521
    407522        switch (validation_level) {
    408523        case 2:
     
    433548        if (validation_level == 6) {
    434549                /* they aren't encrypted! */
     550        } else if (creds->negotiate_flags & NETLOGON_NEG_SUPPORTS_AES) {
     551                /* Don't crypt an all-zero key, it would give away the NETLOGON pipe session key */
     552                if (memcmp(base->key.key, zeros,
     553                           sizeof(base->key.key)) != 0) {
     554                        if (do_encrypt) {
     555                                netlogon_creds_aes_encrypt(creds,
     556                                            base->key.key,
     557                                            sizeof(base->key.key));
     558                        } else {
     559                                netlogon_creds_aes_decrypt(creds,
     560                                            base->key.key,
     561                                            sizeof(base->key.key));
     562                        }
     563                }
     564
     565                if (memcmp(base->LMSessKey.key, zeros,
     566                           sizeof(base->LMSessKey.key)) != 0) {
     567                        if (do_encrypt) {
     568                                netlogon_creds_aes_encrypt(creds,
     569                                            base->LMSessKey.key,
     570                                            sizeof(base->LMSessKey.key));
     571
     572                        } else {
     573                                netlogon_creds_aes_decrypt(creds,
     574                                            base->LMSessKey.key,
     575                                            sizeof(base->LMSessKey.key));
     576                        }
     577                }
    435578        } else if (creds->negotiate_flags & NETLOGON_NEG_ARCFOUR) {
    436                 if (memcmp(base->key.key, zeros, 
     579                /* Don't crypt an all-zero key, it would give away the NETLOGON pipe session key */
     580                if (memcmp(base->key.key, zeros,
    437581                           sizeof(base->key.key)) != 0) {
    438                         netlogon_creds_arcfour_crypt(creds, 
    439                                             base->key.key, 
     582                        netlogon_creds_arcfour_crypt(creds,
     583                                            base->key.key,
    440584                                            sizeof(base->key.key));
    441585                }
    442                        
    443                 if (memcmp(base->LMSessKey.key, zeros, 
     586
     587                if (memcmp(base->LMSessKey.key, zeros,
    444588                           sizeof(base->LMSessKey.key)) != 0) {
    445                         netlogon_creds_arcfour_crypt(creds, 
    446                                             base->LMSessKey.key, 
     589                        netlogon_creds_arcfour_crypt(creds,
     590                                            base->LMSessKey.key,
    447591                                            sizeof(base->LMSessKey.key));
    448592                }
    449593        } else {
    450                 if (memcmp(base->LMSessKey.key, zeros, 
     594                /* Don't crypt an all-zero key, it would give away the NETLOGON pipe session key */
     595                if (memcmp(base->LMSessKey.key, zeros,
    451596                           sizeof(base->LMSessKey.key)) != 0) {
    452                         netlogon_creds_des_decrypt_LMKey(creds,
     597                        if (do_encrypt) {
     598                                netlogon_creds_des_encrypt_LMKey(creds,
    453599                                                &base->LMSessKey);
    454                 }
    455         }
    456 }       
     600                        } else {
     601                                netlogon_creds_des_decrypt_LMKey(creds,
     602                                                &base->LMSessKey);
     603                        }
     604                }
     605        }
     606}
     607
     608void netlogon_creds_decrypt_samlogon_validation(struct netlogon_creds_CredentialState *creds,
     609                                                uint16_t validation_level,
     610                                                union netr_Validation *validation)
     611{
     612        netlogon_creds_crypt_samlogon_validation(creds, validation_level,
     613                                                        validation, false);
     614}
     615
     616void netlogon_creds_encrypt_samlogon_validation(struct netlogon_creds_CredentialState *creds,
     617                                                uint16_t validation_level,
     618                                                union netr_Validation *validation)
     619{
     620        netlogon_creds_crypt_samlogon_validation(creds, validation_level,
     621                                                        validation, true);
     622}
     623
     624static void netlogon_creds_crypt_samlogon_logon(struct netlogon_creds_CredentialState *creds,
     625                                                enum netr_LogonInfoClass level,
     626                                                union netr_LogonLevel *logon,
     627                                                bool do_encrypt)
     628{
     629        static const char zeros[16];
     630
     631        if (logon == NULL) {
     632                return;
     633        }
     634
     635        switch (level) {
     636        case NetlogonInteractiveInformation:
     637        case NetlogonInteractiveTransitiveInformation:
     638        case NetlogonServiceInformation:
     639        case NetlogonServiceTransitiveInformation:
     640                if (logon->password == NULL) {
     641                        return;
     642                }
     643
     644                if (creds->negotiate_flags & NETLOGON_NEG_SUPPORTS_AES) {
     645                        uint8_t *h;
     646
     647                        h = logon->password->lmpassword.hash;
     648                        if (memcmp(h, zeros, 16) != 0) {
     649                                if (do_encrypt) {
     650                                        netlogon_creds_aes_encrypt(creds, h, 16);
     651                                } else {
     652                                        netlogon_creds_aes_decrypt(creds, h, 16);
     653                                }
     654                        }
     655
     656                        h = logon->password->ntpassword.hash;
     657                        if (memcmp(h, zeros, 16) != 0) {
     658                                if (do_encrypt) {
     659                                        netlogon_creds_aes_encrypt(creds, h, 16);
     660                                } else {
     661                                        netlogon_creds_aes_decrypt(creds, h, 16);
     662                                }
     663                        }
     664                } else if (creds->negotiate_flags & NETLOGON_NEG_ARCFOUR) {
     665                        uint8_t *h;
     666
     667                        h = logon->password->lmpassword.hash;
     668                        if (memcmp(h, zeros, 16) != 0) {
     669                                netlogon_creds_arcfour_crypt(creds, h, 16);
     670                        }
     671
     672                        h = logon->password->ntpassword.hash;
     673                        if (memcmp(h, zeros, 16) != 0) {
     674                                netlogon_creds_arcfour_crypt(creds, h, 16);
     675                        }
     676                } else {
     677                        struct samr_Password *p;
     678
     679                        p = &logon->password->lmpassword;
     680                        if (memcmp(p->hash, zeros, 16) != 0) {
     681                                if (do_encrypt) {
     682                                        netlogon_creds_des_encrypt(creds, p);
     683                                } else {
     684                                        netlogon_creds_des_decrypt(creds, p);
     685                                }
     686                        }
     687                        p = &logon->password->ntpassword;
     688                        if (memcmp(p->hash, zeros, 16) != 0) {
     689                                if (do_encrypt) {
     690                                        netlogon_creds_des_encrypt(creds, p);
     691                                } else {
     692                                        netlogon_creds_des_decrypt(creds, p);
     693                                }
     694                        }
     695                }
     696                break;
     697
     698        case NetlogonNetworkInformation:
     699        case NetlogonNetworkTransitiveInformation:
     700                break;
     701
     702        case NetlogonGenericInformation:
     703                if (logon->generic == NULL) {
     704                        return;
     705                }
     706
     707                if (creds->negotiate_flags & NETLOGON_NEG_SUPPORTS_AES) {
     708                        if (do_encrypt) {
     709                                netlogon_creds_aes_encrypt(creds,
     710                                                logon->generic->data,
     711                                                logon->generic->length);
     712                        } else {
     713                                netlogon_creds_aes_decrypt(creds,
     714                                                logon->generic->data,
     715                                                logon->generic->length);
     716                        }
     717                } else if (creds->negotiate_flags & NETLOGON_NEG_ARCFOUR) {
     718                        netlogon_creds_arcfour_crypt(creds,
     719                                                     logon->generic->data,
     720                                                     logon->generic->length);
     721                } else {
     722                        /* Using DES to verify kerberos tickets makes no sense */
     723                }
     724                break;
     725        }
     726}
     727
     728void netlogon_creds_decrypt_samlogon_logon(struct netlogon_creds_CredentialState *creds,
     729                                           enum netr_LogonInfoClass level,
     730                                           union netr_LogonLevel *logon)
     731{
     732        netlogon_creds_crypt_samlogon_logon(creds, level, logon, false);
     733}
     734
     735void netlogon_creds_encrypt_samlogon_logon(struct netlogon_creds_CredentialState *creds,
     736                                           enum netr_LogonInfoClass level,
     737                                           union netr_LogonLevel *logon)
     738{
     739        netlogon_creds_crypt_samlogon_logon(creds, level, logon, true);
     740}
     741
     742union netr_LogonLevel *netlogon_creds_shallow_copy_logon(TALLOC_CTX *mem_ctx,
     743                                        enum netr_LogonInfoClass level,
     744                                        const union netr_LogonLevel *in)
     745{
     746        union netr_LogonLevel *out;
     747
     748        if (in == NULL) {
     749                return NULL;
     750        }
     751
     752        out = talloc(mem_ctx, union netr_LogonLevel);
     753        if (out == NULL) {
     754                return NULL;
     755        }
     756
     757        *out = *in;
     758
     759        switch (level) {
     760        case NetlogonInteractiveInformation:
     761        case NetlogonInteractiveTransitiveInformation:
     762        case NetlogonServiceInformation:
     763        case NetlogonServiceTransitiveInformation:
     764                if (in->password == NULL) {
     765                        return out;
     766                }
     767
     768                out->password = talloc(out, struct netr_PasswordInfo);
     769                if (out->password == NULL) {
     770                        talloc_free(out);
     771                        return NULL;
     772                }
     773                *out->password = *in->password;
     774
     775                return out;
     776
     777        case NetlogonNetworkInformation:
     778        case NetlogonNetworkTransitiveInformation:
     779                break;
     780
     781        case NetlogonGenericInformation:
     782                if (in->generic == NULL) {
     783                        return out;
     784                }
     785
     786                out->generic = talloc(out, struct netr_GenericInfo);
     787                if (out->generic == NULL) {
     788                        talloc_free(out);
     789                        return NULL;
     790                }
     791                *out->generic = *in->generic;
     792
     793                if (in->generic->data == NULL) {
     794                        return out;
     795                }
     796
     797                if (in->generic->length == 0) {
     798                        return out;
     799                }
     800
     801                out->generic->data = talloc_memdup(out->generic,
     802                                                   in->generic->data,
     803                                                   in->generic->length);
     804                if (out->generic->data == NULL) {
     805                        talloc_free(out);
     806                        return NULL;
     807                }
     808
     809                return out;
     810        }
     811
     812        return out;
     813}
    457814
    458815/*
  • vendor/current/libcli/auth/credentials.h

    r740 r988  
    6969#define NETLOGON_NEG_AUTH2_ADS_FLAGS (0x200fbffb | NETLOGON_NEG_ARCFOUR | NETLOGON_NEG_128BIT | NETLOGON_NEG_SCHANNEL)
    7070
    71 #define NETLOGON_NEG_AUTH2_RODC_FLAGS (NETLOGON_NEG_AUTH2_ADS_FLAGS | NETLOGON_NEG_RODC_PASSTHROUGH)
    72 
  • vendor/current/libcli/auth/msrpc_parse.c

    r740 r988  
    7979                        if (!ret) {
    8080                                va_end(ap);
    81                                 return map_nt_error_from_unix(errno);
     81                                return map_nt_error_from_unix_common(errno);
    8282                        }
    8383                        pointers[i].length = n;
     
    9393                        if (!ret) {
    9494                                va_end(ap);
    95                                 return map_nt_error_from_unix(errno);
     95                                return map_nt_error_from_unix_common(errno);
    9696                        }
    9797                        pointers[i].length = n;
     
    109109                        if (!ret) {
    110110                                va_end(ap);
    111                                 return map_nt_error_from_unix(errno);
     111                                return map_nt_error_from_unix_common(errno);
    112112                        }
    113113                        pointers[i].length = n;
     
    178178                        n = pointers[i].length;
    179179                        SSVAL(blob->data, data_ofs, n); data_ofs += 2;
    180                         if (n >= 0) {
    181                                 memcpy(blob->data+data_ofs, pointers[i].data, n);
    182                         }
     180                        memcpy(blob->data+data_ofs, pointers[i].data, n);
    183181                        data_ofs += n;
    184182                        break;
     
    287285                                        if (!convert_string_talloc(mem_ctx, CH_UTF16, CH_UNIX,
    288286                                                                   blob->data + ptr, len1,
    289                                                                    ps, &pull_len, false)) {
     287                                                                   ps, &pull_len)) {
    290288                                                ret = false;
    291289                                                goto cleanup;
     
    323321                                        if (!convert_string_talloc(mem_ctx, CH_DOS, CH_UNIX,
    324322                                                                   blob->data + ptr, len1,
    325                                                                    ps, &pull_len, false)) {
     323                                                                   ps, &pull_len)) {
    326324                                                ret = false;
    327325                                                goto cleanup;
  • vendor/current/libcli/auth/ntlm_check.c

    r746 r988  
    321321                char *unix_pw = NULL;
    322322                bool lm_ok;
     323                size_t converted_size = 0;
    323324
    324325                DEBUG(4,("ntlm_password_check: checking plaintext passwords for user %s\n",
     
    329330                    (convert_string_talloc(mem_ctx, CH_DOS, CH_UNIX,
    330331                                          lm_response->data, lm_response->length,
    331                                            (void *)&unix_pw, NULL, false))) {
     332                                           (void *)&unix_pw, &converted_size))) {
    332333                        if (E_deshash(unix_pw, client_lm.hash)) {
    333334                                lm_ok = true;
     
    485486                                 &tmp_sess_key)) {
    486487                if (nt_response->length > 24) {
    487                         /* If NTLMv2 authentication has preceeded us
     488                        /* If NTLMv2 authentication has preceded us
    488489                         * (even if it failed), then use the session
    489490                         * key from that.  See the RPC-SAMLOGON
     
    514515                                 &tmp_sess_key)) {
    515516                if (nt_response->length > 24) {
    516                         /* If NTLMv2 authentication has preceeded us
     517                        /* If NTLMv2 authentication has preceded us
    517518                         * (even if it failed), then use the session
    518519                         * key from that.  See the RPC-SAMLOGON
     
    542543                                 &tmp_sess_key)) {
    543544                if (nt_response->length > 24) {
    544                         /* If NTLMv2 authentication has preceeded us
     545                        /* If NTLMv2 authentication has preceded us
    545546                         * (even if it failed), then use the session
    546547                         * key from that.  See the RPC-SAMLOGON
  • vendor/current/libcli/auth/proto.h

    r919 r988  
    1717void netlogon_creds_des_decrypt(struct netlogon_creds_CredentialState *creds, struct samr_Password *pass);
    1818void netlogon_creds_arcfour_crypt(struct netlogon_creds_CredentialState *creds, uint8_t *data, size_t len);
     19void netlogon_creds_aes_encrypt(struct netlogon_creds_CredentialState *creds, uint8_t *data, size_t len);
     20void netlogon_creds_aes_decrypt(struct netlogon_creds_CredentialState *creds, uint8_t *data, size_t len);
    1921
    2022/*****************************************************************
     
    2527                                                                  const char *client_account,
    2628                                                                  const char *client_computer_name,
     29                                                                  uint16_t secure_channel_type,
    2730                                                                  const struct netr_Credential *client_challenge,
    2831                                                                  const struct netr_Credential *server_challenge,
     
    5053                                                                  const struct netr_Credential *server_challenge,
    5154                                                                  const struct samr_Password *machine_password,
    52                                                                   struct netr_Credential *credentials_in,
     55                                                                  const struct netr_Credential *credentials_in,
    5356                                                                  struct netr_Credential *credentials_out,
    5457                                                                  uint32_t negotiate_flags);
    5558NTSTATUS netlogon_creds_server_step_check(struct netlogon_creds_CredentialState *creds,
    56                                  struct netr_Authenticator *received_authenticator,
     59                                 const struct netr_Authenticator *received_authenticator,
    5760                                 struct netr_Authenticator *return_authenticator) ;
    58 void netlogon_creds_decrypt_samlogon(struct netlogon_creds_CredentialState *creds,
    59                             uint16_t validation_level,
    60                             union netr_Validation *validation) ;
     61void netlogon_creds_decrypt_samlogon_validation(struct netlogon_creds_CredentialState *creds,
     62                                                uint16_t validation_level,
     63                                                union netr_Validation *validation);
     64void netlogon_creds_encrypt_samlogon_validation(struct netlogon_creds_CredentialState *creds,
     65                                                uint16_t validation_level,
     66                                                union netr_Validation *validation);
     67void netlogon_creds_decrypt_samlogon_logon(struct netlogon_creds_CredentialState *creds,
     68                                           enum netr_LogonInfoClass level,
     69                                           union netr_LogonLevel *logon);
     70void netlogon_creds_encrypt_samlogon_logon(struct netlogon_creds_CredentialState *creds,
     71                                           enum netr_LogonInfoClass level,
     72                                           union netr_LogonLevel *logon);
     73union netr_LogonLevel *netlogon_creds_shallow_copy_logon(TALLOC_CTX *mem_ctx,
     74                                        enum netr_LogonInfoClass level,
     75                                        const union netr_LogonLevel *in);
    6176
    6277/* The following definitions come from /home/jeremy/src/samba/git/master/source3/../source4/../libcli/auth/session.c  */
     
    112127                  uint8_t kr_buf[16]);
    113128void SMBOWFencrypt(const uint8_t passwd[16], const uint8_t *c8, uint8_t p24[24]);
    114 void SMBNTencrypt_hash(const uint8_t nt_hash[16], uint8_t *c8, uint8_t *p24);
    115 void SMBNTencrypt(const char *passwd, uint8_t *c8, uint8_t *p24);
     129void SMBNTencrypt_hash(const uint8_t nt_hash[16], const uint8_t *c8, uint8_t *p24);
     130void SMBNTencrypt(const char *passwd, const uint8_t *c8, uint8_t *p24);
    116131void SMBOWFencrypt_ntv2(const uint8_t kr[16],
    117132                        const DATA_BLOB *srv_chal,
     
    130145                           const char *user, const char *domain, const uint8_t nt_hash[16],
    131146                           const DATA_BLOB *server_chal,
     147                           const NTTIME *server_timestamp,
    132148                           const DATA_BLOB *names_blob,
    133149                           DATA_BLOB *lm_response, DATA_BLOB *nt_response,
     
    180196bool extract_pw_from_buffer(TALLOC_CTX *mem_ctx,
    181197                            uint8_t in_buffer[516], DATA_BLOB *new_pass);
     198struct wkssvc_PasswordBuffer;
    182199void encode_wkssvc_join_password_buffer(TALLOC_CTX *mem_ctx,
    183200                                        const char *pwd,
  • vendor/current/libcli/auth/schannel.h

    r414 r988  
    2323#include "libcli/auth/libcli_auth.h"
    2424#include "libcli/auth/schannel_state.h"
    25 
    26 enum schannel_position {
    27         SCHANNEL_STATE_START = 0,
    28         SCHANNEL_STATE_UPDATE_1
    29 };
    30 
    31 struct schannel_state {
    32         enum schannel_position state;
    33         uint32_t seq_num;
    34         bool initiator;
    35         struct netlogon_creds_CredentialState *creds;
    36 };
    37 
    3825#include "libcli/auth/schannel_proto.h"
  • vendor/current/libcli/auth/schannel_proto.h

    r740 r988  
    2626struct schannel_state;
    2727
    28 struct tdb_wrap *open_schannel_session_store(TALLOC_CTX *mem_ctx,
    29                                              const char *private_dir);
    30 
    31 NTSTATUS netsec_incoming_packet(struct schannel_state *state,
    32                                 TALLOC_CTX *mem_ctx,
    33                                 bool do_unseal,
    34                                 uint8_t *data, size_t length,
    35                                 const DATA_BLOB *sig);
    36 uint32_t netsec_outgoing_sig_size(struct schannel_state *state);
    37 NTSTATUS netsec_outgoing_packet(struct schannel_state *state,
    38                                 TALLOC_CTX *mem_ctx,
    39                                 bool do_seal,
    40                                 uint8_t *data, size_t length,
    41                                 DATA_BLOB *sig);
     28struct db_context *open_schannel_session_store(TALLOC_CTX *mem_ctx,
     29                                               struct loadparm_context *lp_ctx);
    4230
    4331#endif
  • vendor/current/libcli/auth/schannel_state.h

    r740 r988  
    2525
    2626NTSTATUS schannel_get_creds_state(TALLOC_CTX *mem_ctx,
    27                                   const char *db_priv_dir,
     27                                  struct loadparm_context *lp_ctx,
    2828                                  const char *computer_name,
    2929                                  struct netlogon_creds_CredentialState **creds);
    3030
    3131NTSTATUS schannel_save_creds_state(TALLOC_CTX *mem_ctx,
    32                                    const char *db_priv_dir,
     32                                   struct loadparm_context *lp_ctx,
    3333                                   struct netlogon_creds_CredentialState *creds);
    3434
    3535NTSTATUS schannel_check_creds_state(TALLOC_CTX *mem_ctx,
    36                                     const char *db_priv_dir,
     36                                    struct loadparm_context *lp_ctx,
    3737                                    const char *computer_name,
    3838                                    struct netr_Authenticator *received_authenticator,
  • vendor/current/libcli/auth/schannel_state_tdb.c

    r914 r988  
    2424#include "includes.h"
    2525#include "system/filesys.h"
    26 #include <tdb.h>
     26#include "../lib/tdb/include/tdb.h"
    2727#include "../lib/util/util_tdb.h"
     28#include "../lib/param/param.h"
    2829#include "../libcli/auth/schannel.h"
    2930#include "../librpc/gen_ndr/ndr_schannel.h"
    30 #include "lib/util/tdb_wrap.h"
     31#include "lib/dbwrap/dbwrap.h"
    3132
    3233#define SECRETS_SCHANNEL_STATE "SECRETS/SCHANNEL"
     
    3738*******************************************************************************/
    3839
    39 struct tdb_wrap *open_schannel_session_store(TALLOC_CTX *mem_ctx,
    40                                              const char *private_dir)
    41 {
    42         struct tdb_wrap *tdb_sc = NULL;
    43         char *fname = talloc_asprintf(mem_ctx, "%s/schannel_store.tdb", private_dir);
     40struct db_context *open_schannel_session_store(TALLOC_CTX *mem_ctx,
     41                                               struct loadparm_context *lp_ctx)
     42{
     43        struct db_context *db_sc = NULL;
     44        char *fname = lpcfg_private_db_path(mem_ctx, lp_ctx, "schannel_store");
    4445
    4546        if (!fname) {
     
    4748        }
    4849
    49         tdb_sc = tdb_wrap_open(mem_ctx, fname, 0, TDB_CLEAR_IF_FIRST|TDB_NOSYNC, O_RDWR|O_CREAT, 0600);
    50 
    51         if (!tdb_sc) {
     50        db_sc = dbwrap_local_open(mem_ctx, lp_ctx, fname, 0,
     51                                  TDB_CLEAR_IF_FIRST|TDB_NOSYNC, O_RDWR|O_CREAT,
     52                                  0600, DBWRAP_LOCK_ORDER_NONE,
     53                                  DBWRAP_FLAG_NONE);
     54
     55        if (!db_sc) {
    5256                DEBUG(0,("open_schannel_session_store: Failed to open %s - %s\n",
    5357                         fname, strerror(errno)));
     
    5862        TALLOC_FREE(fname);
    5963
    60         return tdb_sc;
     64        return db_sc;
    6165}
    6266
     
    6569
    6670static
    67 NTSTATUS schannel_store_session_key_tdb(struct tdb_wrap *tdb_sc,
     71NTSTATUS schannel_store_session_key_tdb(struct db_context *db_sc,
    6872                                        TALLOC_CTX *mem_ctx,
    6973                                        struct netlogon_creds_CredentialState *creds)
     
    7276        DATA_BLOB blob;
    7377        TDB_DATA value;
    74         int ret;
    7578        char *keystr;
    7679        char *name_upper;
     80        NTSTATUS status;
     81
     82        if (strlen(creds->computer_name) > 15) {
     83                /*
     84                 * We may want to check for a completely
     85                 * valid netbios name.
     86                 */
     87                return STATUS_BUFFER_OVERFLOW;
     88        }
    7789
    7890        name_upper = strupper_talloc(mem_ctx, creds->computer_name);
     
    98110        value.dsize = blob.length;
    99111
    100         ret = tdb_store_bystring(tdb_sc->tdb, keystr, value, TDB_REPLACE);
    101         if (ret != TDB_SUCCESS) {
     112        status = dbwrap_store_bystring(db_sc, keystr, value, TDB_REPLACE);
     113        if (!NT_STATUS_IS_OK(status)) {
    102114                DEBUG(0,("Unable to add %s to session key db - %s\n",
    103                          keystr, tdb_errorstr(tdb_sc->tdb)));
     115                         keystr, nt_errstr(status)));
    104116                talloc_free(keystr);
    105                 return NT_STATUS_INTERNAL_DB_CORRUPTION;
     117                return status;
    106118        }
    107119
     
    122134
    123135static
    124 NTSTATUS schannel_fetch_session_key_tdb(struct tdb_wrap *tdb_sc,
     136NTSTATUS schannel_fetch_session_key_tdb(struct db_context *db_sc,
    125137                                        TALLOC_CTX *mem_ctx,
    126138                                        const char *computer_name,
     
    149161        }
    150162
    151         value = tdb_fetch_bystring(tdb_sc->tdb, keystr);
    152         if (!value.dptr) {
     163        status = dbwrap_fetch_bystring(db_sc, keystr, keystr, &value);
     164        if (!NT_STATUS_IS_OK(status)) {
    153165                DEBUG(10,("schannel_fetch_session_key_tdb: Failed to find entry with key %s\n",
    154166                        keystr ));
    155                 status = NT_STATUS_OBJECT_NAME_NOT_FOUND;
    156167                goto done;
    157168        }
     
    184195
    185196        talloc_free(keystr);
    186         SAFE_FREE(value.dptr);
    187197
    188198        if (!NT_STATUS_IS_OK(status)) {
     
    202212
    203213NTSTATUS schannel_get_creds_state(TALLOC_CTX *mem_ctx,
    204                                   const char *db_priv_dir,
     214                                  struct loadparm_context *lp_ctx,
    205215                                  const char *computer_name,
    206216                                  struct netlogon_creds_CredentialState **_creds)
    207217{
    208218        TALLOC_CTX *tmpctx;
    209         struct tdb_wrap *tdb_sc;
     219        struct db_context *db_sc;
    210220        struct netlogon_creds_CredentialState *creds;
    211221        NTSTATUS status;
     
    216226        }
    217227
    218         tdb_sc = open_schannel_session_store(tmpctx, db_priv_dir);
    219         if (!tdb_sc) {
     228        db_sc = open_schannel_session_store(tmpctx, lp_ctx);
     229        if (!db_sc) {
    220230                return NT_STATUS_ACCESS_DENIED;
    221231        }
    222232
    223         status = schannel_fetch_session_key_tdb(tdb_sc, tmpctx,
     233        status = schannel_fetch_session_key_tdb(db_sc, tmpctx,
    224234                                                computer_name, &creds);
    225235        if (NT_STATUS_IS_OK(status)) {
     
    240250
    241251NTSTATUS schannel_save_creds_state(TALLOC_CTX *mem_ctx,
    242                                    const char *db_priv_dir,
     252                                   struct loadparm_context *lp_ctx,
    243253                                   struct netlogon_creds_CredentialState *creds)
    244254{
    245255        TALLOC_CTX *tmpctx;
    246         struct tdb_wrap *tdb_sc;
     256        struct db_context *db_sc;
    247257        NTSTATUS status;
    248258
     
    252262        }
    253263
    254         tdb_sc = open_schannel_session_store(tmpctx, db_priv_dir);
    255         if (!tdb_sc) {
     264        db_sc = open_schannel_session_store(tmpctx, lp_ctx);
     265        if (!db_sc) {
    256266                return NT_STATUS_ACCESS_DENIED;
    257267        }
    258268
    259         status = schannel_store_session_key_tdb(tdb_sc, tmpctx, creds);
     269        status = schannel_store_session_key_tdb(db_sc, tmpctx, creds);
    260270
    261271        talloc_free(tmpctx);
     
    274284
    275285NTSTATUS schannel_check_creds_state(TALLOC_CTX *mem_ctx,
    276                                     const char *db_priv_dir,
     286                                    struct loadparm_context *lp_ctx,
    277287                                    const char *computer_name,
    278288                                    struct netr_Authenticator *received_authenticator,
     
    281291{
    282292        TALLOC_CTX *tmpctx;
    283         struct tdb_wrap *tdb_sc;
     293        struct db_context *db_sc;
    284294        struct netlogon_creds_CredentialState *creds;
    285295        NTSTATUS status;
    286         int ret;
     296        char *name_upper = NULL;
     297        char *keystr = NULL;
     298        struct db_record *record;
     299        TDB_DATA key;
    287300
    288301        if (creds_out != NULL) {
     
    295308        }
    296309
    297         tdb_sc = open_schannel_session_store(tmpctx, db_priv_dir);
    298         if (!tdb_sc) {
     310        name_upper = strupper_talloc(tmpctx, computer_name);
     311        if (!name_upper) {
     312                status = NT_STATUS_NO_MEMORY;
     313                goto done;
     314        }
     315
     316        keystr = talloc_asprintf(tmpctx, "%s/%s",
     317                                 SECRETS_SCHANNEL_STATE, name_upper);
     318        if (!keystr) {
     319                status = NT_STATUS_NO_MEMORY;
     320                goto done;
     321        }
     322
     323        key = string_term_tdb_data(keystr);
     324
     325        db_sc = open_schannel_session_store(tmpctx, lp_ctx);
     326        if (!db_sc) {
    299327                status = NT_STATUS_ACCESS_DENIED;
    300328                goto done;
    301329        }
    302330
    303         ret = tdb_transaction_start(tdb_sc->tdb);
    304         if (ret != 0) {
     331        record = dbwrap_fetch_locked(db_sc, tmpctx, key);
     332        if (!record) {
    305333                status = NT_STATUS_INTERNAL_DB_CORRUPTION;
    306334                goto done;
     
    311339         * update the structure */
    312340
    313         status = schannel_fetch_session_key_tdb(tdb_sc, tmpctx,
     341        status = schannel_fetch_session_key_tdb(db_sc, tmpctx,
    314342                                                computer_name, &creds);
    315343        if (!NT_STATUS_IS_OK(status)) {
    316                 tdb_transaction_cancel(tdb_sc->tdb);
    317344                goto done;
    318345        }
     
    322349                                                  return_authenticator);
    323350        if (!NT_STATUS_IS_OK(status)) {
    324                 tdb_transaction_cancel(tdb_sc->tdb);
    325                 goto done;
    326         }
    327 
    328         status = schannel_store_session_key_tdb(tdb_sc, tmpctx, creds);
    329         if (!NT_STATUS_IS_OK(status)) {
    330                 tdb_transaction_cancel(tdb_sc->tdb);
    331                 goto done;
    332         }
    333 
    334         tdb_transaction_commit(tdb_sc->tdb);
     351                goto done;
     352        }
     353
     354        status = schannel_store_session_key_tdb(db_sc, tmpctx, creds);
     355        if (!NT_STATUS_IS_OK(status)) {
     356                goto done;
     357        }
    335358
    336359        if (creds_out) {
  • vendor/current/libcli/auth/smbencrypt.c

    r919 r988  
    117117bool E_deshash(const char *passwd, uint8_t p16[16])
    118118{
    119         bool ret = true;
    120         char dospwd[256];
     119        bool ret;
     120        uint8_t dospwd[14];
     121        TALLOC_CTX *frame = talloc_stackframe();
     122
     123        size_t converted_size;
     124
     125        char *tmpbuf;
     126
    121127        ZERO_STRUCT(dospwd);
    122128
    123         /* Password must be converted to DOS charset - null terminated, uppercase. */
    124         push_string(dospwd, passwd, sizeof(dospwd), STR_ASCII|STR_UPPER|STR_TERMINATE);
    125 
    126         /* Only the first 14 chars are considered, password need not be null terminated. */
     129        tmpbuf = strupper_talloc(frame, passwd);
     130        if (tmpbuf == NULL) {
     131                /* Too many callers don't check this result, we need to fill in the buffer with something */
     132                strlcpy((char *)dospwd, passwd ? passwd : "", sizeof(dospwd));
     133                E_P16(dospwd, p16);
     134                talloc_free(frame);
     135                return false;
     136        }
     137
     138        ZERO_STRUCT(dospwd);
     139
     140        ret = convert_string_error(CH_UNIX, CH_DOS, tmpbuf, strlen(tmpbuf), dospwd, sizeof(dospwd), &converted_size);
     141        talloc_free(frame);
     142
     143        /* Only the first 14 chars are considered, password need not
     144         * be null terminated.  We do this in the error and success
     145         * case to avoid returning a fixed 'password' buffer, but
     146         * callers should not use it when E_deshash returns false */
     147
    127148        E_P16((const uint8_t *)dospwd, p16);
    128 
    129         if (strlen(dospwd) > 14) {
    130                 ret = false;
    131         }
    132149
    133150        ZERO_STRUCT(dospwd);
     
    249266/* Does the des encryption. */
    250267
    251 void SMBNTencrypt_hash(const uint8_t nt_hash[16], uint8_t *c8, uint8_t *p24)
     268void SMBNTencrypt_hash(const uint8_t nt_hash[16], const uint8_t *c8, uint8_t *p24)
    252269{
    253270        uint8_t p21[21];
     
    267284/* Does the NT MD4 hash then des encryption. Plaintext version of the above. */
    268285
    269 void SMBNTencrypt(const char *passwd, uint8_t *c8, uint8_t *p24)
     286void SMBNTencrypt(const char *passwd, const uint8_t *c8, uint8_t *p24)
    270287{
    271288        uint8_t nt_hash[16];
     
    371388}
    372389
    373 static DATA_BLOB NTLMv2_generate_client_data(TALLOC_CTX *mem_ctx, const DATA_BLOB *names_blob)
     390static DATA_BLOB NTLMv2_generate_client_data(TALLOC_CTX *mem_ctx,
     391                                             NTTIME nttime,
     392                                             const DATA_BLOB *names_blob)
    374393{
    375394        uint8_t client_chal[8];
    376395        DATA_BLOB response = data_blob(NULL, 0);
    377396        uint8_t long_date[8];
    378         NTTIME nttime;
    379 
    380         unix_to_nt_time(&nttime, time(NULL));
    381397
    382398        generate_random_buffer(client_chal, sizeof(client_chal));
     
    401417                                          const uint8_t ntlm_v2_hash[16],
    402418                                          const DATA_BLOB *server_chal,
     419                                          NTTIME nttime,
    403420                                          const DATA_BLOB *names_blob)
    404421{
     
    417434        /* generate some data to pass into the response function - including
    418435           the hostname and domain name of the server */
    419         ntlmv2_client_data = NTLMv2_generate_client_data(mem_ctx, names_blob);
     436        ntlmv2_client_data = NTLMv2_generate_client_data(mem_ctx, nttime, names_blob);
    420437
    421438        /* Given that data, and the challenge from the server, generate a response */
     
    463480                           const char *user, const char *domain, const uint8_t nt_hash[16],
    464481                           const DATA_BLOB *server_chal,
     482                           const NTTIME *server_timestamp,
    465483                           const DATA_BLOB *names_blob,
    466484                           DATA_BLOB *lm_response, DATA_BLOB *nt_response,
     
    478496
    479497        if (nt_response) {
     498                const NTTIME *nttime = server_timestamp;
     499                NTTIME _now = 0;
     500
     501                if (nttime == NULL) {
     502                        struct timeval tv_now = timeval_current();
     503                        _now = timeval_to_nttime(&tv_now);
     504                        nttime = &_now;
     505                }
     506
    480507                *nt_response = NTLMv2_generate_response(mem_ctx,
    481                                                         ntlm_v2_hash, server_chal,
     508                                                        ntlm_v2_hash,
     509                                                        server_chal,
     510                                                        *nttime,
    482511                                                        names_blob);
    483512                if (user_session_key) {
     
    493522
    494523        if (lm_response) {
    495                 *lm_response = LMv2_generate_response(mem_ctx,
    496                                                       ntlm_v2_hash, server_chal);
     524                if (server_timestamp != NULL) {
     525                        *lm_response = data_blob_talloc_zero(mem_ctx, 24);
     526                } else {
     527                        *lm_response = LMv2_generate_response(mem_ctx,
     528                                                              ntlm_v2_hash,
     529                                                              server_chal);
     530                }
    497531                if (lm_session_key) {
    498532                        *lm_session_key = data_blob_talloc(mem_ctx, NULL, 16);
     
    519553
    520554        return SMBNTLMv2encrypt_hash(mem_ctx,
    521                                      user, domain, nt_hash, server_chal, names_blob,
     555                                     user, domain, nt_hash,
     556                                     server_chal, NULL, names_blob,
    522557                                     lm_response, nt_response, lm_session_key, user_session_key);
    523558}
     
    611646                }
    612647
    613 #ifdef SAMBA4_INTERNAL_HEIMDAL /* smbtorture4 for make test */
    614648                cmp = strcasecmp_m(a, v);
    615 #else /* smbd */
    616                 cmp = StrCaseCmp(a, v);
    617 #endif
    618649                if (cmp != 0) {
    619650                        DEBUG(2,("%s: NTLMv2_RESPONSE with "
     
    637668                v = av_nb_dn->Value.AvNbDomainName;
    638669
    639 #ifdef SAMBA4_INTERNAL_HEIMDAL /* smbtorture4 for make test */
    640670                cmp = strcasecmp_m(workgroup, v);
    641 #else /* smbd */
    642                 cmp = StrCaseCmp(workgroup, v);
    643 #endif
    644671                if (cmp != 0) {
    645672                        DEBUG(2,("%s: NTLMv2_RESPONSE with "
     
    740767                                   byte_len,
    741768                                   (void *)pp_new_pwrd,
    742                                    new_pw_len,
    743                                    false)) {
     769                                   new_pw_len)) {
    744770                DEBUG(0, ("decode_pw_buffer: failed to convert incoming password\n"));
    745771                return false;
     
    891917
    892918        if (!pwd_buf) {
    893                 return WERR_BAD_PASSWORD;
     919                return WERR_INVALID_PASSWORD;
    894920        }
    895921
    896922        if (session_key->length != 16) {
    897923                DEBUG(10,("invalid session key\n"));
    898                 return WERR_BAD_PASSWORD;
     924                return WERR_INVALID_PASSWORD;
    899925        }
    900926
     
    913939        if (!decode_pw_buffer(mem_ctx, buffer, pwd, &pwd_len, CH_UTF16)) {
    914940                data_blob_free(&confounded_session_key);
    915                 return WERR_BAD_PASSWORD;
     941                return WERR_INVALID_PASSWORD;
    916942        }
    917943
  • vendor/current/libcli/auth/spnego.h

    r740 r988  
    4646        SPNEGO_ACCEPT_INCOMPLETE = 1,
    4747        SPNEGO_REJECT = 2,
    48         SPNEGO_NONE_RESULT = 3
     48        SPNEGO_REQUEST_MIC = 3,
     49        /*
     50         * The max value is 0xff (255) on the wire
     51         */
     52        SPNEGO_NONE_RESULT = 256
    4953};
    5054
    5155struct spnego_negTokenInit {
    52         const char **mechTypes;
     56        const char * const *mechTypes;
    5357        DATA_BLOB reqFlags;
    5458        uint8_t reqFlagsPadding;
     
    5963
    6064struct spnego_negTokenTarg {
    61         uint8_t negResult;
     65        enum spnego_negResult negResult;
    6266        const char *supportedMech;
    6367        DATA_BLOB responseToken;
  • vendor/current/libcli/auth/spnego_parse.c

    r740 r988  
    3030        ZERO_STRUCTP(token);
    3131
    32         asn1_start_tag(asn1, ASN1_CONTEXT(0));
    33         asn1_start_tag(asn1, ASN1_SEQUENCE(0));
    34 
    35         while (!asn1->has_error && 0 < asn1_tag_remaining(asn1)) {
     32        if (!asn1_start_tag(asn1, ASN1_CONTEXT(0))) return false;
     33        if (!asn1_start_tag(asn1, ASN1_SEQUENCE(0))) return false;
     34
     35        while (!asn1_has_error(asn1) && 0 < asn1_tag_remaining(asn1)) {
    3636                int i;
    3737                uint8_t context;
     38
    3839                if (!asn1_peek_uint8(asn1, &context)) {
    39                         asn1->has_error = true;
     40                        asn1_set_error(asn1);
    4041                        break;
    4142                }
     
    4344                switch (context) {
    4445                /* Read mechTypes */
    45                 case ASN1_CONTEXT(0):
    46                         asn1_start_tag(asn1, ASN1_CONTEXT(0));
    47                         asn1_start_tag(asn1, ASN1_SEQUENCE(0));
    48 
    49                         token->mechTypes = talloc(NULL, const char *);
    50                         for (i = 0; !asn1->has_error &&
     46                case ASN1_CONTEXT(0): {
     47                        const char **mechTypes;
     48
     49                        if (!asn1_start_tag(asn1, ASN1_CONTEXT(0))) return false;
     50                        if (!asn1_start_tag(asn1, ASN1_SEQUENCE(0))) return false;
     51
     52                        mechTypes = talloc(mem_ctx, const char *);
     53                        if (mechTypes == NULL) {
     54                                asn1_set_error(asn1);
     55                                return false;
     56                        }
     57                        for (i = 0; !asn1_has_error(asn1) &&
    5158                                     0 < asn1_tag_remaining(asn1); i++) {
    5259                                char *oid;
    53                                 token->mechTypes = talloc_realloc(NULL,
    54                                                                   token->mechTypes,
    55                                                                   const char *, i+2);
    56                                 asn1_read_OID(asn1, token->mechTypes, &oid);
    57                                 token->mechTypes[i] = oid;
    58                         }
    59                         token->mechTypes[i] = NULL;
     60                                const char **p;
     61                                p = talloc_realloc(mem_ctx,
     62                                                   mechTypes,
     63                                                   const char *, i+2);
     64                                if (p == NULL) {
     65                                        talloc_free(mechTypes);
     66                                        asn1_set_error(asn1);
     67                                        return false;
     68                                }
     69                                mechTypes = p;
     70
     71                                if (!asn1_read_OID(asn1, mechTypes, &oid)) return false;
     72                                mechTypes[i] = oid;
     73                        }
     74                        mechTypes[i] = NULL;
     75                        token->mechTypes = mechTypes;
    6076
    6177                        asn1_end_tag(asn1);
    6278                        asn1_end_tag(asn1);
    6379                        break;
     80                }
    6481                /* Read reqFlags */
    6582                case ASN1_CONTEXT(1):
    66                         asn1_start_tag(asn1, ASN1_CONTEXT(1));
    67                         asn1_read_BitString(asn1, mem_ctx, &token->reqFlags,
    68                                             &token->reqFlagsPadding);
    69                         asn1_end_tag(asn1);
     83                        if (!asn1_start_tag(asn1, ASN1_CONTEXT(1))) return false;
     84                        if (!asn1_read_BitString(asn1, mem_ctx, &token->reqFlags,
     85                                            &token->reqFlagsPadding)) return false;
     86                        if (!asn1_end_tag(asn1)) return false;
    7087                        break;
    7188                /* Read mechToken */
    7289                case ASN1_CONTEXT(2):
    73                         asn1_start_tag(asn1, ASN1_CONTEXT(2));
    74                         asn1_read_OctetString(asn1, mem_ctx, &token->mechToken);
    75                         asn1_end_tag(asn1);
     90                        if (!asn1_start_tag(asn1, ASN1_CONTEXT(2))) return false;
     91                        if (!asn1_read_OctetString(asn1, mem_ctx, &token->mechToken)) return false;
     92                        if (!asn1_end_tag(asn1)) return false;
    7693                        break;
    7794                /* Read mecListMIC */
     
    7996                {
    8097                        uint8_t type_peek;
    81                         asn1_start_tag(asn1, ASN1_CONTEXT(3));
     98                        if (!asn1_start_tag(asn1, ASN1_CONTEXT(3))) return false;
    8299                        if (!asn1_peek_uint8(asn1, &type_peek)) {
    83                                 asn1->has_error = true;
     100                                asn1_set_error(asn1);
    84101                                break;
    85102                        }
    86103                        if (type_peek == ASN1_OCTET_STRING) {
    87                                 asn1_read_OctetString(asn1, mem_ctx,
    88                                                       &token->mechListMIC);
     104                                if (!asn1_read_OctetString(asn1, mem_ctx,
     105                                                      &token->mechListMIC)) return false;
    89106                        } else {
    90107                                /* RFC 2478 says we have an Octet String here,
    91108                                   but W2k sends something different... */
    92109                                char *mechListMIC;
    93                                 asn1_start_tag(asn1, ASN1_SEQUENCE(0));
    94                                 asn1_start_tag(asn1, ASN1_CONTEXT(0));
    95                                 asn1_read_GeneralString(asn1, mem_ctx, &mechListMIC);
    96                                 asn1_end_tag(asn1);
    97                                 asn1_end_tag(asn1);
     110                                if (!asn1_start_tag(asn1, ASN1_SEQUENCE(0))) return false;
     111                                if (!asn1_start_tag(asn1, ASN1_CONTEXT(0))) return false;
     112                                if (!asn1_read_GeneralString(asn1, mem_ctx, &mechListMIC)) return false;
     113                                if (!asn1_end_tag(asn1)) return false;
     114                                if (!asn1_end_tag(asn1)) return false;
    98115
    99116                                token->targetPrincipal = mechListMIC;
    100117                        }
    101                         asn1_end_tag(asn1);
     118                        if (!asn1_end_tag(asn1)) return false;
    102119                        break;
    103120                }
    104121                default:
    105                         asn1->has_error = true;
    106                         break;
    107                 }
    108         }
    109 
    110         asn1_end_tag(asn1);
    111         asn1_end_tag(asn1);
    112 
    113         return !asn1->has_error;
     122                        asn1_set_error(asn1);
     123                        break;
     124                }
     125        }
     126
     127        if (!asn1_end_tag(asn1)) return false;
     128        if (!asn1_end_tag(asn1)) return false;
     129
     130        return !asn1_has_error(asn1);
    114131}
    115132
    116133static bool write_negTokenInit(struct asn1_data *asn1, struct spnego_negTokenInit *token)
    117134{
    118         asn1_push_tag(asn1, ASN1_CONTEXT(0));
    119         asn1_push_tag(asn1, ASN1_SEQUENCE(0));
     135        if (!asn1_push_tag(asn1, ASN1_CONTEXT(0))) return false;
     136        if (!asn1_push_tag(asn1, ASN1_SEQUENCE(0))) return false;
    120137
    121138        /* Write mechTypes */
     
    123140                int i;
    124141
    125                 asn1_push_tag(asn1, ASN1_CONTEXT(0));
    126                 asn1_push_tag(asn1, ASN1_SEQUENCE(0));
     142                if (!asn1_push_tag(asn1, ASN1_CONTEXT(0))) return false;
     143                if (!asn1_push_tag(asn1, ASN1_SEQUENCE(0))) return false;
    127144                for (i = 0; token->mechTypes[i]; i++) {
    128                         asn1_write_OID(asn1, token->mechTypes[i]);
    129                 }
    130                 asn1_pop_tag(asn1);
    131                 asn1_pop_tag(asn1);
     145                        if (!asn1_write_OID(asn1, token->mechTypes[i])) return false;
     146                }
     147                if (!asn1_pop_tag(asn1)) return false;
     148                if (!asn1_pop_tag(asn1)) return false;
    132149        }
    133150
    134151        /* write reqFlags */
    135152        if (token->reqFlags.length > 0) {
    136                 asn1_push_tag(asn1, ASN1_CONTEXT(1));
    137                 asn1_write_BitString(asn1, token->reqFlags.data,
     153                if (!asn1_push_tag(asn1, ASN1_CONTEXT(1))) return false;
     154                if (!asn1_write_BitString(asn1, token->reqFlags.data,
    138155                                     token->reqFlags.length,
    139                                      token->reqFlagsPadding);
    140                 asn1_pop_tag(asn1);
     156                                     token->reqFlagsPadding)) return false;
     157                if (!asn1_pop_tag(asn1)) return false;
    141158        }
    142159
    143160        /* write mechToken */
    144161        if (token->mechToken.data) {
    145                 asn1_push_tag(asn1, ASN1_CONTEXT(2));
    146                 asn1_write_OctetString(asn1, token->mechToken.data,
    147                                        token->mechToken.length);
    148                 asn1_pop_tag(asn1);
     162                if (!asn1_push_tag(asn1, ASN1_CONTEXT(2))) return false;
     163                if (!asn1_write_OctetString(asn1, token->mechToken.data,
     164                                       token->mechToken.length)) return false;
     165                if (!asn1_pop_tag(asn1)) return false;
    149166        }
    150167
    151168        /* write mechListMIC */
    152169        if (token->mechListMIC.data) {
    153                 asn1_push_tag(asn1, ASN1_CONTEXT(3));
     170                if (!asn1_push_tag(asn1, ASN1_CONTEXT(3))) return false;
    154171#if 0
    155172                /* This is what RFC 2478 says ... */
     
    159176                /* ... but unfortunately this is what Windows
    160177                   sends/expects */
    161                 asn1_push_tag(asn1, ASN1_SEQUENCE(0));
    162                 asn1_push_tag(asn1, ASN1_CONTEXT(0));
    163                 asn1_push_tag(asn1, ASN1_GENERAL_STRING);
    164                 asn1_write(asn1, token->mechListMIC.data,
    165                            token->mechListMIC.length);
    166                 asn1_pop_tag(asn1);
    167                 asn1_pop_tag(asn1);
    168                 asn1_pop_tag(asn1);
     178                if (!asn1_push_tag(asn1, ASN1_SEQUENCE(0))) return false;
     179                if (!asn1_push_tag(asn1, ASN1_CONTEXT(0))) return false;
     180                if (!asn1_push_tag(asn1, ASN1_GENERAL_STRING)) return false;
     181                if (!asn1_write(asn1, token->mechListMIC.data,
     182                           token->mechListMIC.length)) return false;
     183                if (!asn1_pop_tag(asn1)) return false;
     184                if (!asn1_pop_tag(asn1)) return false;
     185                if (!asn1_pop_tag(asn1)) return false;
    169186#endif
    170                 asn1_pop_tag(asn1);
    171         }
    172 
    173         asn1_pop_tag(asn1);
    174         asn1_pop_tag(asn1);
    175 
    176         return !asn1->has_error;
     187                if (!asn1_pop_tag(asn1)) return false;
     188        }
     189
     190        if (!asn1_pop_tag(asn1)) return false;
     191        if (!asn1_pop_tag(asn1)) return false;
     192
     193        return !asn1_has_error(asn1);
    177194}
    178195
     
    182199        ZERO_STRUCTP(token);
    183200
    184         asn1_start_tag(asn1, ASN1_CONTEXT(1));
    185         asn1_start_tag(asn1, ASN1_SEQUENCE(0));
    186 
    187         while (!asn1->has_error && 0 < asn1_tag_remaining(asn1)) {
     201        if (!asn1_start_tag(asn1, ASN1_CONTEXT(1))) return false;
     202        if (!asn1_start_tag(asn1, ASN1_SEQUENCE(0))) return false;
     203
     204        while (!asn1_has_error(asn1) && 0 < asn1_tag_remaining(asn1)) {
    188205                uint8_t context;
     206                uint8_t neg_result;
    189207                char *oid;
     208
    190209                if (!asn1_peek_uint8(asn1, &context)) {
    191                         asn1->has_error = true;
     210                        asn1_set_error(asn1);
    192211                        break;
    193212                }
     
    195214                switch (context) {
    196215                case ASN1_CONTEXT(0):
    197                         asn1_start_tag(asn1, ASN1_CONTEXT(0));
    198                         asn1_start_tag(asn1, ASN1_ENUMERATED);
    199                         asn1_read_uint8(asn1, &token->negResult);
    200                         asn1_end_tag(asn1);
    201                         asn1_end_tag(asn1);
     216                        if (!asn1_start_tag(asn1, ASN1_CONTEXT(0))) return false;
     217                        if (!asn1_start_tag(asn1, ASN1_ENUMERATED)) return false;
     218                        if (!asn1_read_uint8(asn1, &neg_result)) return false;
     219                        token->negResult = neg_result;
     220                        if (!asn1_end_tag(asn1)) return false;
     221                        if (!asn1_end_tag(asn1)) return false;
    202222                        break;
    203223                case ASN1_CONTEXT(1):
    204                         asn1_start_tag(asn1, ASN1_CONTEXT(1));
    205                         asn1_read_OID(asn1, mem_ctx, &oid);
     224                        if (!asn1_start_tag(asn1, ASN1_CONTEXT(1))) return false;
     225                        if (!asn1_read_OID(asn1, mem_ctx, &oid)) return false;
    206226                        token->supportedMech = oid;
    207                         asn1_end_tag(asn1);
     227                        if (!asn1_end_tag(asn1)) return false;
    208228                        break;
    209229                case ASN1_CONTEXT(2):
    210                         asn1_start_tag(asn1, ASN1_CONTEXT(2));
    211                         asn1_read_OctetString(asn1, mem_ctx, &token->responseToken);
    212                         asn1_end_tag(asn1);
     230                        if (!asn1_start_tag(asn1, ASN1_CONTEXT(2))) return false;
     231                        if (!asn1_read_OctetString(asn1, mem_ctx, &token->responseToken)) return false;
     232                        if (!asn1_end_tag(asn1)) return false;
    213233                        break;
    214234                case ASN1_CONTEXT(3):
    215                         asn1_start_tag(asn1, ASN1_CONTEXT(3));
    216                         asn1_read_OctetString(asn1, mem_ctx, &token->mechListMIC);
    217                         asn1_end_tag(asn1);
     235                        if (!asn1_start_tag(asn1, ASN1_CONTEXT(3))) return false;
     236                        if (!asn1_read_OctetString(asn1, mem_ctx, &token->mechListMIC)) return false;
     237                        if (!asn1_end_tag(asn1)) return false;
    218238                        break;
    219239                default:
    220                         asn1->has_error = true;
    221                         break;
    222                 }
    223         }
    224 
    225         asn1_end_tag(asn1);
    226         asn1_end_tag(asn1);
    227 
    228         return !asn1->has_error;
     240                        asn1_set_error(asn1);
     241                        break;
     242                }
     243        }
     244
     245        if (!asn1_end_tag(asn1)) return false;
     246        if (!asn1_end_tag(asn1)) return false;
     247
     248        return !asn1_has_error(asn1);
    229249}
    230250
    231251static bool write_negTokenTarg(struct asn1_data *asn1, struct spnego_negTokenTarg *token)
    232252{
    233         asn1_push_tag(asn1, ASN1_CONTEXT(1));
    234         asn1_push_tag(asn1, ASN1_SEQUENCE(0));
     253        if (!asn1_push_tag(asn1, ASN1_CONTEXT(1))) return false;
     254        if (!asn1_push_tag(asn1, ASN1_SEQUENCE(0))) return false;
    235255
    236256        if (token->negResult != SPNEGO_NONE_RESULT) {
    237                 asn1_push_tag(asn1, ASN1_CONTEXT(0));
    238                 asn1_write_enumerated(asn1, token->negResult);
    239                 asn1_pop_tag(asn1);
     257                if (!asn1_push_tag(asn1, ASN1_CONTEXT(0))) return false;
     258                if (!asn1_write_enumerated(asn1, token->negResult)) return false;
     259                if (!asn1_pop_tag(asn1)) return false;
    240260        }
    241261
    242262        if (token->supportedMech) {
    243                 asn1_push_tag(asn1, ASN1_CONTEXT(1));
    244                 asn1_write_OID(asn1, token->supportedMech);
    245                 asn1_pop_tag(asn1);
     263                if (!asn1_push_tag(asn1, ASN1_CONTEXT(1))) return false;
     264                if (!asn1_write_OID(asn1, token->supportedMech)) return false;
     265                if (!asn1_pop_tag(asn1)) return false;
    246266        }
    247267
    248268        if (token->responseToken.data) {
    249                 asn1_push_tag(asn1, ASN1_CONTEXT(2));
    250                 asn1_write_OctetString(asn1, token->responseToken.data,
    251                                        token->responseToken.length);
    252                 asn1_pop_tag(asn1);
     269                if (!asn1_push_tag(asn1, ASN1_CONTEXT(2))) return false;
     270                if (!asn1_write_OctetString(asn1, token->responseToken.data,
     271                                       token->responseToken.length)) return false;
     272                if (!asn1_pop_tag(asn1)) return false;
    253273        }
    254274
    255275        if (token->mechListMIC.data) {
    256                 asn1_push_tag(asn1, ASN1_CONTEXT(3));
    257                 asn1_write_OctetString(asn1, token->mechListMIC.data,
    258                                       token->mechListMIC.length);
    259                 asn1_pop_tag(asn1);
    260         }
    261 
    262         asn1_pop_tag(asn1);
    263         asn1_pop_tag(asn1);
    264 
    265         return !asn1->has_error;
     276                if (!asn1_push_tag(asn1, ASN1_CONTEXT(3))) return false;
     277                if (!asn1_write_OctetString(asn1, token->mechListMIC.data,
     278                                      token->mechListMIC.length)) return false;
     279                if (!asn1_pop_tag(asn1)) return false;
     280        }
     281
     282        if (!asn1_pop_tag(asn1)) return false;
     283        if (!asn1_pop_tag(asn1)) return false;
     284
     285        return !asn1_has_error(asn1);
    266286}
    267287
     
    283303        }
    284304
    285         asn1_load(asn1, data);
     305        if (!asn1_load(asn1, data)) goto err;
    286306
    287307        if (!asn1_peek_uint8(asn1, &context)) {
    288                 asn1->has_error = true;
     308                asn1_set_error(asn1);
    289309        } else {
    290310                switch (context) {
    291311                case ASN1_APPLICATION(0):
    292                         asn1_start_tag(asn1, ASN1_APPLICATION(0));
    293                         asn1_check_OID(asn1, OID_SPNEGO);
     312                        if (!asn1_start_tag(asn1, ASN1_APPLICATION(0))) goto err;
     313                        if (!asn1_check_OID(asn1, OID_SPNEGO)) goto err;
    294314                        if (read_negTokenInit(asn1, mem_ctx, &token->negTokenInit)) {
    295315                                token->type = SPNEGO_NEG_TOKEN_INIT;
    296316                        }
    297                         asn1_end_tag(asn1);
     317                        if (!asn1_end_tag(asn1)) goto err;
    298318                        break;
    299319                case ASN1_CONTEXT(1):
     
    303323                        break;
    304324                default:
    305                         asn1->has_error = true;
    306                         break;
    307                 }
    308         }
    309 
    310         if (!asn1->has_error) ret = asn1->ofs;
     325                        asn1_set_error(asn1);
     326                        break;
     327                }
     328        }
     329
     330        if (!asn1_has_error(asn1)) {
     331                ret = asn1_current_ofs(asn1);
     332        }
     333
     334  err:
     335
    311336        asn1_free(asn1);
    312337
     
    325350        switch (spnego->type) {
    326351        case SPNEGO_NEG_TOKEN_INIT:
    327                 asn1_push_tag(asn1, ASN1_APPLICATION(0));
    328                 asn1_write_OID(asn1, OID_SPNEGO);
    329                 write_negTokenInit(asn1, &spnego->negTokenInit);
    330                 asn1_pop_tag(asn1);
     352                if (!asn1_push_tag(asn1, ASN1_APPLICATION(0))) goto err;
     353                if (!asn1_write_OID(asn1, OID_SPNEGO)) goto err;
     354                if (!write_negTokenInit(asn1, &spnego->negTokenInit)) goto err;
     355                if (!asn1_pop_tag(asn1)) goto err;
    331356                break;
    332357        case SPNEGO_NEG_TOKEN_TARG:
     
    334359                break;
    335360        default:
    336                 asn1->has_error = true;
    337                 break;
    338         }
    339 
    340         if (!asn1->has_error) {
    341                 *blob = data_blob_talloc(mem_ctx, asn1->data, asn1->length);
    342                 ret = asn1->ofs;
    343         }
     361                asn1_set_error(asn1);
     362                break;
     363        }
     364
     365        if (!asn1_extract_blob(asn1, mem_ctx, blob)) {
     366                goto err;
     367        }
     368
     369        ret = asn1_current_ofs(asn1);
     370
     371  err:
     372
    344373        asn1_free(asn1);
    345374
     
    356385        case SPNEGO_NEG_TOKEN_INIT:
    357386                if (spnego->negTokenInit.mechTypes) {
    358                         talloc_free(spnego->negTokenInit.mechTypes);
     387                        talloc_free(discard_const(spnego->negTokenInit.mechTypes));
    359388                }
    360389                data_blob_free(&spnego->negTokenInit.reqFlags);
     
    380409
    381410bool spnego_write_mech_types(TALLOC_CTX *mem_ctx,
    382                              const char **mech_types,
     411                             const char * const *mech_types,
    383412                             DATA_BLOB *blob)
    384413{
     414        bool ret = false;
    385415        struct asn1_data *asn1 = asn1_init(mem_ctx);
    386416
     
    393423                int i;
    394424
    395                 asn1_push_tag(asn1, ASN1_SEQUENCE(0));
     425                if (!asn1_push_tag(asn1, ASN1_SEQUENCE(0))) goto err;
    396426                for (i = 0; mech_types[i]; i++) {
    397                         asn1_write_OID(asn1, mech_types[i]);
    398                 }
    399                 asn1_pop_tag(asn1);
    400         }
    401 
    402         if (asn1->has_error) {
    403                 asn1_free(asn1);
    404                 return false;
    405         }
    406 
    407         *blob = data_blob_talloc(mem_ctx, asn1->data, asn1->length);
    408         if (blob->length != asn1->length) {
    409                 asn1_free(asn1);
    410                 return false;
    411         }
     427                        if (!asn1_write_OID(asn1, mech_types[i])) goto err;
     428                }
     429                if (!asn1_pop_tag(asn1)) goto err;
     430        }
     431
     432        if (asn1_has_error(asn1)) {
     433                goto err;
     434        }
     435
     436        if (!asn1_extract_blob(asn1, mem_ctx, blob)) {
     437                goto err;
     438        }
     439
     440        ret = true;
     441
     442  err:
    412443
    413444        asn1_free(asn1);
    414445
    415         return true;
    416 }
     446        return ret;
     447}
  • vendor/current/libcli/auth/spnego_proto.h

    r414 r988  
    2525bool spnego_free_data(struct spnego_data *spnego);
    2626bool spnego_write_mech_types(TALLOC_CTX *mem_ctx,
    27                              const char **mech_types,
     27                             const char * const *mech_types,
    2828                             DATA_BLOB *blob);
  • vendor/current/libcli/auth/wscript_build

    r919 r988  
    33bld.SAMBA_LIBRARY('cliauth',
    44                  source='',
    5                   deps='NTLMSSP_COMMON MSRPC_PARSE LIBCLI_AUTH COMMON_SCHANNEL PAM_ERRORS SPNEGO_PARSE',
     5                  deps='MSRPC_PARSE LIBCLI_AUTH COMMON_SCHANNEL PAM_ERRORS SPNEGO_PARSE krb5samba samba-errors NTLM_CHECK UTIL_LSARPC',
    66                  private_library=True,
    77                  grouping_library=True)
    8 
    9 bld.SAMBA_SUBSYSTEM('NTLMSSP_COMMON',
    10                     source='ntlmssp.c ntlmssp_ndr.c ntlmssp_server.c ntlmssp_sign.c ntlm_check.c',
    11                     deps='samba-util NDR_NTLMSSP MSRPC_PARSE')
    12 
    138
    149bld.SAMBA_SUBSYSTEM('MSRPC_PARSE',
     
    1712        )
    1813
     14bld.SAMBA_SUBSYSTEM('NTLM_CHECK',
     15                    source='ntlm_check.c',
     16                    deps = 'talloc'
     17                    )
    1918
    2019bld.SAMBA_SUBSYSTEM('LIBCLI_AUTH',
    2120        source='credentials.c session.c smbencrypt.c smbdes.c',
    22         public_deps='MSRPC_PARSE NDR_NTLMSSP',
     21        public_deps='MSRPC_PARSE',
    2322        public_headers='credentials.h:domain_credentials.h'
    2423        )
     
    2625
    2726bld.SAMBA_SUBSYSTEM('COMMON_SCHANNEL',
    28         source='schannel_state_tdb.c schannel_sign.c',
    29         deps='tdb-wrap UTIL_TDB'
     27        source='schannel_state_tdb.c',
     28        deps='dbwrap util_tdb samba-hostconfig NDR_NETLOGON'
    3029        )
    3130
     31bld.SAMBA_SUBSYSTEM('NETLOGON_CREDS_CLI',
     32        source='netlogon_creds_cli.c',
     33        deps='dbwrap util_tdb tevent-util samba-hostconfig RPC_NDR_NETLOGON NDR_NETLOGON'
     34        )
    3235
    3336bld.SAMBA_SUBSYSTEM('PAM_ERRORS',
     
    3841bld.SAMBA_SUBSYSTEM('SPNEGO_PARSE',
    3942                    source='spnego_parse.c',
    40                     deps='ASN1_UTIL')
     43                    deps='asn1util')
  • vendor/current/libcli/cldap/cldap.c

    r746 r988  
    6262        bool connected;
    6363
    64         /*
    65          * we allow sync requests only, if the caller
    66          * did not pass an event context to cldap_socket_init()
    67          */
    68         struct {
    69                 bool allow_poll;
    70                 struct tevent_context *ctx;
    71         } event;
    72 
    7364        /* the queue for outgoing dgrams */
    7465        struct tevent_queue *send_queue;
     
    8778        /* what to do with incoming request packets */
    8879        struct {
     80                struct tevent_context *ev;
    8981                void (*handler)(struct cldap_socket *,
    9082                                void *private_data,
     
    9890
    9991        struct {
     92                struct tevent_context *ev;
    10093                struct cldap_socket *cldap;
    10194        } caller;
     
    137130static bool cldap_recvfrom_setup(struct cldap_socket *c)
    138131{
     132        struct tevent_context *ev;
     133
    139134        if (c->recv_subreq) {
    140135                return true;
     
    145140        }
    146141
    147         c->recv_subreq = tdgram_recvfrom_send(c, c->event.ctx, c->sock);
     142        ev = c->incoming.ev;
     143        if (ev == NULL) {
     144                ev = c->searches.list->caller.ev;
     145        }
     146
     147        c->recv_subreq = tdgram_recvfrom_send(c, ev, c->sock);
    148148        if (!c->recv_subreq) {
    149149                return false;
     
    213213        talloc_free(subreq);
    214214        talloc_free(in);
    215         /*TODO: call a dead socket handler */
    216         return;
    217215}
    218216
     
    223221                                    struct cldap_incoming *in)
    224222{
    225         DATA_BLOB blob;
    226223        struct asn1_data *asn1;
    227224        void *p;
     
    233230        }
    234231
    235         blob = data_blob_const(in->buf, in->len);
    236 
    237232        asn1 = asn1_init(in);
    238233        if (!asn1) {
     
    240235        }
    241236
    242         if (!asn1_load(asn1, blob)) {
    243                 goto nomem;
    244         }
     237        asn1_load_nocopy(asn1, in->buf, in->len);
    245238
    246239        in->ldap_msg = talloc(in, struct ldap_message);
     
    259252        if (p == NULL) {
    260253                if (!c->incoming.handler) {
    261                         goto done;
     254                        TALLOC_FREE(in);
     255                        return true;
    262256                }
    263257
     
    267261        }
    268262
    269         search = talloc_get_type(p, struct cldap_search_state);
     263        search = talloc_get_type_abort(p, struct cldap_search_state);
    270264        search->response.in = talloc_move(search, &in);
     265
    271266        search->response.asn1 = asn1;
    272         search->response.asn1->ofs = 0;
     267
     268        asn1_load_nocopy(search->response.asn1,
     269                         search->response.in->buf, search->response.in->len);
    273270
    274271        DLIST_REMOVE(c->searches.list, search);
    275272
    276         cldap_recvfrom_setup(c);
    277 
     273        if (cldap_recvfrom_setup(c)) {
     274                tevent_req_done(search->req);
     275                return true;
     276        }
     277
     278        /*
     279         * This request was ok, just defer the notify of the caller
     280         * and then just fail the next request if needed
     281         */
     282        tevent_req_defer_callback(search->req, search->caller.ev);
    278283        tevent_req_done(search->req);
    279         return true;
    280 
     284
     285        status = NT_STATUS_NO_MEMORY;
     286        /* in is NULL it this point */
     287        goto nterror;
    281288nomem:
    282289        in->recv_errno = ENOMEM;
    283290error:
    284         status = map_nt_error_from_unix(in->recv_errno);
     291        status = map_nt_error_from_unix_common(in->recv_errno);
    285292nterror:
    286293        TALLOC_FREE(in);
     
    288295        if (!c->connected) {
    289296                /* otherwise we just ignore the error */
    290                 goto done;
     297                return false;
    291298        }
    292299        if (!c->searches.list) {
    293                 goto done;
    294         }
    295         cldap_recvfrom_setup(c);
     300                return false;
     301        }
     302        /*
     303         * We might called tevent_req_done() for a successful
     304         * search before, so we better deliver the failure
     305         * after the success, that is why we better also
     306         * use tevent_req_defer_callback() here.
     307         */
     308        tevent_req_defer_callback(c->searches.list->req,
     309                                  c->searches.list->caller.ev);
    296310        tevent_req_nterror(c->searches.list->req, status);
    297         return true;
    298 done:
    299         TALLOC_FREE(in);
    300311        return false;
    301312}
     
    305316*/
    306317NTSTATUS cldap_socket_init(TALLOC_CTX *mem_ctx,
    307                            struct tevent_context *ev,
    308318                           const struct tsocket_address *local_addr,
    309319                           const struct tsocket_address *remote_addr,
     
    341351        }
    342352
    343         if (!ev) {
    344                 ev = tevent_context_init(c);
    345                 if (!ev) {
    346                         goto nomem;
    347                 }
    348                 c->event.allow_poll = true;
    349         }
    350         c->event.ctx = ev;
    351 
    352353        if (!local_addr) {
    353354                /*
     
    362363                                                        &any);
    363364                if (ret != 0) {
    364                         status = map_nt_error_from_unix(errno);
     365                        status = map_nt_error_from_unix_common(errno);
    365366                        goto nterror;
    366367                }
     
    376377                                     c, &c->sock);
    377378        if (ret != 0) {
    378                 status = map_nt_error_from_unix(errno);
     379                status = map_nt_error_from_unix_common(errno);
    379380                goto nterror;
    380381        }
     
    406407*/
    407408NTSTATUS cldap_set_incoming_handler(struct cldap_socket *c,
     409                                    struct tevent_context *ev,
    408410                                    void (*handler)(struct cldap_socket *,
    409411                                                    void *private_data,
     
    415417        }
    416418
    417         /* if sync requests are allowed, we don't allow an incoming handler */
    418         if (c->event.allow_poll) {
    419                 return NT_STATUS_INVALID_PIPE_STATE;
    420         }
    421 
     419        c->incoming.ev = ev;
    422420        c->incoming.handler = handler;
    423421        c->incoming.private_data = private_data;
     
    453451        }
    454452
     453        if (cldap->incoming.ev == NULL) {
     454                return NT_STATUS_INVALID_PIPE_STATE;
     455        }
     456
    455457        if (!io->dest) {
    456458                return NT_STATUS_INVALID_ADDRESS;
     
    505507
    506508        subreq = tdgram_sendto_queue_send(state,
    507                                           cldap->event.ctx,
     509                                          cldap->incoming.ev,
    508510                                          cldap->sock,
    509511                                          cldap->send_queue,
     
    558560*/
    559561struct tevent_req *cldap_search_send(TALLOC_CTX *mem_ctx,
    560                                     struct cldap_socket *cldap,
    561                                     const struct cldap_search *io)
     562                                     struct tevent_context *ev,
     563                                     struct cldap_socket *cldap,
     564                                     const struct cldap_search *io)
    562565{
    563566        struct tevent_req *req, *subreq;
     
    576579        }
    577580        ZERO_STRUCTP(state);
     581        state->caller.ev = ev;
    578582        state->req = req;
    579583        state->caller.cldap = cldap;
     
    651655        end = now;
    652656        for (i = 0; i < state->request.count; i++) {
    653                 end = tevent_timeval_add(&end, 0, state->request.delay);
    654         }
    655 
    656         if (!tevent_req_set_endtime(req, state->caller.cldap->event.ctx, end)) {
    657                 tevent_req_nomem(NULL, req);
     657                end = tevent_timeval_add(&end, state->request.delay / 1000000,
     658                                         state->request.delay % 1000000);
     659        }
     660
     661        if (!tevent_req_set_endtime(req, state->caller.ev, end)) {
     662                tevent_req_oom(req);
    658663                goto post;
    659664        }
    660665
    661666        subreq = tdgram_sendto_queue_send(state,
    662                                           state->caller.cldap->event.ctx,
     667                                          state->caller.ev,
    663668                                          state->caller.cldap->sock,
    664669                                          state->caller.cldap->send_queue,
     
    671676        tevent_req_set_callback(subreq, cldap_search_state_queue_done, req);
    672677
    673         DLIST_ADD_END(cldap->searches.list, state, struct cldap_search_state *);
     678        DLIST_ADD_END(cldap->searches.list, state);
    674679
    675680        return req;
    676681
    677682 post:
    678         return tevent_req_post(req, cldap->event.ctx);
     683        return tevent_req_post(req, state->caller.ev);
    679684}
    680685
     
    693698        if (ret == -1) {
    694699                NTSTATUS status;
    695                 status = map_nt_error_from_unix(sys_errno);
     700                status = map_nt_error_from_unix_common(sys_errno);
    696701                DLIST_REMOVE(state->caller.cldap->searches.list, state);
    697702                ZERO_STRUCT(state->caller.cldap);
     
    704709        /* wait for incoming traffic */
    705710        if (!cldap_recvfrom_setup(state->caller.cldap)) {
    706                 tevent_req_nomem(NULL, req);
     711                tevent_req_oom(req);
    707712                return;
    708713        }
     
    713718        }
    714719
    715         next = tevent_timeval_current_ofs(0, state->request.delay);
     720        next = tevent_timeval_current_ofs(state->request.delay / 1000000,
     721                                          state->request.delay % 1000000);
    716722        subreq = tevent_wakeup_send(state,
    717                                     state->caller.cldap->event.ctx,
     723                                    state->caller.ev,
    718724                                    next);
    719725        if (tevent_req_nomem(subreq, req)) {
     
    739745
    740746        subreq = tdgram_sendto_queue_send(state,
    741                                           state->caller.cldap->event.ctx,
     747                                          state->caller.ev,
    742748                                          state->caller.cldap->sock,
    743749                                          state->caller.cldap->send_queue,
     
    828834                      struct cldap_search *io)
    829835{
     836        TALLOC_CTX *frame;
    830837        struct tevent_req *req;
     838        struct tevent_context *ev;
    831839        NTSTATUS status;
    832 
    833         if (!cldap->event.allow_poll) {
    834                 return NT_STATUS_INVALID_PIPE_STATE;
    835         }
    836840
    837841        if (cldap->searches.list) {
     
    839843        }
    840844
    841         req = cldap_search_send(mem_ctx, cldap, io);
    842         NT_STATUS_HAVE_NO_MEMORY(req);
    843 
    844         if (!tevent_req_poll(req, cldap->event.ctx)) {
    845                 talloc_free(req);
    846                 return NT_STATUS_INTERNAL_ERROR;
     845        if (cldap->incoming.handler) {
     846                return NT_STATUS_INVALID_PIPE_STATE;
     847        }
     848
     849        frame = talloc_stackframe();
     850
     851        ev = samba_tevent_context_init(frame);
     852        if (ev == NULL) {
     853                TALLOC_FREE(frame);
     854                return NT_STATUS_NO_MEMORY;
     855        }
     856
     857        req = cldap_search_send(mem_ctx, ev, cldap, io);
     858        if (req == NULL) {
     859                TALLOC_FREE(frame);
     860                return NT_STATUS_NO_MEMORY;
     861        }
     862
     863        if (!tevent_req_poll(req, ev)) {
     864                status = map_nt_error_from_unix_common(errno);
     865                TALLOC_FREE(frame);
     866                return status;
    847867        }
    848868
    849869        status = cldap_search_recv(req, mem_ctx, io);
    850         talloc_free(req);
    851 
    852         return status;
     870        if (!NT_STATUS_IS_OK(status)) {
     871                TALLOC_FREE(frame);
     872                return status;
     873        }
     874
     875        TALLOC_FREE(frame);
     876        return NT_STATUS_OK;
    853877}
    854878
     
    857881};
    858882
     883char *cldap_netlogon_create_filter(TALLOC_CTX *mem_ctx,
     884                                   const struct cldap_netlogon *io)
     885{
     886        char *filter;
     887
     888        filter = talloc_asprintf(mem_ctx, "(&(NtVer=%s)",
     889                                 ldap_encode_ndr_uint32(mem_ctx, io->in.version));
     890        if (filter == NULL)
     891                return NULL;
     892
     893        if (io->in.user) {
     894                filter = talloc_asprintf_append_buffer(filter, "(User=%s)", io->in.user);
     895                if (filter == NULL) {
     896                        return NULL;
     897                }
     898        }
     899        if (io->in.host) {
     900                filter = talloc_asprintf_append_buffer(filter, "(Host=%s)", io->in.host);
     901                if (filter == NULL) {
     902                        return NULL;
     903                }
     904        }
     905        if (io->in.realm) {
     906                filter = talloc_asprintf_append_buffer(filter, "(DnsDomain=%s)", io->in.realm);
     907                if (filter == NULL) {
     908                        return NULL;
     909                }
     910        }
     911        if (io->in.acct_control != -1) {
     912                filter = talloc_asprintf_append_buffer(filter, "(AAC=%s)",
     913                                                ldap_encode_ndr_uint32(mem_ctx, io->in.acct_control));
     914                if (filter == NULL) {
     915                        return NULL;
     916                }
     917        }
     918        if (io->in.domain_sid) {
     919                struct dom_sid *sid = dom_sid_parse_talloc(mem_ctx, io->in.domain_sid);
     920
     921                filter = talloc_asprintf_append_buffer(filter, "(domainSid=%s)",
     922                                                ldap_encode_ndr_dom_sid(mem_ctx, sid));
     923                if (filter == NULL) {
     924                        return NULL;
     925                }
     926        }
     927        if (io->in.domain_guid) {
     928                struct GUID guid;
     929                GUID_from_string(io->in.domain_guid, &guid);
     930
     931                filter = talloc_asprintf_append_buffer(filter, "(DomainGuid=%s)",
     932                                                ldap_encode_ndr_GUID(mem_ctx, &guid));
     933                if (filter == NULL) {
     934                        return NULL;
     935                }
     936        }
     937        filter = talloc_asprintf_append_buffer(filter, ")");
     938
     939        return filter;
     940}
     941
    859942static void cldap_netlogon_state_done(struct tevent_req *subreq);
    860943/*
     
    862945*/
    863946struct tevent_req *cldap_netlogon_send(TALLOC_CTX *mem_ctx,
    864                                       struct cldap_socket *cldap,
    865                                       const struct cldap_netlogon *io)
     947                                       struct tevent_context *ev,
     948                                       struct cldap_socket *cldap,
     949                                       const struct cldap_netlogon *io)
    866950{
    867951        struct tevent_req *req, *subreq;
     
    876960        }
    877961
    878         filter = talloc_asprintf(state, "(&(NtVer=%s)",
    879                                  ldap_encode_ndr_uint32(state, io->in.version));
    880         if (tevent_req_nomem(filter, req)) {
    881                 goto post;
    882         }
    883         if (io->in.user) {
    884                 filter = talloc_asprintf_append_buffer(filter, "(User=%s)", io->in.user);
    885                 if (tevent_req_nomem(filter, req)) {
    886                         goto post;
    887                 }
    888         }
    889         if (io->in.host) {
    890                 filter = talloc_asprintf_append_buffer(filter, "(Host=%s)", io->in.host);
    891                 if (tevent_req_nomem(filter, req)) {
    892                         goto post;
    893                 }
    894         }
    895         if (io->in.realm) {
    896                 filter = talloc_asprintf_append_buffer(filter, "(DnsDomain=%s)", io->in.realm);
    897                 if (tevent_req_nomem(filter, req)) {
    898                         goto post;
    899                 }
    900         }
    901         if (io->in.acct_control != -1) {
    902                 filter = talloc_asprintf_append_buffer(filter, "(AAC=%s)",
    903                                                 ldap_encode_ndr_uint32(state, io->in.acct_control));
    904                 if (tevent_req_nomem(filter, req)) {
    905                         goto post;
    906                 }
    907         }
    908         if (io->in.domain_sid) {
    909                 struct dom_sid *sid = dom_sid_parse_talloc(state, io->in.domain_sid);
    910                 if (tevent_req_nomem(sid, req)) {
    911                         goto post;
    912                 }
    913                 filter = talloc_asprintf_append_buffer(filter, "(domainSid=%s)",
    914                                                 ldap_encode_ndr_dom_sid(state, sid));
    915                 if (tevent_req_nomem(filter, req)) {
    916                         goto post;
    917                 }
    918         }
    919         if (io->in.domain_guid) {
    920                 struct GUID guid;
    921                 NTSTATUS status;
    922                 status = GUID_from_string(io->in.domain_guid, &guid);
    923                 if (tevent_req_nterror(req, status)) {
    924                         goto post;
    925                 }
    926                 filter = talloc_asprintf_append_buffer(filter, "(DomainGuid=%s)",
    927                                                 ldap_encode_ndr_GUID(state, &guid));
    928                 if (tevent_req_nomem(filter, req)) {
    929                         goto post;
    930                 }
    931         }
    932         filter = talloc_asprintf_append_buffer(filter, ")");
     962        filter = cldap_netlogon_create_filter(state, io);
    933963        if (tevent_req_nomem(filter, req)) {
    934964                goto post;
     
    951981        state->search.in.retries        = 2;
    952982
    953         subreq = cldap_search_send(state, cldap, &state->search);
     983        subreq = cldap_search_send(state, ev, cldap, &state->search);
    954984        if (tevent_req_nomem(subreq, req)) {
    955985                goto post;
     
    959989        return req;
    960990post:
    961         return tevent_req_post(req, cldap->event.ctx);
     991        return tevent_req_post(req, ev);
    962992}
    963993
     
    9891019        struct cldap_netlogon_state *state = tevent_req_data(req,
    9901020                                             struct cldap_netlogon_state);
    991         NTSTATUS status;
     1021        NTSTATUS status = NT_STATUS_UNSUCCESSFUL;
    9921022        DATA_BLOB *data;
    9931023
     
    10331063                        struct cldap_netlogon *io)
    10341064{
     1065        TALLOC_CTX *frame;
    10351066        struct tevent_req *req;
     1067        struct tevent_context *ev;
    10361068        NTSTATUS status;
    1037 
    1038         if (!cldap->event.allow_poll) {
    1039                 return NT_STATUS_INVALID_PIPE_STATE;
    1040         }
    10411069
    10421070        if (cldap->searches.list) {
     
    10441072        }
    10451073
    1046         req = cldap_netlogon_send(mem_ctx, cldap, io);
    1047         NT_STATUS_HAVE_NO_MEMORY(req);
    1048 
    1049         if (!tevent_req_poll(req, cldap->event.ctx)) {
    1050                 talloc_free(req);
    1051                 return NT_STATUS_INTERNAL_ERROR;
     1074        if (cldap->incoming.handler) {
     1075                return NT_STATUS_INVALID_PIPE_STATE;
     1076        }
     1077
     1078        frame = talloc_stackframe();
     1079
     1080        ev = samba_tevent_context_init(frame);
     1081        if (ev == NULL) {
     1082                TALLOC_FREE(frame);
     1083                return NT_STATUS_NO_MEMORY;
     1084        }
     1085
     1086        req = cldap_netlogon_send(mem_ctx, ev, cldap, io);
     1087        if (req == NULL) {
     1088                TALLOC_FREE(frame);
     1089                return NT_STATUS_NO_MEMORY;
     1090        }
     1091
     1092        if (!tevent_req_poll(req, ev)) {
     1093                status = map_nt_error_from_unix_common(errno);
     1094                TALLOC_FREE(frame);
     1095                return status;
    10521096        }
    10531097
    10541098        status = cldap_netlogon_recv(req, mem_ctx, io);
    1055         talloc_free(req);
    1056 
    1057         return status;
     1099        if (!NT_STATUS_IS_OK(status)) {
     1100                TALLOC_FREE(frame);
     1101                return status;
     1102        }
     1103
     1104        TALLOC_FREE(frame);
     1105        return NT_STATUS_OK;
    10581106}
    10591107
  • vendor/current/libcli/cldap/cldap.h

    r740 r988  
    5353
    5454NTSTATUS cldap_socket_init(TALLOC_CTX *mem_ctx,
    55                            struct tevent_context *ev,
    5655                           const struct tsocket_address *local_addr,
    5756                           const struct tsocket_address *remote_addr,
     
    5958
    6059NTSTATUS cldap_set_incoming_handler(struct cldap_socket *cldap,
     60                                    struct tevent_context *ev,
    6161                                    void (*handler)(struct cldap_socket *,
    6262                                                    void *private_data,
     
    6464                                    void *private_data);
    6565struct tevent_req *cldap_search_send(TALLOC_CTX *mem_ctx,
     66                                     struct tevent_context *ev,
    6667                                     struct cldap_socket *cldap,
    6768                                     const struct cldap_search *io);
     
    114115
    115116struct tevent_req *cldap_netlogon_send(TALLOC_CTX *mem_ctx,
     117                                       struct tevent_context *ev,
    116118                                       struct cldap_socket *cldap,
    117119                                       const struct cldap_netlogon *io);
     
    122124                        TALLOC_CTX *mem_ctx,
    123125                        struct cldap_netlogon *io);
     126char *cldap_netlogon_create_filter(TALLOC_CTX *mem_ctx,
     127                                   const struct cldap_netlogon *io);
    124128
    125129NTSTATUS cldap_netlogon_reply(struct cldap_socket *cldap,
  • vendor/current/libcli/cldap/wscript_build

    r740 r988  
    22
    33
    4 bld.SAMBA_SUBSYSTEM('LIBCLI_CLDAP',
    5         source='cldap.c',
    6         public_deps='cli-ldap',
    7         deps='LIBTSOCKET samba-util UTIL_TEVENT ldb LIBCLI_NETLOGON'
    8         )
     4bld.SAMBA_LIBRARY('cli_cldap',
     5                  source='cldap.c',
     6                  public_deps='cli-ldap',
     7                  deps='LIBTSOCKET samba-util tevent-util ldb LIBCLI_NETLOGON',
     8                  private_library=True
     9                  )
    910
  • vendor/current/libcli/drsuapi/drsuapi.h

    r414 r988  
    3030                                 const DATA_BLOB *gensec_skey,
    3131                                 uint32_t rid,
     32                                 uint32_t dsdb_repl_flags,
    3233                                 struct drsuapi_DsReplicaAttribute *attr);
    3334
  • vendor/current/libcli/drsuapi/repl_decrypt.c

    r746 r988  
    2929#include "../libcli/drsuapi/drsuapi.h"
    3030#include "libcli/auth/libcli_auth.h"
     31#include "dsdb/samdb/samdb.h"
    3132
    3233WERROR drsuapi_decrypt_attribute_value(TALLOC_CTX *mem_ctx,
     
    135136                                 const DATA_BLOB *gensec_skey,
    136137                                 uint32_t rid,
     138                                 uint32_t dsdb_repl_flags,
    137139                                 struct drsuapi_DsReplicaAttribute *attr)
    138140{
     
    165167        }
    166168
     169        if (dsdb_repl_flags & DSDB_REPL_FLAG_EXPECT_NO_SECRETS) {
     170                return WERR_TOO_MANY_SECRETS;
     171        }
     172
    167173        if (attr->value_ctr.num_values > 1) {
    168174                return WERR_DS_DRA_INVALID_PARAMETER;
  • vendor/current/libcli/drsuapi/wscript_build

    r740 r988  
    44bld.SAMBA_SUBSYSTEM('LIBCLI_DRSUAPI',
    55        source='repl_decrypt.c',
    6         public_deps='LIBCLI_AUTH'
     6        public_deps='LIBCLI_AUTH samdb'
    77        )
    88
  • vendor/current/libcli/echo/echo.c

    r740 r988  
    7676                                                &local_addr);
    7777        if (ret != 0) {
    78                 tevent_req_nterror(req, map_nt_error_from_unix(ret));
     78                tevent_req_nterror(req, map_nt_error_from_unix_common(ret));
    7979                return tevent_req_post(req, ev);
    8080        }
     
    8383                                                ECHO_PORT, &server_addr);
    8484        if (ret != 0) {
    85                 tevent_req_nterror(req, map_nt_error_from_unix(ret));
     85                tevent_req_nterror(req, map_nt_error_from_unix_common(ret));
    8686                return tevent_req_post(req, ev);
    8787        }
     
    8989        ret = tdgram_inet_udp_socket(local_addr, server_addr, state, &dgram);
    9090        if (ret != 0) {
    91                 tevent_req_nterror(req, map_nt_error_from_unix(ret));
     91                tevent_req_nterror(req, map_nt_error_from_unix_common(ret));
    9292                return tevent_req_post(req, ev);
    9393        }
     
    133133
    134134        if (len == -1 && err != 0) {
    135                 tevent_req_nterror(req, map_nt_error_from_unix(err));
     135                tevent_req_nterror(req, map_nt_error_from_unix_common(err));
    136136                return;
    137137        }
     
    169169
    170170        if (len == -1 && err != 0) {
    171                 tevent_req_nterror(req, map_nt_error_from_unix(err));
     171                tevent_req_nterror(req, map_nt_error_from_unix_common(err));
     172                return;
     173        }
     174
     175        if (len != state->orig_len) {
     176                tevent_req_nterror(req, NT_STATUS_INVALID_NETWORK_RESPONSE);
    172177                return;
    173178        }
  • vendor/current/libcli/echo/tests/echo.c

    r740 r988  
    6565        make_nbt_name_server(&name,
    6666                             torture_setting_string(tctx, "host", NULL));
    67         status = resolve_name(lpcfg_resolve_context(tctx->lp_ctx), &name, tctx,
    68                               &address, tctx->ev);
     67        status = resolve_name_ex(lpcfg_resolve_context(tctx->lp_ctx),
     68                                 0, 0,
     69                                 &name, tctx,
     70                                 &address, tctx->ev);
    6971        if (!NT_STATUS_IS_OK(status)) {
    7072                printf("Failed to resolve %s - %s\n", name.name,
  • vendor/current/libcli/echo/tests/wscript_build

    r740 r988  
    55        subsystem='smbtorture',
    66        init_function='torture_libcli_echo_init',
    7         deps='LIBTSOCKET UTIL_TEVENT LIBCLI_ECHO',
     7        deps='LIBTSOCKET tevent-util LIBCLI_ECHO',
    88        internal_module=True);
  • vendor/current/libcli/echo/wscript_build

    r740 r988  
    33bld.SAMBA_SUBSYSTEM('LIBCLI_ECHO',
    44        source='echo.c',
    5         deps='LIBTSOCKET UTIL_TEVENT');
     5        deps='LIBTSOCKET tevent-util');
    66
    77bld.RECURSE('tests')
  • vendor/current/libcli/ldap/ldap_message.c

    r740 r988  
    230230        case LDB_OP_AND:
    231231        case LDB_OP_OR:
    232                 asn1_push_tag(data, ASN1_CONTEXT(tree->operation==LDB_OP_AND?0:1));
     232                if (!asn1_push_tag(data, ASN1_CONTEXT(tree->operation==LDB_OP_AND?0:1))) return false;
    233233                for (i=0; i<tree->u.list.num_elements; i++) {
    234234                        if (!ldap_push_filter(data, tree->u.list.elements[i])) {
     
    236236                        }
    237237                }
    238                 asn1_pop_tag(data);
     238                if (!asn1_pop_tag(data)) return false;
    239239                break;
    240240
    241241        case LDB_OP_NOT:
    242                 asn1_push_tag(data, ASN1_CONTEXT(2));
     242                if (!asn1_push_tag(data, ASN1_CONTEXT(2))) return false;
    243243                if (!ldap_push_filter(data, tree->u.isnot.child)) {
    244244                        return false;
    245245                }
    246                 asn1_pop_tag(data);
     246                if (!asn1_pop_tag(data)) return false;
    247247                break;
    248248
    249249        case LDB_OP_EQUALITY:
    250250                /* equality test */
    251                 asn1_push_tag(data, ASN1_CONTEXT(3));
    252                 asn1_write_OctetString(data, tree->u.equality.attr,
    253                                       strlen(tree->u.equality.attr));
    254                 asn1_write_OctetString(data, tree->u.equality.value.data,
    255                                       tree->u.equality.value.length);
    256                 asn1_pop_tag(data);
     251                if (!asn1_push_tag(data, ASN1_CONTEXT(3))) return false;
     252                if (!asn1_write_OctetString(data, tree->u.equality.attr,
     253                                      strlen(tree->u.equality.attr))) return false;
     254                if (!asn1_write_OctetString(data, tree->u.equality.value.data,
     255                                      tree->u.equality.value.length)) return false;
     256                if (!asn1_pop_tag(data)) return false;
    257257                break;
    258258
     
    267267                                  final   [2] LDAPString } }
    268268                */
    269                 asn1_push_tag(data, ASN1_CONTEXT(4));
    270                 asn1_write_OctetString(data, tree->u.substring.attr, strlen(tree->u.substring.attr));
    271                 asn1_push_tag(data, ASN1_SEQUENCE(0));
    272                 i = 0;
    273                 if ( ! tree->u.substring.start_with_wildcard) {
    274                         asn1_push_tag(data, ASN1_CONTEXT_SIMPLE(0));
    275                         asn1_write_DATA_BLOB_LDAPString(data, tree->u.substring.chunks[i]);
    276                         asn1_pop_tag(data);
    277                         i++;
    278                 }
    279                 while (tree->u.substring.chunks[i]) {
    280                         int ctx;
    281 
    282                         if (( ! tree->u.substring.chunks[i + 1]) &&
    283                             (tree->u.substring.end_with_wildcard == 0)) {
    284                                 ctx = 2;
    285                         } else {
    286                                 ctx = 1;
    287                         }
    288                         asn1_push_tag(data, ASN1_CONTEXT_SIMPLE(ctx));
    289                         asn1_write_DATA_BLOB_LDAPString(data, tree->u.substring.chunks[i]);
    290                         asn1_pop_tag(data);
    291                         i++;
    292                 }
    293                 asn1_pop_tag(data);
    294                 asn1_pop_tag(data);
     269                if (!asn1_push_tag(data, ASN1_CONTEXT(4))) return false;
     270                if (!asn1_write_OctetString(data, tree->u.substring.attr, strlen(tree->u.substring.attr))) return false;
     271                if (!asn1_push_tag(data, ASN1_SEQUENCE(0))) return false;
     272
     273                if (tree->u.substring.chunks && tree->u.substring.chunks[0]) {
     274                        i = 0;
     275                        if (!tree->u.substring.start_with_wildcard) {
     276                                if (!asn1_push_tag(data, ASN1_CONTEXT_SIMPLE(0))) return false;
     277                                if (!asn1_write_DATA_BLOB_LDAPString(data, tree->u.substring.chunks[i])) return false;
     278                                if (!asn1_pop_tag(data)) return false;
     279                                i++;
     280                        }
     281                        while (tree->u.substring.chunks[i]) {
     282                                int ctx;
     283
     284                                if (( ! tree->u.substring.chunks[i + 1]) &&
     285                                    (tree->u.substring.end_with_wildcard == 0)) {
     286                                        ctx = 2;
     287                                } else {
     288                                        ctx = 1;
     289                                }
     290                                if (!asn1_push_tag(data, ASN1_CONTEXT_SIMPLE(ctx))) return false;
     291                                if (!asn1_write_DATA_BLOB_LDAPString(data, tree->u.substring.chunks[i])) return false;
     292                                if (!asn1_pop_tag(data)) return false;
     293                                i++;
     294                        }
     295                }
     296                if (!asn1_pop_tag(data)) return false;
     297                if (!asn1_pop_tag(data)) return false;
    295298                break;
    296299
    297300        case LDB_OP_GREATER:
    298301                /* greaterOrEqual test */
    299                 asn1_push_tag(data, ASN1_CONTEXT(5));
    300                 asn1_write_OctetString(data, tree->u.comparison.attr,
    301                                       strlen(tree->u.comparison.attr));
    302                 asn1_write_OctetString(data, tree->u.comparison.value.data,
    303                                       tree->u.comparison.value.length);
    304                 asn1_pop_tag(data);
     302                if (!asn1_push_tag(data, ASN1_CONTEXT(5))) return false;
     303                if (!asn1_write_OctetString(data, tree->u.comparison.attr,
     304                                      strlen(tree->u.comparison.attr))) return false;
     305                if (!asn1_write_OctetString(data, tree->u.comparison.value.data,
     306                                      tree->u.comparison.value.length)) return false;
     307                if (!asn1_pop_tag(data)) return false;
    305308                break;
    306309
    307310        case LDB_OP_LESS:
    308311                /* lessOrEqual test */
    309                 asn1_push_tag(data, ASN1_CONTEXT(6));
    310                 asn1_write_OctetString(data, tree->u.comparison.attr,
    311                                       strlen(tree->u.comparison.attr));
    312                 asn1_write_OctetString(data, tree->u.comparison.value.data,
    313                                       tree->u.comparison.value.length);
    314                 asn1_pop_tag(data);
     312                if (!asn1_push_tag(data, ASN1_CONTEXT(6))) return false;
     313                if (!asn1_write_OctetString(data, tree->u.comparison.attr,
     314                                      strlen(tree->u.comparison.attr))) return false;
     315                if (!asn1_write_OctetString(data, tree->u.comparison.value.data,
     316                                      tree->u.comparison.value.length)) return false;
     317                if (!asn1_pop_tag(data)) return false;
    315318                break;
    316319
    317320        case LDB_OP_PRESENT:
    318321                /* present test */
    319                 asn1_push_tag(data, ASN1_CONTEXT_SIMPLE(7));
    320                 asn1_write_LDAPString(data, tree->u.present.attr);
    321                 asn1_pop_tag(data);
    322                 return !data->has_error;
     322                if (!asn1_push_tag(data, ASN1_CONTEXT_SIMPLE(7))) return false;
     323                if (!asn1_write_LDAPString(data, tree->u.present.attr)) return false;
     324                if (!asn1_pop_tag(data)) return false;
     325                return !asn1_has_error(data);
    323326
    324327        case LDB_OP_APPROX:
    325328                /* approx test */
    326                 asn1_push_tag(data, ASN1_CONTEXT(8));
    327                 asn1_write_OctetString(data, tree->u.comparison.attr,
    328                                       strlen(tree->u.comparison.attr));
    329                 asn1_write_OctetString(data, tree->u.comparison.value.data,
    330                                       tree->u.comparison.value.length);
    331                 asn1_pop_tag(data);
     329                if (!asn1_push_tag(data, ASN1_CONTEXT(8))) return false;
     330                if (!asn1_write_OctetString(data, tree->u.comparison.attr,
     331                                      strlen(tree->u.comparison.attr))) return false;
     332                if (!asn1_write_OctetString(data, tree->u.comparison.value.data,
     333                                      tree->u.comparison.value.length)) return false;
     334                if (!asn1_pop_tag(data)) return false;
    332335                break;
    333336
     
    341344                  }
    342345                */
    343                 asn1_push_tag(data, ASN1_CONTEXT(9));
     346                if (!asn1_push_tag(data, ASN1_CONTEXT(9))) return false;
    344347                if (tree->u.extended.rule_id) {
    345                         asn1_push_tag(data, ASN1_CONTEXT_SIMPLE(1));
    346                         asn1_write_LDAPString(data, tree->u.extended.rule_id);
    347                         asn1_pop_tag(data);
     348                        if (!asn1_push_tag(data, ASN1_CONTEXT_SIMPLE(1))) return false;
     349                        if (!asn1_write_LDAPString(data, tree->u.extended.rule_id)) return false;
     350                        if (!asn1_pop_tag(data)) return false;
    348351                }
    349352                if (tree->u.extended.attr) {
    350                         asn1_push_tag(data, ASN1_CONTEXT_SIMPLE(2));
    351                         asn1_write_LDAPString(data, tree->u.extended.attr);
    352                         asn1_pop_tag(data);
    353                 }
    354                 asn1_push_tag(data, ASN1_CONTEXT_SIMPLE(3));
    355                 asn1_write_DATA_BLOB_LDAPString(data, &tree->u.extended.value);
    356                 asn1_pop_tag(data);
    357                 asn1_push_tag(data, ASN1_CONTEXT_SIMPLE(4));
    358                 asn1_write_uint8(data, tree->u.extended.dnAttributes);
    359                 asn1_pop_tag(data);
    360                 asn1_pop_tag(data);
     353                        if (!asn1_push_tag(data, ASN1_CONTEXT_SIMPLE(2))) return false;
     354                        if (!asn1_write_LDAPString(data, tree->u.extended.attr)) return false;
     355                        if (!asn1_pop_tag(data)) return false;
     356                }
     357                if (!asn1_push_tag(data, ASN1_CONTEXT_SIMPLE(3))) return false;
     358                if (!asn1_write_DATA_BLOB_LDAPString(data, &tree->u.extended.value)) return false;
     359                if (!asn1_pop_tag(data)) return false;
     360                if (!asn1_push_tag(data, ASN1_CONTEXT_SIMPLE(4))) return false;
     361                if (!asn1_write_uint8(data, tree->u.extended.dnAttributes)) return false;
     362                if (!asn1_pop_tag(data)) return false;
     363                if (!asn1_pop_tag(data)) return false;
    361364                break;
    362365
     
    364367                return false;
    365368        }
    366         return !data->has_error;
    367 }
    368 
    369 static void ldap_encode_response(struct asn1_data *data, struct ldap_Result *result)
    370 {
    371         asn1_write_enumerated(data, result->resultcode);
    372         asn1_write_OctetString(data, result->dn,
    373                                (result->dn) ? strlen(result->dn) : 0);
    374         asn1_write_OctetString(data, result->errormessage,
     369        return !asn1_has_error(data);
     370}
     371
     372static bool ldap_encode_response(struct asn1_data *data, struct ldap_Result *result)
     373{
     374        if (!asn1_write_enumerated(data, result->resultcode)) return false;
     375        if (!asn1_write_OctetString(data, result->dn,
     376                               (result->dn) ? strlen(result->dn) : 0)) return false;
     377        if (!asn1_write_OctetString(data, result->errormessage,
    375378                               (result->errormessage) ?
    376                                strlen(result->errormessage) : 0);
     379                               strlen(result->errormessage) : 0)) return false;
    377380        if (result->referral) {
    378                 asn1_push_tag(data, ASN1_CONTEXT(3));
    379                 asn1_write_OctetString(data, result->referral,
    380                                        strlen(result->referral));
    381                 asn1_pop_tag(data);
    382         }
     381                if (!asn1_push_tag(data, ASN1_CONTEXT(3))) return false;
     382                if (!asn1_write_OctetString(data, result->referral,
     383                                       strlen(result->referral))) return false;
     384                if (!asn1_pop_tag(data)) return false;
     385        }
     386        return true;
    383387}
    384388
     
    392396        if (!data) return false;
    393397
    394         asn1_push_tag(data, ASN1_SEQUENCE(0));
    395         asn1_write_Integer(data, msg->messageid);
     398        if (!asn1_push_tag(data, ASN1_SEQUENCE(0))) goto err;
     399        if (!asn1_write_Integer(data, msg->messageid)) goto err;
    396400
    397401        switch (msg->type) {
    398402        case LDAP_TAG_BindRequest: {
    399403                struct ldap_BindRequest *r = &msg->r.BindRequest;
    400                 asn1_push_tag(data, ASN1_APPLICATION(msg->type));
    401                 asn1_write_Integer(data, r->version);
    402                 asn1_write_OctetString(data, r->dn,
    403                                        (r->dn != NULL) ? strlen(r->dn) : 0);
     404                if (!asn1_push_tag(data, ASN1_APPLICATION(msg->type))) goto err;
     405                if (!asn1_write_Integer(data, r->version)) goto err;
     406                if (!asn1_write_OctetString(data, r->dn,
     407                                       (r->dn != NULL) ? strlen(r->dn) : 0)) goto err;
    404408
    405409                switch (r->mechanism) {
    406410                case LDAP_AUTH_MECH_SIMPLE:
    407411                        /* context, primitive */
    408                         asn1_push_tag(data, ASN1_CONTEXT_SIMPLE(0));
    409                         asn1_write(data, r->creds.password,
    410                                    strlen(r->creds.password));
    411                         asn1_pop_tag(data);
     412                        if (!asn1_push_tag(data, ASN1_CONTEXT_SIMPLE(0))) goto err;
     413                        if (!asn1_write(data, r->creds.password,
     414                                   strlen(r->creds.password))) goto err;
     415                        if (!asn1_pop_tag(data)) goto err;
    412416                        break;
    413417                case LDAP_AUTH_MECH_SASL:
    414418                        /* context, constructed */
    415                         asn1_push_tag(data, ASN1_CONTEXT(3));
    416                         asn1_write_OctetString(data, r->creds.SASL.mechanism,
    417                                                strlen(r->creds.SASL.mechanism));
     419                        if (!asn1_push_tag(data, ASN1_CONTEXT(3))) goto err;
     420                        if (!asn1_write_OctetString(data, r->creds.SASL.mechanism,
     421                                               strlen(r->creds.SASL.mechanism))) goto err;
    418422                        if (r->creds.SASL.secblob) {
    419                                 asn1_write_OctetString(data, r->creds.SASL.secblob->data,
    420                                                        r->creds.SASL.secblob->length);
    421                         }
    422                         asn1_pop_tag(data);
     423                                if (!asn1_write_OctetString(data, r->creds.SASL.secblob->data,
     424                                                       r->creds.SASL.secblob->length)) goto err;
     425                        }
     426                        if (!asn1_pop_tag(data)) goto err;
    423427                        break;
    424428                default:
    425                         return false;
    426                 }
    427 
    428                 asn1_pop_tag(data);
     429                        goto err;
     430                }
     431
     432                if (!asn1_pop_tag(data)) goto err;
    429433                break;
    430434        }
    431435        case LDAP_TAG_BindResponse: {
    432436                struct ldap_BindResponse *r = &msg->r.BindResponse;
    433                 asn1_push_tag(data, ASN1_APPLICATION(msg->type));
    434                 ldap_encode_response(data, &r->response);
     437                if (!asn1_push_tag(data, ASN1_APPLICATION(msg->type))) goto err;
     438                if (!ldap_encode_response(data, &r->response)) goto err;
    435439                if (r->SASL.secblob) {
    436                         asn1_write_ContextSimple(data, 7, r->SASL.secblob);
    437                 }
    438                 asn1_pop_tag(data);
     440                        if (!asn1_write_ContextSimple(data, 7, r->SASL.secblob)) goto err;
     441                }
     442                if (!asn1_pop_tag(data)) goto err;
    439443                break;
    440444        }
    441445        case LDAP_TAG_UnbindRequest: {
    442446/*              struct ldap_UnbindRequest *r = &msg->r.UnbindRequest; */
    443                 asn1_push_tag(data, ASN1_APPLICATION_SIMPLE(msg->type));
    444                 asn1_pop_tag(data);
     447                if (!asn1_push_tag(data, ASN1_APPLICATION_SIMPLE(msg->type))) goto err;
     448                if (!asn1_pop_tag(data)) goto err;
    445449                break;
    446450        }
    447451        case LDAP_TAG_SearchRequest: {
    448452                struct ldap_SearchRequest *r = &msg->r.SearchRequest;
    449                 asn1_push_tag(data, ASN1_APPLICATION(msg->type));
    450                 asn1_write_OctetString(data, r->basedn, strlen(r->basedn));
    451                 asn1_write_enumerated(data, r->scope);
    452                 asn1_write_enumerated(data, r->deref);
    453                 asn1_write_Integer(data, r->sizelimit);
    454                 asn1_write_Integer(data, r->timelimit);
    455                 asn1_write_BOOLEAN(data, r->attributesonly);
     453                if (!asn1_push_tag(data, ASN1_APPLICATION(msg->type))) goto err;
     454                if (!asn1_write_OctetString(data, r->basedn, strlen(r->basedn))) goto err;
     455                if (!asn1_write_enumerated(data, r->scope)) goto err;
     456                if (!asn1_write_enumerated(data, r->deref)) goto err;
     457                if (!asn1_write_Integer(data, r->sizelimit)) goto err;
     458                if (!asn1_write_Integer(data, r->timelimit)) goto err;
     459                if (!asn1_write_BOOLEAN(data, r->attributesonly)) goto err;
    456460
    457461                if (!ldap_push_filter(data, r->tree)) {
    458                         return false;
    459                 }
    460 
    461                 asn1_push_tag(data, ASN1_SEQUENCE(0));
     462                        goto err;
     463                }
     464
     465                if (!asn1_push_tag(data, ASN1_SEQUENCE(0))) goto err;
    462466                for (i=0; i<r->num_attributes; i++) {
    463                         asn1_write_OctetString(data, r->attributes[i],
    464                                                strlen(r->attributes[i]));
    465                 }
    466                 asn1_pop_tag(data);
    467                 asn1_pop_tag(data);
     467                        if (!asn1_write_OctetString(data, r->attributes[i],
     468                                               strlen(r->attributes[i]))) goto err;
     469                }
     470                if (!asn1_pop_tag(data)) goto err;
     471                if (!asn1_pop_tag(data)) goto err;
    468472                break;
    469473        }
    470474        case LDAP_TAG_SearchResultEntry: {
    471475                struct ldap_SearchResEntry *r = &msg->r.SearchResultEntry;
    472                 asn1_push_tag(data, ASN1_APPLICATION(msg->type));
    473                 asn1_write_OctetString(data, r->dn, strlen(r->dn));
    474                 asn1_push_tag(data, ASN1_SEQUENCE(0));
     476                if (!asn1_push_tag(data, ASN1_APPLICATION(msg->type))) goto err;
     477                if (!asn1_write_OctetString(data, r->dn, strlen(r->dn))) goto err;
     478                if (!asn1_push_tag(data, ASN1_SEQUENCE(0))) goto err;
    475479                for (i=0; i<r->num_attributes; i++) {
    476480                        struct ldb_message_element *attr = &r->attributes[i];
    477                         asn1_push_tag(data, ASN1_SEQUENCE(0));
    478                         asn1_write_OctetString(data, attr->name,
    479                                                strlen(attr->name));
    480                         asn1_push_tag(data, ASN1_SEQUENCE(1));
     481                        if (!asn1_push_tag(data, ASN1_SEQUENCE(0))) goto err;
     482                        if (!asn1_write_OctetString(data, attr->name,
     483                                               strlen(attr->name))) goto err;
     484                        if (!asn1_push_tag(data, ASN1_SEQUENCE(1))) goto err;
    481485                        for (j=0; j<attr->num_values; j++) {
    482                                 asn1_write_OctetString(data,
     486                                if (!asn1_write_OctetString(data,
    483487                                                       attr->values[j].data,
    484                                                        attr->values[j].length);
    485                         }
    486                         asn1_pop_tag(data);
    487                         asn1_pop_tag(data);
    488                 }
    489                 asn1_pop_tag(data);
    490                 asn1_pop_tag(data);
     488                                                       attr->values[j].length)) goto err;
     489                        }
     490                        if (!asn1_pop_tag(data)) goto err;
     491                        if (!asn1_pop_tag(data)) goto err;
     492                }
     493                if (!asn1_pop_tag(data)) goto err;
     494                if (!asn1_pop_tag(data)) goto err;
    491495                break;
    492496        }
    493497        case LDAP_TAG_SearchResultDone: {
    494498                struct ldap_Result *r = &msg->r.SearchResultDone;
    495                 asn1_push_tag(data, ASN1_APPLICATION(msg->type));
    496                 ldap_encode_response(data, r);
    497                 asn1_pop_tag(data);
     499                if (!asn1_push_tag(data, ASN1_APPLICATION(msg->type))) goto err;
     500                if (!ldap_encode_response(data, r)) goto err;
     501                if (!asn1_pop_tag(data)) goto err;
    498502                break;
    499503        }
    500504        case LDAP_TAG_ModifyRequest: {
    501505                struct ldap_ModifyRequest *r = &msg->r.ModifyRequest;
    502                 asn1_push_tag(data, ASN1_APPLICATION(msg->type));
    503                 asn1_write_OctetString(data, r->dn, strlen(r->dn));
    504                 asn1_push_tag(data, ASN1_SEQUENCE(0));
     506                if (!asn1_push_tag(data, ASN1_APPLICATION(msg->type))) goto err;
     507                if (!asn1_write_OctetString(data, r->dn, strlen(r->dn))) goto err;
     508                if (!asn1_push_tag(data, ASN1_SEQUENCE(0))) goto err;
    505509
    506510                for (i=0; i<r->num_mods; i++) {
    507511                        struct ldb_message_element *attrib = &r->mods[i].attrib;
    508                         asn1_push_tag(data, ASN1_SEQUENCE(0));
    509                         asn1_write_enumerated(data, r->mods[i].type);
    510                         asn1_push_tag(data, ASN1_SEQUENCE(0));
    511                         asn1_write_OctetString(data, attrib->name,
    512                                                strlen(attrib->name));
    513                         asn1_push_tag(data, ASN1_SET);
     512                        if (!asn1_push_tag(data, ASN1_SEQUENCE(0))) goto err;
     513                        if (!asn1_write_enumerated(data, r->mods[i].type)) goto err;
     514                        if (!asn1_push_tag(data, ASN1_SEQUENCE(0))) goto err;
     515                        if (!asn1_write_OctetString(data, attrib->name,
     516                                               strlen(attrib->name))) goto err;
     517                        if (!asn1_push_tag(data, ASN1_SET)) goto err;
    514518                        for (j=0; j<attrib->num_values; j++) {
    515                                 asn1_write_OctetString(data,
     519                                if (!asn1_write_OctetString(data,
    516520                                                       attrib->values[j].data,
    517                                                        attrib->values[j].length);
     521                                                       attrib->values[j].length)) goto err;
    518522       
    519523                        }
    520                         asn1_pop_tag(data);
    521                         asn1_pop_tag(data);
    522                         asn1_pop_tag(data);
     524                        if (!asn1_pop_tag(data)) goto err;
     525                        if (!asn1_pop_tag(data)) goto err;
     526                        if (!asn1_pop_tag(data)) goto err;
    523527                }
    524528               
    525                 asn1_pop_tag(data);
    526                 asn1_pop_tag(data);
     529                if (!asn1_pop_tag(data)) goto err;
     530                if (!asn1_pop_tag(data)) goto err;
    527531                break;
    528532        }
    529533        case LDAP_TAG_ModifyResponse: {
    530534                struct ldap_Result *r = &msg->r.ModifyResponse;
    531                 asn1_push_tag(data, ASN1_APPLICATION(msg->type));
    532                 ldap_encode_response(data, r);
    533                 asn1_pop_tag(data);
     535                if (!asn1_push_tag(data, ASN1_APPLICATION(msg->type))) goto err;
     536                if (!ldap_encode_response(data, r)) goto err;
     537                if (!asn1_pop_tag(data)) goto err;
    534538                break;
    535539        }
    536540        case LDAP_TAG_AddRequest: {
    537541                struct ldap_AddRequest *r = &msg->r.AddRequest;
    538                 asn1_push_tag(data, ASN1_APPLICATION(msg->type));
    539                 asn1_write_OctetString(data, r->dn, strlen(r->dn));
    540                 asn1_push_tag(data, ASN1_SEQUENCE(0));
     542                if (!asn1_push_tag(data, ASN1_APPLICATION(msg->type))) goto err;
     543                if (!asn1_write_OctetString(data, r->dn, strlen(r->dn))) goto err;
     544                if (!asn1_push_tag(data, ASN1_SEQUENCE(0))) goto err;
    541545
    542546                for (i=0; i<r->num_attributes; i++) {
    543547                        struct ldb_message_element *attrib = &r->attributes[i];
    544                         asn1_push_tag(data, ASN1_SEQUENCE(0));
    545                         asn1_write_OctetString(data, attrib->name,
    546                                                strlen(attrib->name));
    547                         asn1_push_tag(data, ASN1_SET);
     548                        if (!asn1_push_tag(data, ASN1_SEQUENCE(0))) goto err;
     549                        if (!asn1_write_OctetString(data, attrib->name,
     550                                               strlen(attrib->name))) goto err;
     551                        if (!asn1_push_tag(data, ASN1_SET)) goto err;
    548552                        for (j=0; j<r->attributes[i].num_values; j++) {
    549                                 asn1_write_OctetString(data,
     553                                if (!asn1_write_OctetString(data,
    550554                                                       attrib->values[j].data,
    551                                                        attrib->values[j].length);
    552                         }
    553                         asn1_pop_tag(data);
    554                         asn1_pop_tag(data);
    555                 }
    556                 asn1_pop_tag(data);
    557                 asn1_pop_tag(data);
     555                                                       attrib->values[j].length)) goto err;
     556                        }
     557                        if (!asn1_pop_tag(data)) goto err;
     558                        if (!asn1_pop_tag(data)) goto err;
     559                }
     560                if (!asn1_pop_tag(data)) goto err;
     561                if (!asn1_pop_tag(data)) goto err;
    558562                break;
    559563        }
    560564        case LDAP_TAG_AddResponse: {
    561565                struct ldap_Result *r = &msg->r.AddResponse;
    562                 asn1_push_tag(data, ASN1_APPLICATION(msg->type));
    563                 ldap_encode_response(data, r);
    564                 asn1_pop_tag(data);
     566                if (!asn1_push_tag(data, ASN1_APPLICATION(msg->type))) goto err;
     567                if (!ldap_encode_response(data, r)) goto err;
     568                if (!asn1_pop_tag(data)) goto err;
    565569                break;
    566570        }
    567571        case LDAP_TAG_DelRequest: {
    568572                struct ldap_DelRequest *r = &msg->r.DelRequest;
    569                 asn1_push_tag(data, ASN1_APPLICATION_SIMPLE(msg->type));
    570                 asn1_write(data, r->dn, strlen(r->dn));
    571                 asn1_pop_tag(data);
     573                if (!asn1_push_tag(data, ASN1_APPLICATION_SIMPLE(msg->type))) goto err;
     574                if (!asn1_write(data, r->dn, strlen(r->dn))) goto err;
     575                if (!asn1_pop_tag(data)) goto err;
    572576                break;
    573577        }
    574578        case LDAP_TAG_DelResponse: {
    575579                struct ldap_Result *r = &msg->r.DelResponse;
    576                 asn1_push_tag(data, ASN1_APPLICATION(msg->type));
    577                 ldap_encode_response(data, r);
    578                 asn1_pop_tag(data);
     580                if (!asn1_push_tag(data, ASN1_APPLICATION(msg->type))) goto err;
     581                if (!ldap_encode_response(data, r)) goto err;
     582                if (!asn1_pop_tag(data)) goto err;
    579583                break;
    580584        }
    581585        case LDAP_TAG_ModifyDNRequest: {
    582586                struct ldap_ModifyDNRequest *r = &msg->r.ModifyDNRequest;
    583                 asn1_push_tag(data, ASN1_APPLICATION(msg->type));
    584                 asn1_write_OctetString(data, r->dn, strlen(r->dn));
    585                 asn1_write_OctetString(data, r->newrdn, strlen(r->newrdn));
    586                 asn1_write_BOOLEAN(data, r->deleteolddn);
     587                if (!asn1_push_tag(data, ASN1_APPLICATION(msg->type))) goto err;
     588                if (!asn1_write_OctetString(data, r->dn, strlen(r->dn))) goto err;
     589                if (!asn1_write_OctetString(data, r->newrdn, strlen(r->newrdn))) goto err;
     590                if (!asn1_write_BOOLEAN(data, r->deleteolddn)) goto err;
    587591                if (r->newsuperior) {
    588                         asn1_push_tag(data, ASN1_CONTEXT_SIMPLE(0));
    589                         asn1_write(data, r->newsuperior,
    590                                    strlen(r->newsuperior));
    591                         asn1_pop_tag(data);
    592                 }
    593                 asn1_pop_tag(data);
     592                        if (!asn1_push_tag(data, ASN1_CONTEXT_SIMPLE(0))) goto err;
     593                        if (!asn1_write(data, r->newsuperior,
     594                                   strlen(r->newsuperior))) goto err;
     595                        if (!asn1_pop_tag(data)) goto err;
     596                }
     597                if (!asn1_pop_tag(data)) goto err;
    594598                break;
    595599        }
    596600        case LDAP_TAG_ModifyDNResponse: {
    597601                struct ldap_Result *r = &msg->r.ModifyDNResponse;
    598                 asn1_push_tag(data, ASN1_APPLICATION(msg->type));
    599                 ldap_encode_response(data, r);
    600                 asn1_pop_tag(data);
     602                if (!asn1_push_tag(data, ASN1_APPLICATION(msg->type))) goto err;
     603                if (!ldap_encode_response(data, r)) goto err;
     604                if (!asn1_pop_tag(data)) goto err;
    601605                break;
    602606        }
    603607        case LDAP_TAG_CompareRequest: {
    604608                struct ldap_CompareRequest *r = &msg->r.CompareRequest;
    605                 asn1_push_tag(data, ASN1_APPLICATION(msg->type));
    606                 asn1_write_OctetString(data, r->dn, strlen(r->dn));
    607                 asn1_push_tag(data, ASN1_SEQUENCE(0));
    608                 asn1_write_OctetString(data, r->attribute,
    609                                        strlen(r->attribute));
    610                 asn1_write_OctetString(data, r->value.data,
    611                                        r->value.length);
    612                 asn1_pop_tag(data);
    613                 asn1_pop_tag(data);
     609                if (!asn1_push_tag(data, ASN1_APPLICATION(msg->type))) goto err;
     610                if (!asn1_write_OctetString(data, r->dn, strlen(r->dn))) goto err;
     611                if (!asn1_push_tag(data, ASN1_SEQUENCE(0))) goto err;
     612                if (!asn1_write_OctetString(data, r->attribute,
     613                                       strlen(r->attribute))) goto err;
     614                if (!asn1_write_OctetString(data, r->value.data,
     615                                       r->value.length)) goto err;
     616                if (!asn1_pop_tag(data)) goto err;
     617                if (!asn1_pop_tag(data)) goto err;
    614618                break;
    615619        }
    616620        case LDAP_TAG_CompareResponse: {
    617621                struct ldap_Result *r = &msg->r.ModifyDNResponse;
    618                 asn1_push_tag(data, ASN1_APPLICATION(msg->type));
    619                 ldap_encode_response(data, r);
    620                 asn1_pop_tag(data);
     622                if (!asn1_push_tag(data, ASN1_APPLICATION(msg->type))) goto err;
     623                if (!ldap_encode_response(data, r)) goto err;
     624                if (!asn1_pop_tag(data)) goto err;
    621625                break;
    622626        }
    623627        case LDAP_TAG_AbandonRequest: {
    624628                struct ldap_AbandonRequest *r = &msg->r.AbandonRequest;
    625                 asn1_push_tag(data, ASN1_APPLICATION_SIMPLE(msg->type));
    626                 asn1_write_implicit_Integer(data, r->messageid);
    627                 asn1_pop_tag(data);
     629                if (!asn1_push_tag(data, ASN1_APPLICATION_SIMPLE(msg->type))) goto err;
     630                if (!asn1_write_implicit_Integer(data, r->messageid)) goto err;
     631                if (!asn1_pop_tag(data)) goto err;
    628632                break;
    629633        }
    630634        case LDAP_TAG_SearchResultReference: {
    631635                struct ldap_SearchResRef *r = &msg->r.SearchResultReference;
    632                 asn1_push_tag(data, ASN1_APPLICATION(msg->type));
    633                 asn1_write_OctetString(data, r->referral, strlen(r->referral));
    634                 asn1_pop_tag(data);
     636                if (!asn1_push_tag(data, ASN1_APPLICATION(msg->type))) goto err;
     637                if (!asn1_write_OctetString(data, r->referral, strlen(r->referral))) goto err;
     638                if (!asn1_pop_tag(data)) goto err;
    635639                break;
    636640        }
    637641        case LDAP_TAG_ExtendedRequest: {
    638642                struct ldap_ExtendedRequest *r = &msg->r.ExtendedRequest;
    639                 asn1_push_tag(data, ASN1_APPLICATION(msg->type));
    640                 asn1_push_tag(data, ASN1_CONTEXT_SIMPLE(0));
    641                 asn1_write(data, r->oid, strlen(r->oid));
    642                 asn1_pop_tag(data);
     643                if (!asn1_push_tag(data, ASN1_APPLICATION(msg->type))) goto err;
     644                if (!asn1_push_tag(data, ASN1_CONTEXT_SIMPLE(0))) goto err;
     645                if (!asn1_write(data, r->oid, strlen(r->oid))) goto err;
     646                if (!asn1_pop_tag(data)) goto err;
    643647                if (r->value) {
    644                         asn1_push_tag(data, ASN1_CONTEXT_SIMPLE(1));
    645                         asn1_write(data, r->value->data, r->value->length);
    646                         asn1_pop_tag(data);
    647                 }
    648                 asn1_pop_tag(data);
     648                        if (!asn1_push_tag(data, ASN1_CONTEXT_SIMPLE(1))) goto err;
     649                        if (!asn1_write(data, r->value->data, r->value->length)) goto err;
     650                        if (!asn1_pop_tag(data)) goto err;
     651                }
     652                if (!asn1_pop_tag(data)) goto err;
    649653                break;
    650654        }
    651655        case LDAP_TAG_ExtendedResponse: {
    652656                struct ldap_ExtendedResponse *r = &msg->r.ExtendedResponse;
    653                 asn1_push_tag(data, ASN1_APPLICATION(msg->type));
    654                 ldap_encode_response(data, &r->response);
     657                if (!asn1_push_tag(data, ASN1_APPLICATION(msg->type))) goto err;
     658                if (!ldap_encode_response(data, &r->response)) goto err;
    655659                if (r->oid) {
    656                         asn1_push_tag(data, ASN1_CONTEXT_SIMPLE(10));
    657                         asn1_write(data, r->oid, strlen(r->oid));
    658                         asn1_pop_tag(data);
     660                        if (!asn1_push_tag(data, ASN1_CONTEXT_SIMPLE(10))) goto err;
     661                        if (!asn1_write(data, r->oid, strlen(r->oid))) goto err;
     662                        if (!asn1_pop_tag(data)) goto err;
    659663                }
    660664                if (r->value) {
    661                         asn1_push_tag(data, ASN1_CONTEXT_SIMPLE(11));
    662                         asn1_write(data, r->value->data, r->value->length);
    663                         asn1_pop_tag(data);
    664                 }
    665                 asn1_pop_tag(data);
     665                        if (!asn1_push_tag(data, ASN1_CONTEXT_SIMPLE(11))) goto err;
     666                        if (!asn1_write(data, r->value->data, r->value->length)) goto err;
     667                        if (!asn1_pop_tag(data)) goto err;
     668                }
     669                if (!asn1_pop_tag(data)) goto err;
    666670                break;
    667671        }
    668672        default:
    669                 return false;
     673                goto err;
    670674        }
    671675
    672676        if (msg->controls != NULL) {
    673                 asn1_push_tag(data, ASN1_CONTEXT(0));
     677                if (!asn1_push_tag(data, ASN1_CONTEXT(0))) goto err;
    674678               
    675679                for (i = 0; msg->controls[i] != NULL; i++) {
     
    677681                                                 control_handlers,
    678682                                                 msg->controls[i])) {
    679                                 DEBUG(1,("Unable to encode control %s\n",
     683                                DEBUG(0,("Unable to encode control %s\n",
    680684                                         msg->controls[i]->oid));
    681                                 return false;
    682                         }
    683                 }
    684 
    685                 asn1_pop_tag(data);
    686         }
    687 
    688         asn1_pop_tag(data);
    689 
    690         if (data->has_error) {
    691                 asn1_free(data);
    692                 return false;
    693         }
    694 
    695         *result = data_blob_talloc(mem_ctx, data->data, data->length);
     685                                goto err;
     686                        }
     687                }
     688
     689                if (!asn1_pop_tag(data)) goto err;
     690        }
     691
     692        if (!asn1_pop_tag(data)) goto err;
     693
     694        if (!asn1_extract_blob(data, mem_ctx, result)) {
     695                goto err;
     696        }
     697
    696698        asn1_free(data);
     699
    697700        return true;
     701
     702  err:
     703
     704        asn1_free(data);
     705        return false;
    698706}
    699707
     
    702710{
    703711        char *result = talloc_array(mem_ctx, char, blob.length+1);
     712        if (result == NULL) {
     713                return NULL;
     714        }
    704715        memcpy(result, blob.data, blob.length);
    705716        result[blob.length] = '\0';
     
    716727        *result = blob2string_talloc(mem_ctx, string);
    717728        data_blob_free(&string);
    718         return true;
    719 }
    720 
    721 static void ldap_decode_response(TALLOC_CTX *mem_ctx,
     729        return *result ? true : false;
     730}
     731
     732static bool ldap_decode_response(TALLOC_CTX *mem_ctx,
    722733                                 struct asn1_data *data,
    723734                                 struct ldap_Result *result)
    724735{
    725         asn1_read_enumerated(data, &result->resultcode);
    726         asn1_read_OctetString_talloc(mem_ctx, data, &result->dn);
    727         asn1_read_OctetString_talloc(mem_ctx, data, &result->errormessage);
     736        if (!asn1_read_enumerated(data, &result->resultcode)) return false;
     737        if (!asn1_read_OctetString_talloc(mem_ctx, data, &result->dn)) return false;
     738        if (!asn1_read_OctetString_talloc(mem_ctx, data, &result->errormessage)) return false;
    728739        if (asn1_peek_tag(data, ASN1_CONTEXT(3))) {
    729                 asn1_start_tag(data, ASN1_CONTEXT(3));
    730                 asn1_read_OctetString_talloc(mem_ctx, data, &result->referral);
    731                 asn1_end_tag(data);
     740                if (!asn1_start_tag(data, ASN1_CONTEXT(3))) return false;
     741                if (!asn1_read_OctetString_talloc(mem_ctx, data, &result->referral)) return false;
     742                if (!asn1_end_tag(data)) return false;
    732743        } else {
    733744                result->referral = NULL;
    734745        }
     746        return true;
    735747}
    736748
     
    754766        chunks[chunk_num]->length = strlen(value);
    755767
    756         chunks[chunk_num + 1] = '\0';
     768        chunks[chunk_num + 1] = NULL;
    757769
    758770        return chunks;
     
    833845                DATA_BLOB value;
    834846
    835                 asn1_start_tag(data, ASN1_CONTEXT(filter_tag));
    836                 asn1_read_OctetString_talloc(mem_ctx, data, &attrib);
    837                 asn1_read_OctetString(data, mem_ctx, &value);
    838                 asn1_end_tag(data);
    839                 if ((data->has_error) || (attrib == NULL) || (value.data == NULL)) {
     847                if (!asn1_start_tag(data, ASN1_CONTEXT(filter_tag))) goto failed;
     848                if (!asn1_read_OctetString_talloc(mem_ctx, data, &attrib)) goto failed;
     849                if (!asn1_read_OctetString(data, mem_ctx, &value)) goto failed;
     850                if (!asn1_end_tag(data)) goto failed;
     851                if (asn1_has_error(data) || (attrib == NULL) ||
     852                    (value.data == NULL)) {
    840853                        goto failed;
    841854                }
     
    863876                ret->operation = LDB_OP_SUBSTRING;
    864877                ret->u.substring.attr = talloc_strndup(ret, (char *)attr.data, attr.length);
     878                if (ret->u.substring.attr == NULL) {
     879                        goto failed;
     880                }
    865881                ret->u.substring.chunks = NULL;
    866882                ret->u.substring.start_with_wildcard = 1;
     
    872888
    873889                while (asn1_tag_remaining(data)) {
    874                         asn1_peek_uint8(data, &subs_tag);
     890                        if (!asn1_peek_uint8(data, &subs_tag)) goto failed;
    875891                        subs_tag &= 0x1f;       /* strip off the asn1 stuff */
    876892                        if (subs_tag > 2) goto failed;
    877893
    878                         asn1_start_tag(data, ASN1_CONTEXT_SIMPLE(subs_tag));
    879                         asn1_read_LDAPString(data, mem_ctx, &value);
    880                         asn1_end_tag(data);
     894                        if (!asn1_start_tag(data, ASN1_CONTEXT_SIMPLE(subs_tag))) goto failed;
     895                        if (!asn1_read_LDAPString(data, mem_ctx, &value)) goto failed;
     896                        if (!asn1_end_tag(data)) goto failed;
    881897
    882898                        switch (subs_tag) {
     
    945961                DATA_BLOB value;
    946962
    947                 asn1_start_tag(data, ASN1_CONTEXT(filter_tag));
    948                 asn1_read_OctetString_talloc(mem_ctx, data, &attrib);
    949                 asn1_read_OctetString(data, mem_ctx, &value);
    950                 asn1_end_tag(data);
    951                 if ((data->has_error) || (attrib == NULL) || (value.data == NULL)) {
     963                if (!asn1_start_tag(data, ASN1_CONTEXT(filter_tag))) goto failed;
     964                if (!asn1_read_OctetString_talloc(mem_ctx, data, &attrib)) goto failed;
     965                if (!asn1_read_OctetString(data, mem_ctx, &value)) goto failed;
     966                if (!asn1_end_tag(data)) goto failed;
     967                if (asn1_has_error(data) || (attrib == NULL) ||
     968                    (value.data == NULL)) {
    952969                        goto failed;
    953970                }
     
    964981                DATA_BLOB value;
    965982
    966                 asn1_start_tag(data, ASN1_CONTEXT(filter_tag));
    967                 asn1_read_OctetString_talloc(mem_ctx, data, &attrib);
    968                 asn1_read_OctetString(data, mem_ctx, &value);
    969                 asn1_end_tag(data);
    970                 if ((data->has_error) || (attrib == NULL) || (value.data == NULL)) {
     983                if (!asn1_start_tag(data, ASN1_CONTEXT(filter_tag))) goto failed;
     984                if (!asn1_read_OctetString_talloc(mem_ctx, data, &attrib)) goto failed;
     985                if (!asn1_read_OctetString(data, mem_ctx, &value)) goto failed;
     986                if (!asn1_end_tag(data)) goto failed;
     987                if (asn1_has_error(data) || (attrib == NULL) ||
     988                    (value.data == NULL)) {
    971989                        goto failed;
    972990                }
     
    10021020                DATA_BLOB value;
    10031021
    1004                 asn1_start_tag(data, ASN1_CONTEXT(filter_tag));
    1005                 asn1_read_OctetString_talloc(mem_ctx, data, &attrib);
    1006                 asn1_read_OctetString(data, mem_ctx, &value);
    1007                 asn1_end_tag(data);
    1008                 if ((data->has_error) || (attrib == NULL) || (value.data == NULL)) {
     1022                if (!asn1_start_tag(data, ASN1_CONTEXT(filter_tag))) goto failed;
     1023                if (!asn1_read_OctetString_talloc(mem_ctx, data, &attrib)) goto failed;
     1024                if (!asn1_read_OctetString(data, mem_ctx, &value)) goto failed;
     1025                if (!asn1_end_tag(data)) goto failed;
     1026                if (asn1_has_error(data) || (attrib == NULL) ||
     1027                    (value.data == NULL)) {
    10091028                        goto failed;
    10101029                }
     
    10281047                /* either oid or type must be defined */
    10291048                if (asn1_peek_tag(data, ASN1_CONTEXT_SIMPLE(1))) { /* optional */
    1030                         asn1_start_tag(data, ASN1_CONTEXT_SIMPLE(1));
    1031                         asn1_read_LDAPString(data, ret, &oid);
    1032                         asn1_end_tag(data);
     1049                        if (!asn1_start_tag(data, ASN1_CONTEXT_SIMPLE(1))) goto failed;
     1050                        if (!asn1_read_LDAPString(data, ret, &oid)) goto failed;
     1051                        if (!asn1_end_tag(data)) goto failed;
    10331052                }
    10341053                if (asn1_peek_tag(data, ASN1_CONTEXT_SIMPLE(2))) {      /* optional  */
    1035                         asn1_start_tag(data, ASN1_CONTEXT_SIMPLE(2));
    1036                         asn1_read_LDAPString(data, ret, &attr);
    1037                         asn1_end_tag(data);
    1038                 }
    1039                 asn1_start_tag(data, ASN1_CONTEXT_SIMPLE(3));
    1040                 asn1_read_LDAPString(data, ret, &value);
    1041                 asn1_end_tag(data);
     1054                        if (!asn1_start_tag(data, ASN1_CONTEXT_SIMPLE(2))) goto failed;
     1055                        if (!asn1_read_LDAPString(data, ret, &attr)) goto failed;
     1056                        if (!asn1_end_tag(data)) goto failed;
     1057                }
     1058                if (!asn1_start_tag(data, ASN1_CONTEXT_SIMPLE(3))) goto failed;
     1059                if (!asn1_read_LDAPString(data, ret, &value)) goto failed;
     1060                if (!asn1_end_tag(data)) goto failed;
    10421061                /* dnAttributes is marked as BOOLEAN DEFAULT FALSE
    10431062                   it is not marked as OPTIONAL but openldap tools
     
    10471066                   boolean value to be set */
    10481067                if (asn1_peek_tag(data, ASN1_CONTEXT_SIMPLE(4))) {
    1049                         asn1_start_tag(data, ASN1_CONTEXT_SIMPLE(4));
    1050                         asn1_read_uint8(data, &dnAttributes);
    1051                         asn1_end_tag(data);
     1068                        if (!asn1_start_tag(data, ASN1_CONTEXT_SIMPLE(4))) goto failed;
     1069                        if (!asn1_read_uint8(data, &dnAttributes)) goto failed;
     1070                        if (!asn1_end_tag(data)) goto failed;
    10521071                } else {
    10531072                        dnAttributes = 0;
     
    10681087                        } else {
    10691088                                ret->u.extended.attr = talloc_strdup(ret, "*");
     1089                                if (ret->u.extended.attr == NULL) {
     1090                                        goto failed;
     1091                                }
    10701092                        }
    10711093                        ret->u.extended.rule_id      = talloc_steal(ret, oid);
     
    10971119
    10981120/* Decode a single LDAP attribute, possibly containing multiple values */
    1099 static void ldap_decode_attrib(TALLOC_CTX *mem_ctx, struct asn1_data *data,
     1121static bool ldap_decode_attrib(TALLOC_CTX *mem_ctx, struct asn1_data *data,
    11001122                               struct ldb_message_element *attrib)
    11011123{
    1102         asn1_start_tag(data, ASN1_SEQUENCE(0));
    1103         asn1_read_OctetString_talloc(mem_ctx, data, &attrib->name);
    1104         asn1_start_tag(data, ASN1_SET);
     1124        if (!asn1_start_tag(data, ASN1_SEQUENCE(0))) return false;
     1125        if (!asn1_read_OctetString_talloc(mem_ctx, data, &attrib->name)) return false;
     1126        if (!asn1_start_tag(data, ASN1_SET)) return false;
    11051127        while (asn1_peek_tag(data, ASN1_OCTET_STRING)) {
    11061128                DATA_BLOB blob;
    1107                 asn1_read_OctetString(data, mem_ctx, &blob);
     1129                if (!asn1_read_OctetString(data, mem_ctx, &blob)) return false;
    11081130                add_value_to_attrib(mem_ctx, &blob, attrib);
    11091131        }
    1110         asn1_end_tag(data);
    1111         asn1_end_tag(data);
    1112        
     1132        if (!asn1_end_tag(data)) return false;
     1133        return asn1_end_tag(data);
    11131134}
    11141135
    11151136/* Decode a set of LDAP attributes, as found in the dereference control */
    1116 void ldap_decode_attribs_bare(TALLOC_CTX *mem_ctx, struct asn1_data *data,
     1137bool ldap_decode_attribs_bare(TALLOC_CTX *mem_ctx, struct asn1_data *data,
    11171138                              struct ldb_message_element **attributes,
    11181139                              int *num_attributes)
     
    11211142                struct ldb_message_element attrib;
    11221143                ZERO_STRUCT(attrib);
    1123                 ldap_decode_attrib(mem_ctx, data, &attrib);
     1144                if (!ldap_decode_attrib(mem_ctx, data, &attrib)) return false;
    11241145                add_attrib_to_array_talloc(mem_ctx, &attrib,
    11251146                                           attributes, num_attributes);
    11261147        }
     1148        return true;
    11271149}
    11281150
    11291151/* Decode a set of LDAP attributes, as found in a search entry */
    1130 static void ldap_decode_attribs(TALLOC_CTX *mem_ctx, struct asn1_data *data,
     1152static bool ldap_decode_attribs(TALLOC_CTX *mem_ctx, struct asn1_data *data,
    11311153                                struct ldb_message_element **attributes,
    11321154                                int *num_attributes)
    11331155{
    1134         asn1_start_tag(data, ASN1_SEQUENCE(0));
    1135         ldap_decode_attribs_bare(mem_ctx, data,
    1136                                  attributes, num_attributes);
    1137         asn1_end_tag(data);
     1156        if (!asn1_start_tag(data, ASN1_SEQUENCE(0))) return false;
     1157        if (!ldap_decode_attribs_bare(mem_ctx, data,
     1158                                 attributes, num_attributes)) return false;
     1159        return asn1_end_tag(data);
    11381160}
    11391161
     
    11461168        uint8_t tag;
    11471169
    1148         asn1_start_tag(data, ASN1_SEQUENCE(0));
    1149         asn1_read_Integer(data, &msg->messageid);
    1150 
    1151         if (!asn1_peek_uint8(data, &tag))
    1152                 return NT_STATUS_LDAP(LDAP_PROTOCOL_ERROR);
     1170        if (!asn1_start_tag(data, ASN1_SEQUENCE(0))) goto prot_err;
     1171        if (!asn1_read_Integer(data, &msg->messageid)) goto prot_err;
     1172
     1173        if (!asn1_peek_uint8(data, &tag)) goto prot_err;
    11531174
    11541175        switch(tag) {
     
    11571178                struct ldap_BindRequest *r = &msg->r.BindRequest;
    11581179                msg->type = LDAP_TAG_BindRequest;
    1159                 asn1_start_tag(data, tag);
    1160                 asn1_read_Integer(data, &r->version);
    1161                 asn1_read_OctetString_talloc(msg, data, &r->dn);
     1180                if (!asn1_start_tag(data, tag)) goto prot_err;
     1181                if (!asn1_read_Integer(data, &r->version)) goto prot_err;
     1182                if (!asn1_read_OctetString_talloc(msg, data, &r->dn)) goto prot_err;
    11621183                if (asn1_peek_tag(data, ASN1_CONTEXT_SIMPLE(0))) {
    11631184                        int pwlen;
    11641185                        r->creds.password = "";
    11651186                        r->mechanism = LDAP_AUTH_MECH_SIMPLE;
    1166                         asn1_start_tag(data, ASN1_CONTEXT_SIMPLE(0));
     1187                        if (!asn1_start_tag(data, ASN1_CONTEXT_SIMPLE(0))) goto prot_err;
    11671188                        pwlen = asn1_tag_remaining(data);
    11681189                        if (pwlen == -1) {
    1169                                 return NT_STATUS_LDAP(LDAP_PROTOCOL_ERROR);
     1190                                goto prot_err;
    11701191                        }
    11711192                        if (pwlen != 0) {
     
    11741195                                        return NT_STATUS_LDAP(LDAP_OPERATIONS_ERROR);
    11751196                                }
    1176                                 asn1_read(data, pw, pwlen);
     1197                                if (!asn1_read(data, pw, pwlen)) goto prot_err;
    11771198                                pw[pwlen] = '\0';
    11781199                                r->creds.password = pw;
    11791200                        }
    1180                         asn1_end_tag(data);
     1201                        if (!asn1_end_tag(data)) goto prot_err;
    11811202                } else if (asn1_peek_tag(data, ASN1_CONTEXT(3))){
    1182                         asn1_start_tag(data, ASN1_CONTEXT(3));
     1203                        if (!asn1_start_tag(data, ASN1_CONTEXT(3))) goto prot_err;
    11831204                        r->mechanism = LDAP_AUTH_MECH_SASL;
    1184                         asn1_read_OctetString_talloc(msg, data, &r->creds.SASL.mechanism);
     1205                        if (!asn1_read_OctetString_talloc(msg, data, &r->creds.SASL.mechanism)) goto prot_err;
    11851206                        if (asn1_peek_tag(data, ASN1_OCTET_STRING)) { /* optional */
    11861207                                DATA_BLOB tmp_blob = data_blob(NULL, 0);
    1187                                 asn1_read_OctetString(data, msg, &tmp_blob);
     1208                                if (!asn1_read_OctetString(data, msg, &tmp_blob)) goto prot_err;
    11881209                                r->creds.SASL.secblob = talloc(msg, DATA_BLOB);
    11891210                                if (!r->creds.SASL.secblob) {
     
    11961217                                r->creds.SASL.secblob = NULL;
    11971218                        }
    1198                         asn1_end_tag(data);
     1219                        if (!asn1_end_tag(data)) goto prot_err;
    11991220                } else {
    12001221                        /* Neither Simple nor SASL bind */
    1201                         return NT_STATUS_LDAP(LDAP_PROTOCOL_ERROR);
    1202                 }
    1203                 asn1_end_tag(data);
     1222                        goto prot_err;
     1223                }
     1224                if (!asn1_end_tag(data)) goto prot_err;
    12041225                break;
    12051226        }
     
    12081229                struct ldap_BindResponse *r = &msg->r.BindResponse;
    12091230                msg->type = LDAP_TAG_BindResponse;
    1210                 asn1_start_tag(data, tag);
    1211                 ldap_decode_response(msg, data, &r->response);
     1231                if (!asn1_start_tag(data, tag)) goto prot_err;
     1232                if (!ldap_decode_response(msg, data, &r->response)) goto prot_err;
    12121233                if (asn1_peek_tag(data, ASN1_CONTEXT_SIMPLE(7))) {
    12131234                        DATA_BLOB tmp_blob = data_blob(NULL, 0);
    1214                         asn1_read_ContextSimple(data, 7, &tmp_blob);
     1235                        if (!asn1_read_ContextSimple(data, 7, &tmp_blob)) goto prot_err;
    12151236                        r->SASL.secblob = talloc(msg, DATA_BLOB);
    12161237                        if (!r->SASL.secblob) {
     
    12231244                        r->SASL.secblob = NULL;
    12241245                }
    1225                 asn1_end_tag(data);
     1246                if (!asn1_end_tag(data)) goto prot_err;
    12261247                break;
    12271248        }
     
    12291250        case ASN1_APPLICATION_SIMPLE(LDAP_TAG_UnbindRequest): {
    12301251                msg->type = LDAP_TAG_UnbindRequest;
    1231                 asn1_start_tag(data, tag);
    1232                 asn1_end_tag(data);
     1252                if (!asn1_start_tag(data, tag)) goto prot_err;
     1253                if (!asn1_end_tag(data)) goto prot_err;
    12331254                break;
    12341255        }
     
    12391260                const char **attrs = NULL;
    12401261                msg->type = LDAP_TAG_SearchRequest;
    1241                 asn1_start_tag(data, tag);
    1242                 asn1_read_OctetString_talloc(msg, data, &r->basedn);
    1243                 asn1_read_enumerated(data, (int *)(void *)&(r->scope));
    1244                 asn1_read_enumerated(data, (int *)(void *)&(r->deref));
    1245                 asn1_read_Integer(data, &sizelimit);
     1262                if (!asn1_start_tag(data, tag)) goto prot_err;
     1263                if (!asn1_read_OctetString_talloc(msg, data, &r->basedn)) goto prot_err;
     1264                if (!asn1_read_enumerated(data, (int *)(void *)&(r->scope))) goto prot_err;
     1265                if (!asn1_read_enumerated(data, (int *)(void *)&(r->deref))) goto prot_err;
     1266                if (!asn1_read_Integer(data, &sizelimit)) goto prot_err;
    12461267                r->sizelimit = sizelimit;
    1247                 asn1_read_Integer(data, &timelimit);
     1268                if (!asn1_read_Integer(data, &timelimit)) goto prot_err;
    12481269                r->timelimit = timelimit;
    1249                 asn1_read_BOOLEAN(data, &r->attributesonly);
     1270                if (!asn1_read_BOOLEAN(data, &r->attributesonly)) goto prot_err;
    12501271
    12511272                r->tree = ldap_decode_filter_tree(msg, data);
    12521273                if (r->tree == NULL) {
    1253                         return NT_STATUS_LDAP(LDAP_PROTOCOL_ERROR);
    1254                 }
    1255 
    1256                 asn1_start_tag(data, ASN1_SEQUENCE(0));
     1274                        goto prot_err;
     1275                }
     1276
     1277                if (!asn1_start_tag(data, ASN1_SEQUENCE(0))) goto prot_err;
    12571278
    12581279                r->num_attributes = 0;
    12591280                r->attributes = NULL;
    12601281
    1261                 while (asn1_tag_remaining(data) > 0) {                                 
     1282                while (asn1_tag_remaining(data) > 0) {
    12621283
    12631284                        const char *attr;
    12641285                        if (!asn1_read_OctetString_talloc(msg, data,
    12651286                                                          &attr))
    1266                                 return NT_STATUS_LDAP(LDAP_PROTOCOL_ERROR);
     1287                                goto prot_err;
    12671288                        if (!add_string_to_array(msg, attr,
    12681289                                                 &attrs,
    12691290                                                 &r->num_attributes))
    1270                                 return NT_STATUS_LDAP(LDAP_PROTOCOL_ERROR);
     1291                                goto prot_err;
    12711292                }
    12721293                r->attributes = attrs;
    12731294
    1274                 asn1_end_tag(data);
    1275                 asn1_end_tag(data);
     1295                if (!asn1_end_tag(data)) goto prot_err;
     1296                if (!asn1_end_tag(data)) goto prot_err;
    12761297                break;
    12771298        }
     
    12821303                r->attributes = NULL;
    12831304                r->num_attributes = 0;
    1284                 asn1_start_tag(data, tag);
    1285                 asn1_read_OctetString_talloc(msg, data, &r->dn);
    1286                 ldap_decode_attribs(msg, data, &r->attributes,
    1287                                     &r->num_attributes);
    1288                 asn1_end_tag(data);
     1305                if (!asn1_start_tag(data, tag)) goto prot_err;
     1306                if (!asn1_read_OctetString_talloc(msg, data, &r->dn)) goto prot_err;
     1307                if (!ldap_decode_attribs(msg, data, &r->attributes,
     1308                                    &r->num_attributes)) goto prot_err;
     1309                if (!asn1_end_tag(data)) goto prot_err;
    12891310                break;
    12901311        }
     
    12931314                struct ldap_Result *r = &msg->r.SearchResultDone;
    12941315                msg->type = LDAP_TAG_SearchResultDone;
    1295                 asn1_start_tag(data, tag);
    1296                 ldap_decode_response(msg, data, r);
    1297                 asn1_end_tag(data);
     1316                if (!asn1_start_tag(data, tag)) goto prot_err;
     1317                if (!ldap_decode_response(msg, data, r)) goto prot_err;
     1318                if (!asn1_end_tag(data)) goto prot_err;
    12981319                break;
    12991320        }
     
    13021323                struct ldap_SearchResRef *r = &msg->r.SearchResultReference;
    13031324                msg->type = LDAP_TAG_SearchResultReference;
    1304                 asn1_start_tag(data, tag);
    1305                 asn1_read_OctetString_talloc(msg, data, &r->referral);
    1306                 asn1_end_tag(data);
     1325                if (!asn1_start_tag(data, tag)) goto prot_err;
     1326                if (!asn1_read_OctetString_talloc(msg, data, &r->referral)) goto prot_err;
     1327                if (!asn1_end_tag(data)) goto prot_err;
    13071328                break;
    13081329        }
     
    13111332                struct ldap_ModifyRequest *r = &msg->r.ModifyRequest;
    13121333                msg->type = LDAP_TAG_ModifyRequest;
    1313                 asn1_start_tag(data, ASN1_APPLICATION(LDAP_TAG_ModifyRequest));
    1314                 asn1_read_OctetString_talloc(msg, data, &r->dn);
    1315                 asn1_start_tag(data, ASN1_SEQUENCE(0));
     1334                if (!asn1_start_tag(data, ASN1_APPLICATION(LDAP_TAG_ModifyRequest))) goto prot_err;
     1335                if (!asn1_read_OctetString_talloc(msg, data, &r->dn)) goto prot_err;
     1336                if (!asn1_start_tag(data, ASN1_SEQUENCE(0))) goto prot_err;
    13161337
    13171338                r->num_mods = 0;
     
    13221343                        int v;
    13231344                        ZERO_STRUCT(mod);
    1324                         asn1_start_tag(data, ASN1_SEQUENCE(0));
    1325                         asn1_read_enumerated(data, &v);
     1345                        if (!asn1_start_tag(data, ASN1_SEQUENCE(0))) goto prot_err;
     1346                        if (!asn1_read_enumerated(data, &v)) goto prot_err;
    13261347                        mod.type = v;
    1327                         ldap_decode_attrib(msg, data, &mod.attrib);
    1328                         asn1_end_tag(data);
     1348                        if (!ldap_decode_attrib(msg, data, &mod.attrib)) goto prot_err;
     1349                        if (!asn1_end_tag(data)) goto prot_err;
    13291350                        if (!add_mod_to_array_talloc(msg, &mod,
    13301351                                                     &r->mods, &r->num_mods)) {
     
    13331354                }
    13341355
    1335                 asn1_end_tag(data);
    1336                 asn1_end_tag(data);
     1356                if (!asn1_end_tag(data)) goto prot_err;
     1357                if (!asn1_end_tag(data)) goto prot_err;
    13371358                break;
    13381359        }
     
    13411362                struct ldap_Result *r = &msg->r.ModifyResponse;
    13421363                msg->type = LDAP_TAG_ModifyResponse;
    1343                 asn1_start_tag(data, tag);
    1344                 ldap_decode_response(msg, data, r);
    1345                 asn1_end_tag(data);
     1364                if (!asn1_start_tag(data, tag)) goto prot_err;
     1365                if (!ldap_decode_response(msg, data, r)) goto prot_err;
     1366                if (!asn1_end_tag(data)) goto prot_err;
    13461367                break;
    13471368        }
     
    13501371                struct ldap_AddRequest *r = &msg->r.AddRequest;
    13511372                msg->type = LDAP_TAG_AddRequest;
    1352                 asn1_start_tag(data, tag);
    1353                 asn1_read_OctetString_talloc(msg, data, &r->dn);
     1373                if (!asn1_start_tag(data, tag)) goto prot_err;
     1374                if (!asn1_read_OctetString_talloc(msg, data, &r->dn)) goto prot_err;
    13541375
    13551376                r->attributes = NULL;
    13561377                r->num_attributes = 0;
    1357                 ldap_decode_attribs(msg, data, &r->attributes,
    1358                                     &r->num_attributes);
    1359 
    1360                 asn1_end_tag(data);
     1378                if (!ldap_decode_attribs(msg, data, &r->attributes,
     1379                                    &r->num_attributes)) goto prot_err;
     1380
     1381                if (!asn1_end_tag(data)) goto prot_err;
    13611382                break;
    13621383        }
     
    13651386                struct ldap_Result *r = &msg->r.AddResponse;
    13661387                msg->type = LDAP_TAG_AddResponse;
    1367                 asn1_start_tag(data, tag);
    1368                 ldap_decode_response(msg, data, r);
    1369                 asn1_end_tag(data);
     1388                if (!asn1_start_tag(data, tag)) goto prot_err;
     1389                if (!ldap_decode_response(msg, data, r)) goto prot_err;
     1390                if (!asn1_end_tag(data)) goto prot_err;
    13701391                break;
    13711392        }
     
    13761397                char *dn;
    13771398                msg->type = LDAP_TAG_DelRequest;
    1378                 asn1_start_tag(data,
    1379                                ASN1_APPLICATION_SIMPLE(LDAP_TAG_DelRequest));
     1399                if (!asn1_start_tag(data,
     1400                               ASN1_APPLICATION_SIMPLE(LDAP_TAG_DelRequest))) goto prot_err;
    13801401                len = asn1_tag_remaining(data);
    13811402                if (len == -1) {
    1382                         return NT_STATUS_LDAP(LDAP_PROTOCOL_ERROR);
     1403                        goto prot_err;
    13831404                }
    13841405                dn = talloc_array(msg, char, len+1);
    13851406                if (dn == NULL)
    13861407                        break;
    1387                 asn1_read(data, dn, len);
     1408                if (!asn1_read(data, dn, len)) goto prot_err;
    13881409                dn[len] = '\0';
    13891410                r->dn = dn;
    1390                 asn1_end_tag(data);
     1411                if (!asn1_end_tag(data)) goto prot_err;
    13911412                break;
    13921413        }
     
    13951416                struct ldap_Result *r = &msg->r.DelResponse;
    13961417                msg->type = LDAP_TAG_DelResponse;
    1397                 asn1_start_tag(data, tag);
    1398                 ldap_decode_response(msg, data, r);
    1399                 asn1_end_tag(data);
     1418                if (!asn1_start_tag(data, tag)) goto prot_err;
     1419                if (!ldap_decode_response(msg, data, r)) goto prot_err;
     1420                if (!asn1_end_tag(data)) goto prot_err;
    14001421                break;
    14011422        }
     
    14041425                struct ldap_ModifyDNRequest *r = &msg->r.ModifyDNRequest;
    14051426                msg->type = LDAP_TAG_ModifyDNRequest;
    1406                 asn1_start_tag(data,
    1407                                ASN1_APPLICATION(LDAP_TAG_ModifyDNRequest));
    1408                 asn1_read_OctetString_talloc(msg, data, &r->dn);
    1409                 asn1_read_OctetString_talloc(msg, data, &r->newrdn);
    1410                 asn1_read_BOOLEAN(data, &r->deleteolddn);
     1427                if (!asn1_start_tag(data,
     1428                               ASN1_APPLICATION(LDAP_TAG_ModifyDNRequest))) goto prot_err;
     1429                if (!asn1_read_OctetString_talloc(msg, data, &r->dn)) goto prot_err;
     1430                if (!asn1_read_OctetString_talloc(msg, data, &r->newrdn)) goto prot_err;
     1431                if (!asn1_read_BOOLEAN(data, &r->deleteolddn)) goto prot_err;
    14111432                r->newsuperior = NULL;
    14121433                if (asn1_tag_remaining(data) > 0) {
    14131434                        int len;
    14141435                        char *newsup;
    1415                         asn1_start_tag(data, ASN1_CONTEXT_SIMPLE(0));
     1436                        if (!asn1_start_tag(data, ASN1_CONTEXT_SIMPLE(0))) goto prot_err;
    14161437                        len = asn1_tag_remaining(data);
    14171438                        if (len == -1) {
    1418                                 return NT_STATUS_LDAP(LDAP_PROTOCOL_ERROR);
     1439                                goto prot_err;
    14191440                        }
    14201441                        newsup = talloc_array(msg, char, len+1);
     
    14221443                                return NT_STATUS_LDAP(LDAP_OPERATIONS_ERROR);
    14231444                        }
    1424                         asn1_read(data, newsup, len);
     1445                        if (!asn1_read(data, newsup, len)) goto prot_err;
    14251446                        newsup[len] = '\0';
    14261447                        r->newsuperior = newsup;
    1427                         asn1_end_tag(data);
    1428                 }
    1429                 asn1_end_tag(data);
     1448                        if (!asn1_end_tag(data)) goto prot_err;
     1449                }
     1450                if (!asn1_end_tag(data)) goto prot_err;
    14301451                break;
    14311452        }
     
    14341455                struct ldap_Result *r = &msg->r.ModifyDNResponse;
    14351456                msg->type = LDAP_TAG_ModifyDNResponse;
    1436                 asn1_start_tag(data, tag);
    1437                 ldap_decode_response(msg, data, r);
    1438                 asn1_end_tag(data);
     1457                if (!asn1_start_tag(data, tag)) goto prot_err;
     1458                if (!ldap_decode_response(msg, data, r)) goto prot_err;
     1459                if (!asn1_end_tag(data)) goto prot_err;
    14391460                break;
    14401461        }
     
    14431464                struct ldap_CompareRequest *r = &msg->r.CompareRequest;
    14441465                msg->type = LDAP_TAG_CompareRequest;
    1445                 asn1_start_tag(data,
    1446                                ASN1_APPLICATION(LDAP_TAG_CompareRequest));
    1447                 asn1_read_OctetString_talloc(msg, data, &r->dn);
    1448                 asn1_start_tag(data, ASN1_SEQUENCE(0));
    1449                 asn1_read_OctetString_talloc(msg, data, &r->attribute);
    1450                 asn1_read_OctetString(data, msg, &r->value);
     1466                if (!asn1_start_tag(data,
     1467                               ASN1_APPLICATION(LDAP_TAG_CompareRequest))) goto prot_err;
     1468                if (!asn1_read_OctetString_talloc(msg, data, &r->dn)) goto prot_err;
     1469                if (!asn1_start_tag(data, ASN1_SEQUENCE(0))) goto prot_err;
     1470                if (!asn1_read_OctetString_talloc(msg, data, &r->attribute)) goto prot_err;
     1471                if (!asn1_read_OctetString(data, msg, &r->value)) goto prot_err;
    14511472                if (r->value.data) {
    14521473                        talloc_steal(msg, r->value.data);
    14531474                }
    1454                 asn1_end_tag(data);
    1455                 asn1_end_tag(data);
     1475                if (!asn1_end_tag(data)) goto prot_err;
     1476                if (!asn1_end_tag(data)) goto prot_err;
    14561477                break;
    14571478        }
     
    14601481                struct ldap_Result *r = &msg->r.CompareResponse;
    14611482                msg->type = LDAP_TAG_CompareResponse;
    1462                 asn1_start_tag(data, tag);
    1463                 ldap_decode_response(msg, data, r);
    1464                 asn1_end_tag(data);
     1483                if (!asn1_start_tag(data, tag)) goto prot_err;
     1484                if (!ldap_decode_response(msg, data, r)) goto prot_err;
     1485                if (!asn1_end_tag(data)) goto prot_err;
    14651486                break;
    14661487        }
     
    14691490                struct ldap_AbandonRequest *r = &msg->r.AbandonRequest;
    14701491                msg->type = LDAP_TAG_AbandonRequest;
    1471                 asn1_start_tag(data, tag);
    1472                 asn1_read_implicit_Integer(data, &r->messageid);
    1473                 asn1_end_tag(data);
     1492                if (!asn1_start_tag(data, tag)) goto prot_err;
     1493                if (!asn1_read_implicit_Integer(data, &r->messageid)) goto prot_err;
     1494                if (!asn1_end_tag(data)) goto prot_err;
    14741495                break;
    14751496        }
     
    14801501
    14811502                msg->type = LDAP_TAG_ExtendedRequest;
    1482                 asn1_start_tag(data,tag);
     1503                if (!asn1_start_tag(data,tag)) goto prot_err;
    14831504                if (!asn1_read_ContextSimple(data, 0, &tmp_blob)) {
    1484                         return NT_STATUS_LDAP(LDAP_PROTOCOL_ERROR);
     1505                        goto prot_err;
    14851506                }
    14861507                r->oid = blob2string_talloc(msg, tmp_blob);
     
    14911512
    14921513                if (asn1_peek_tag(data, ASN1_CONTEXT_SIMPLE(1))) {
    1493                         asn1_read_ContextSimple(data, 1, &tmp_blob);
     1514                        if (!asn1_read_ContextSimple(data, 1, &tmp_blob)) goto prot_err;
    14941515                        r->value = talloc(msg, DATA_BLOB);
    14951516                        if (!r->value) {
     
    15021523                }
    15031524
    1504                 asn1_end_tag(data);
     1525                if (!asn1_end_tag(data)) goto prot_err;
    15051526                break;
    15061527        }
     
    15111532
    15121533                msg->type = LDAP_TAG_ExtendedResponse;
    1513                 asn1_start_tag(data, tag);             
    1514                 ldap_decode_response(msg, data, &r->response);
     1534                if (!asn1_start_tag(data, tag)) goto prot_err;
     1535                if (!ldap_decode_response(msg, data, &r->response)) goto prot_err;
    15151536
    15161537                if (asn1_peek_tag(data, ASN1_CONTEXT_SIMPLE(10))) {
    1517                         asn1_read_ContextSimple(data, 1, &tmp_blob);
     1538                        if (!asn1_read_ContextSimple(data, 1, &tmp_blob)) goto prot_err;
    15181539                        r->oid = blob2string_talloc(msg, tmp_blob);
    15191540                        data_blob_free(&tmp_blob);
     
    15261547
    15271548                if (asn1_peek_tag(data, ASN1_CONTEXT_SIMPLE(11))) {
    1528                         asn1_read_ContextSimple(data, 1, &tmp_blob);
     1549                        if (!asn1_read_ContextSimple(data, 1, &tmp_blob)) goto prot_err;
    15291550                        r->value = talloc(msg, DATA_BLOB);
    15301551                        if (!r->value) {
     
    15371558                }
    15381559
    1539                 asn1_end_tag(data);
    1540                 break;
    1541         }
    1542         default: 
    1543                 return NT_STATUS_LDAP(LDAP_PROTOCOL_ERROR);
     1560                if (!asn1_end_tag(data)) goto prot_err;
     1561                break;
     1562        }
     1563        default:
     1564                goto prot_err;
    15441565        }
    15451566
     
    15521573                bool *decoded = NULL;
    15531574
    1554                 asn1_start_tag(data, ASN1_CONTEXT(0));
     1575                if (!asn1_start_tag(data, ASN1_CONTEXT(0))) goto prot_err;
    15551576
    15561577                while (asn1_peek_tag(data, ASN1_SEQUENCE(0))) {
     
    15731594                        }
    15741595
    1575                         if (!ldap_decode_control_wrapper(ctrl, data, ctrl[i], &value)) {
    1576                                 return NT_STATUS_LDAP(LDAP_PROTOCOL_ERROR);
    1577                         }
    1578                        
    1579                         if (!ldap_decode_control_value(ctrl, value,
     1596                        if (!ldap_decode_control_wrapper(ctrl[i], data, ctrl[i], &value)) {
     1597                                goto prot_err;
     1598                        }
     1599
     1600                        if (!ldap_decode_control_value(ctrl[i], value,
    15801601                                                       control_handlers,
    15811602                                                       ctrl[i])) {
     
    16011622                msg->controls_decoded = decoded;
    16021623
    1603                 asn1_end_tag(data);
    1604         }
    1605 
    1606         asn1_end_tag(data);
    1607         if ((data->has_error) || (data->nesting != NULL)) {
     1624                if (!asn1_end_tag(data)) goto prot_err;
     1625        }
     1626
     1627        if (!asn1_end_tag(data)) goto prot_err;
     1628        if (asn1_has_error(data) || asn1_has_nesting(data)) {
    16081629                return NT_STATUS_LDAP(LDAP_PROTOCOL_ERROR);
    16091630        }
    16101631        return NT_STATUS_OK;
     1632
     1633  prot_err:
     1634
     1635        return NT_STATUS_LDAP(LDAP_PROTOCOL_ERROR);
    16111636}
    16121637
     
    16181643NTSTATUS ldap_full_packet(void *private_data, DATA_BLOB blob, size_t *packet_size)
    16191644{
     1645        int ret;
     1646
    16201647        if (blob.length < 6) {
    16211648                /*
     
    16251652                return STATUS_MORE_ENTRIES;
    16261653        }
    1627         return asn1_peek_full_tag(blob, ASN1_SEQUENCE(0), packet_size);
    1628 }
     1654
     1655        ret = asn1_peek_full_tag(blob, ASN1_SEQUENCE(0), packet_size);
     1656        if (ret != 0) {
     1657                return map_nt_error_from_unix_common(ret);
     1658        }
     1659        return NT_STATUS_OK;
     1660}
  • vendor/current/libcli/ldap/ldap_message.h

    r740 r988  
    2323
    2424#include "../libcli/ldap/ldap_errors.h"
    25 #if _SAMBA_BUILD_ == 3
    26 #include "lib/ldb_compat.h"
    27 #else
    2825#include <ldb.h>
    29 #endif
    3026
    3127enum ldap_request_tag {
     
    109105        bool attributesonly;
    110106        struct ldb_parse_tree *tree;
    111         int num_attributes;
     107        size_t num_attributes;
    112108        const char * const *attributes;
    113109};
     
    233229                                  const char **result);
    234230
    235 void ldap_decode_attribs_bare(TALLOC_CTX *mem_ctx, struct asn1_data *data,
     231bool ldap_decode_attribs_bare(TALLOC_CTX *mem_ctx, struct asn1_data *data,
    236232                              struct ldb_message_element **attributes,
    237233                              int *num_attributes);
  • vendor/current/libcli/ldap/ldap_ndr.c

    r740 r988  
    2222
    2323#include "includes.h"
    24 #if _SAMBA_BUILD_ == 3
    25 #include "lib/ldb_compat.h"
    26 #else
    2724#include <ldb.h>
    28 #endif
    2925#include "librpc/gen_ndr/ndr_security.h"
    3026#include "librpc/gen_ndr/ndr_misc.h"
  • vendor/current/libcli/ldap/wscript_build

    r740 r988  
    11#!/usr/bin/env python
    22
    3 bld.SAMBA_SUBSYSTEM('LIBCLI_LDAP_MESSAGE',
    4         source='ldap_message.c',
    5         public_deps='errors talloc ldb',
    6         public_headers='ldap_message.h ldap_errors.h',
    7         deps='samba-util ASN1_UTIL'
    8         )
    9 
    10 
    11 bld.SAMBA_SUBSYSTEM('LIBCLI_LDAP_NDR',
    12         source='ldap_ndr.c',
    13         public_deps='errors talloc',
    14         public_headers='ldap_ndr.h',
    15         deps='samba-util ldb NDR_SECURITY tevent'
    16         )
    17 
     3bld.SAMBA_LIBRARY('cli-ldap-common',
     4                  source='ldap_message.c ldap_ndr.c',
     5                  public_deps='samba-errors talloc ldb',
     6                  private_headers='ldap_message.h ldap_errors.h ldap_ndr.h',
     7                  deps='samba-util asn1util NDR_SECURITY tevent',
     8                  private_library=True)
  • vendor/current/libcli/named_pipe_auth/npa_tstream.c

    r740 r988  
    2525#include "../librpc/gen_ndr/ndr_named_pipe_auth.h"
    2626#include "../libcli/named_pipe_auth/npa_tstream.h"
    27 #if _SAMBA_BUILD_ == 4
    28 #include "libcli/raw/smb.h"
    29 #endif
     27#include "../libcli/smb/smb_constants.h"
    3028
    3129static const struct tstream_context_ops tstream_npa_ops;
     
    13241322                                                &state->client);
    13251323        if (ret != 0) {
    1326                 DEBUG(2, ("Invalid server address[%s:%u] - %s\n",
     1324                DEBUG(2, ("Invalid client address[%s:%u] - %s\n",
    13271325                          i4.client_addr, i4.client_port,
    13281326                          strerror(errno)));
     
    14451443        return 0;
    14461444}
     1445
     1446
     1447/* SOCKETPAIR for internal rpc communication */
     1448
     1449/* file_type is FILE_TYPE_BYTE_MODE_PIPE or FILE_TYPE_MESSAGE_MODE_PIPE */
     1450int _tstream_npa_socketpair(uint16_t file_type,
     1451                            TALLOC_CTX *mem_ctx1,
     1452                            struct tstream_context **pstream1,
     1453                            TALLOC_CTX *mem_ctx2,
     1454                            struct tstream_context **pstream2,
     1455                            const char *location)
     1456{
     1457        struct tstream_context *stream1 = NULL;
     1458        struct tstream_context *stream2 = NULL;
     1459        int fds[2];
     1460        int fd1;
     1461        int fd2;
     1462        int rc;
     1463        bool ok;
     1464
     1465        rc = socketpair(AF_UNIX, SOCK_STREAM, 0, fds);
     1466        if (rc == -1) {
     1467                return -1;
     1468        }
     1469        fd1 = fds[0];
     1470        fd2 = fds[1];
     1471
     1472        ok = smb_set_close_on_exec(fd1);
     1473        if (!ok) {
     1474                goto close_fail;
     1475        }
     1476
     1477        ok = smb_set_close_on_exec(fd2);
     1478        if (!ok) {
     1479                goto close_fail;
     1480        }
     1481
     1482        rc = set_blocking(fd1, false);
     1483        if (rc == -1) {
     1484                goto close_fail;
     1485        }
     1486
     1487        rc = set_blocking(fd2, false);
     1488        if (rc == -1) {
     1489                goto close_fail;
     1490        }
     1491
     1492        rc = _tstream_npa_existing_socket(mem_ctx1,
     1493                                          fd1,
     1494                                          file_type,
     1495                                          &stream1,
     1496                                          location);
     1497        if (rc == -1) {
     1498                goto close_fail;
     1499        }
     1500
     1501        rc = _tstream_npa_existing_socket(mem_ctx2,
     1502                                          fd2,
     1503                                          file_type,
     1504                                          &stream2,
     1505                                          location);
     1506        if (rc == -1) {
     1507                int sys_errno = errno;
     1508                talloc_free(stream1);
     1509                close(fd2);
     1510                errno = sys_errno;
     1511                return -1;
     1512        }
     1513
     1514        *pstream1 = stream1;
     1515        *pstream2 = stream2;
     1516
     1517        return 0;
     1518
     1519close_fail:
     1520        {
     1521                int sys_errno = errno;
     1522                close(fd1);
     1523                close(fd2);
     1524                errno = sys_errno;
     1525                return -1;
     1526        }
     1527}
  • vendor/current/libcli/named_pipe_auth/npa_tstream.h

    r740 r988  
    118118                                          __location__)
    119119
     120int _tstream_npa_socketpair(uint16_t file_type,
     121                            TALLOC_CTX *mem_ctx1,
     122                            struct tstream_context **pstream1,
     123                            TALLOC_CTX *mem_ctx2,
     124                            struct tstream_context **pstream2,
     125                            const char *location);
     126#define tstream_npa_socketpair(ft, mem1, stream1, mem2, stream2) \
     127        _tstream_npa_socketpair(ft, mem1, stream1, mem2, stream2, \
     128                                __location__)
     129
    120130#endif /* NPA_TSTREAM_H */
  • vendor/current/libcli/named_pipe_auth/wscript_build

    r740 r988  
    22
    33
    4 bld.SAMBA_SUBSYSTEM('NAMED_PIPE_AUTH_TSTREAM',
    5         source='npa_tstream.c',
    6         public_deps='NDR_NAMED_PIPE_AUTH tevent LIBTSOCKET'
    7         )
     4bld.SAMBA_LIBRARY('npa_tstream',
     5                  source='npa_tstream.c',
     6                  private_library=True,
     7                  public_deps='NDR_NAMED_PIPE_AUTH tevent LIBTSOCKET'
     8                  )
    89
  • vendor/current/libcli/nbt/libnbt.h

    r740 r988  
    2525#include "librpc/gen_ndr/nbt.h"
    2626#include "librpc/ndr/libndr.h"
    27 #include "system/network.h"
     27#include "lib/util/xfile.h"
     28
    2829/*
    2930  possible states for pending requests
     
    335336
    336337
    337 NDR_SCALAR_PROTO(wrepl_nbt_name, const struct nbt_name *)
    338 NDR_SCALAR_PROTO(nbt_string, const char *)
     338NDR_SCALAR_PTR_PROTO(wrepl_nbt_name, struct nbt_name)
    339339NDR_BUFFER_PROTO(nbt_name, struct nbt_name)
    340340NTSTATUS nbt_rcode_to_ntstatus(uint8_t rcode);
     
    373373                                          int *return_count);
    374374
    375 NTSTATUS resolve_dns_hosts_file_as_sockaddr(const char *dns_hosts_file,
    376                                             const char *name, bool srv_lookup,
    377                                             TALLOC_CTX *mem_ctx,
    378                                             struct sockaddr_storage **return_iplist,
    379                                             int *return_count);
    380 
    381375#endif /* __LIBNBT_H__ */
  • vendor/current/libcli/nbt/namerefresh.c

    r740 r988  
    332332
    333333        if (!tevent_req_poll(subreq, ev)) {
    334                 status = map_nt_error_from_unix(errno);
     334                status = map_nt_error_from_unix_common(errno);
    335335                talloc_free(frame);
    336336                return status;
  • vendor/current/libcli/nbt/nameregister.c

    r740 r988  
    284284
    285285        if (!tevent_req_poll(subreq, ev)) {
    286                 status = map_nt_error_from_unix(errno);
     286                status = map_nt_error_from_unix_common(errno);
    287287                talloc_free(frame);
    288288                return status;
     
    499499
    500500        if (!tevent_req_poll(subreq, ev)) {
    501                 status = map_nt_error_from_unix(errno);
     501                status = map_nt_error_from_unix_common(errno);
    502502                talloc_free(frame);
    503503                return status;
  • vendor/current/libcli/nbt/nbtname.c

    r740 r988  
    2929#include "system/locale.h"
    3030#include "lib/util/util_net.h"
    31 
    32 /* don't allow an unlimited number of name components */
    33 #define MAX_COMPONENTS 10
    34 
    35 /**
    36   print a nbt string
    37 */
    38 _PUBLIC_ void ndr_print_nbt_string(struct ndr_print *ndr, const char *name, const char *s)
    39 {
    40         ndr_print_string(ndr, name, s);
    41 }
    42 
    43 /*
    44   pull one component of a nbt_string
    45 */
    46 static enum ndr_err_code ndr_pull_component(struct ndr_pull *ndr,
    47                                             uint8_t **component,
    48                                             uint32_t *offset,
    49                                             uint32_t *max_offset)
    50 {
    51         uint8_t len;
    52         unsigned int loops = 0;
    53         while (loops < 5) {
    54                 if (*offset >= ndr->data_size) {
    55                         return ndr_pull_error(ndr, NDR_ERR_STRING,
    56                                               "BAD NBT NAME component");
    57                 }
    58                 len = ndr->data[*offset];
    59                 if (len == 0) {
    60                         *offset += 1;
    61                         *max_offset = MAX(*max_offset, *offset);
    62                         *component = NULL;
    63                         return NDR_ERR_SUCCESS;
    64                 }
    65                 if ((len & 0xC0) == 0xC0) {
    66                         /* its a label pointer */
    67                         if (1 + *offset >= ndr->data_size) {
    68                                 return ndr_pull_error(ndr, NDR_ERR_STRING,
    69                                                       "BAD NBT NAME component");
    70                         }
    71                         *max_offset = MAX(*max_offset, *offset + 2);
    72                         *offset = ((len&0x3F)<<8) | ndr->data[1 + *offset];
    73                         *max_offset = MAX(*max_offset, *offset);
    74                         loops++;
    75                         continue;
    76                 }
    77                 if ((len & 0xC0) != 0) {
    78                         /* its a reserved length field */
    79                         return ndr_pull_error(ndr, NDR_ERR_STRING,
    80                                               "BAD NBT NAME component");
    81                 }
    82                 if (*offset + len + 2 > ndr->data_size) {
    83                         return ndr_pull_error(ndr, NDR_ERR_STRING,
    84                                               "BAD NBT NAME component");
    85                 }
    86                 *component = (uint8_t*)talloc_strndup(
    87                         ndr->current_mem_ctx,
    88                         (const char *)&ndr->data[1 + *offset], len);
    89                 NDR_ERR_HAVE_NO_MEMORY(*component);
    90                 *offset += len + 1;
    91                 *max_offset = MAX(*max_offset, *offset);
    92                 return NDR_ERR_SUCCESS;
    93         }
    94 
    95         /* too many pointers */
    96         return ndr_pull_error(ndr, NDR_ERR_STRING, "BAD NBT NAME component");
    97 }
    98 
    99 /**
    100   pull a nbt_string from the wire
    101 */
    102 _PUBLIC_ enum ndr_err_code ndr_pull_nbt_string(struct ndr_pull *ndr, int ndr_flags, const char **s)
    103 {
    104         uint32_t offset = ndr->offset;
    105         uint32_t max_offset = offset;
    106         unsigned num_components;
    107         char *name;
    108 
    109         if (!(ndr_flags & NDR_SCALARS)) {
    110                 return NDR_ERR_SUCCESS;
    111         }
    112 
    113         name = NULL;
    114 
    115         /* break up name into a list of components */
    116         for (num_components=0;num_components<MAX_COMPONENTS;num_components++) {
    117                 uint8_t *component = NULL;
    118                 NDR_CHECK(ndr_pull_component(ndr, &component, &offset, &max_offset));
    119                 if (component == NULL) break;
    120                 if (name) {
    121                         name = talloc_asprintf_append_buffer(name, ".%s", component);
    122                         NDR_ERR_HAVE_NO_MEMORY(name);
    123                 } else {
    124                         name = (char *)component;
    125                 }
    126         }
    127         if (num_components == MAX_COMPONENTS) {
    128                 return ndr_pull_error(ndr, NDR_ERR_STRING,
    129                                       "BAD NBT NAME too many components");
    130         }
    131         if (num_components == 0) {
    132                 name = talloc_strdup(ndr->current_mem_ctx, "");
    133                 NDR_ERR_HAVE_NO_MEMORY(name);
    134         }
    135 
    136         (*s) = name;
    137         ndr->offset = max_offset;
    138 
    139         return NDR_ERR_SUCCESS;
    140 }
    141 
    142 /**
    143   push a nbt string to the wire
    144 */
    145 _PUBLIC_ enum ndr_err_code ndr_push_nbt_string(struct ndr_push *ndr, int ndr_flags, const char *s)
    146 {
    147         if (!(ndr_flags & NDR_SCALARS)) {
    148                 return NDR_ERR_SUCCESS;
    149         }
    150 
    151         while (s && *s) {
    152                 enum ndr_err_code ndr_err;
    153                 char *compname;
    154                 size_t complen;
    155                 uint32_t offset;
    156 
    157                 /* see if we have pushed the remaing string allready,
    158                  * if so we use a label pointer to this string
    159                  */
    160                 ndr_err = ndr_token_retrieve_cmp_fn(&ndr->nbt_string_list, s, &offset, (comparison_fn_t)strcmp, false);
    161                 if (NDR_ERR_CODE_IS_SUCCESS(ndr_err)) {
    162                         uint8_t b[2];
    163 
    164                         if (offset > 0x3FFF) {
    165                                 return ndr_push_error(ndr, NDR_ERR_STRING,
    166                                                       "offset for nbt string label pointer %u[%08X] > 0x00003FFF",
    167                                                       offset, offset);
    168                         }
    169 
    170                         b[0] = 0xC0 | (offset>>8);
    171                         b[1] = (offset & 0xFF);
    172 
    173                         return ndr_push_bytes(ndr, b, 2);
    174                 }
    175 
    176                 complen = strcspn(s, ".");
    177 
    178                 /* we need to make sure the length fits into 6 bytes */
    179                 if (complen > 0x3F) {
    180                         return ndr_push_error(ndr, NDR_ERR_STRING,
    181                                               "component length %u[%08X] > 0x0000003F",
    182                                               (unsigned)complen, (unsigned)complen);
    183                 }
    184 
    185                 compname = talloc_asprintf(ndr, "%c%*.*s",
    186                                                 (unsigned char)complen,
    187                                                 (unsigned char)complen,
    188                                                 (unsigned char)complen, s);
    189                 NDR_ERR_HAVE_NO_MEMORY(compname);
    190 
    191                 /* remember the current componemt + the rest of the string
    192                  * so it can be reused later
    193                  */
    194                 NDR_CHECK(ndr_token_store(ndr, &ndr->nbt_string_list, s, ndr->offset));
    195 
    196                 /* push just this component into the blob */
    197                 NDR_CHECK(ndr_push_bytes(ndr, (const uint8_t *)compname, complen+1));
    198                 talloc_free(compname);
    199 
    200                 s += complen;
    201                 if (*s == '.') s++;
    202         }
    203 
    204         /* if we reach the end of the string and have pushed the last component
    205          * without using a label pointer, we need to terminate the string
    206          */
    207         return ndr_push_bytes(ndr, (const uint8_t *)"", 1);
    208 }
    209 
     31#include "libcli/nbt/libnbt.h"
    21032
    21133/*
     
    503325  pull a nbt name, WINS Replication uses another on wire format for nbt name
    504326*/
    505 _PUBLIC_ enum ndr_err_code ndr_pull_wrepl_nbt_name(struct ndr_pull *ndr, int ndr_flags, const struct nbt_name **_r)
     327_PUBLIC_ enum ndr_err_code ndr_pull_wrepl_nbt_name(struct ndr_pull *ndr, int ndr_flags, struct nbt_name **_r)
    506328{
    507329        struct nbt_name *r;
  • vendor/current/libcli/nbt/nbtsocket.c

    r740 r988  
    5151        }
    5252        if (req->nbtsock->send_queue == NULL) {
    53                 EVENT_FD_NOT_WRITEABLE(req->nbtsock->fde);
     53                TEVENT_FD_NOT_WRITEABLE(req->nbtsock->fde);
    5454        }
    5555        if (req->nbtsock->num_pending == 0 &&
    5656            req->nbtsock->incoming.handler == NULL) {
    57                 EVENT_FD_NOT_READABLE(req->nbtsock->fde);
     57                TEVENT_FD_NOT_READABLE(req->nbtsock->fde);
    5858        }
    5959        return 0;
     
    8888                        talloc_free(req);
    8989                } else {
    90                         EVENT_FD_READABLE(nbtsock->fde);
     90                        TEVENT_FD_READABLE(nbtsock->fde);
    9191                        nbtsock->num_pending++;
    9292                }
    9393        }
    9494
    95         EVENT_FD_NOT_WRITEABLE(nbtsock->fde);
     95        TEVENT_FD_NOT_WRITEABLE(nbtsock->fde);
    9696        talloc_free(tmp_ctx);
    9797        return;
     
    123123        if (req->num_retries != 0) {
    124124                req->num_retries--;
    125                 req->te = event_add_timed(req->nbtsock->event_ctx, req,
    126                                           timeval_add(&t, req->timeout, 0),
    127                                           nbt_name_socket_timeout, req);
     125                req->te = tevent_add_timer(req->nbtsock->event_ctx, req,
     126                                           timeval_add(&t, req->timeout, 0),
     127                                           nbt_name_socket_timeout, req);
    128128                if (req->state != NBT_REQUEST_SEND) {
    129129                        req->state = NBT_REQUEST_SEND;
    130                         DLIST_ADD_END(req->nbtsock->send_queue, req,
    131                                       struct nbt_name_request *);
    132                 }
    133                 EVENT_FD_WRITEABLE(req->nbtsock->fde);
     130                        DLIST_ADD_END(req->nbtsock->send_queue, req);
     131                }
     132                TEVENT_FD_WRITEABLE(req->nbtsock->fde);
    134133                return;
    135134        }
     
    274273                }
    275274                req->timeout = ttl;
    276                 req->te = event_add_timed(req->nbtsock->event_ctx, req,
    277                                           timeval_current_ofs(req->timeout, 0),
    278                                           nbt_name_socket_timeout, req);
     275                req->te = tevent_add_timer(req->nbtsock->event_ctx, req,
     276                                           timeval_current_ofs(req->timeout, 0),
     277                                           nbt_name_socket_timeout, req);
    279278                return;
    280279        }
     
    319318        struct nbt_name_socket *nbtsock = talloc_get_type(private_data,
    320319                                                          struct nbt_name_socket);
    321         if (flags & EVENT_FD_WRITE) {
     320        if (flags & TEVENT_FD_WRITE) {
    322321                nbt_name_socket_send(nbtsock);
    323322        }
    324         if (flags & EVENT_FD_READ) {
     323        if (flags & TEVENT_FD_READ) {
    325324                nbt_name_socket_recv(nbtsock);
    326325        }
     
    359358        nbtsock->unexpected.handler = NULL;
    360359
    361         nbtsock->fde = event_add_fd(nbtsock->event_ctx, nbtsock,
    362                                     socket_get_fd(nbtsock->sock), 0,
    363                                     nbt_name_socket_handler, nbtsock);
     360        nbtsock->fde = tevent_add_fd(nbtsock->event_ctx, nbtsock,
     361                                     socket_get_fd(nbtsock->sock), 0,
     362                                     nbt_name_socket_handler, nbtsock);
    364363
    365364        return nbtsock;
     
    408407        req->name_trn_id     = id;
    409408
    410         req->te = event_add_timed(nbtsock->event_ctx, req,
    411                                   timeval_current_ofs(req->timeout, 0),
    412                                   nbt_name_socket_timeout, req);
     409        req->te = tevent_add_timer(nbtsock->event_ctx, req,
     410                                   timeval_current_ofs(req->timeout, 0),
     411                                   nbt_name_socket_timeout, req);
    413412
    414413        talloc_set_destructor(req, nbt_name_request_destructor);
     
    419418        if (!NDR_ERR_CODE_IS_SUCCESS(ndr_err)) goto failed;
    420419
    421         DLIST_ADD_END(nbtsock->send_queue, req, struct nbt_name_request *);
     420        DLIST_ADD_END(nbtsock->send_queue, req);
    422421
    423422        if (DEBUGLVL(10)) {
     
    427426        }
    428427
    429         EVENT_FD_WRITEABLE(nbtsock->fde);
     428        TEVENT_FD_WRITEABLE(nbtsock->fde);
    430429
    431430        return req;
     
    470469        }
    471470
    472         DLIST_ADD_END(nbtsock->send_queue, req, struct nbt_name_request *);
    473 
    474         EVENT_FD_WRITEABLE(nbtsock->fde);
     471        DLIST_ADD_END(nbtsock->send_queue, req);
     472
     473        TEVENT_FD_WRITEABLE(nbtsock->fde);
    475474
    476475        return NT_STATUS_OK;
     
    489488
    490489        while (req->state < NBT_REQUEST_DONE) {
    491                 if (event_loop_once(req->nbtsock->event_ctx) != 0) {
     490                if (tevent_loop_once(req->nbtsock->event_ctx) != 0) {
    492491                        req->state = NBT_REQUEST_ERROR;
    493492                        req->status = NT_STATUS_UNEXPECTED_NETWORK_ERROR;
     
    509508        nbtsock->incoming.handler = handler;
    510509        nbtsock->incoming.private_data = private_data;
    511         EVENT_FD_READABLE(nbtsock->fde);
     510        TEVENT_FD_READABLE(nbtsock->fde);
    512511        return NT_STATUS_OK;
    513512}
     
    523522        nbtsock->unexpected.handler = handler;
    524523        nbtsock->unexpected.private_data = private_data;
    525         EVENT_FD_READABLE(nbtsock->fde);
     524        TEVENT_FD_READABLE(nbtsock->fde);
    526525        return NT_STATUS_OK;
    527526}
  • vendor/current/libcli/nbt/pynbt.c

    r740 r988  
    2121#include "includes.h"
    2222#include "libcli/util/pyerrors.h"
    23 #include "scripting/python/modules.h"
     23#include "python/modules.h"
    2424#include "../libcli/nbt/libnbt.h"
    2525#include "lib/events/events.h"
    2626
    2727void initnetbios(void);
    28 
    29 #ifndef Py_RETURN_NONE
    30 #define Py_RETURN_NONE return Py_INCREF(Py_None), Py_None
    31 #endif
    3228
    3329extern PyTypeObject nbt_node_Type;
  • vendor/current/libcli/nbt/tools/nmblookup.c

    r740 r988  
    3333#include "param/param.h"
    3434
     35#include <string.h>
     36
     37#define MAX_NETBIOSNAME_LEN 16
     38
    3539/* command line options */
    3640static struct {
     
    191195        struct nbt_name_socket *nbtsock;
    192196        NTSTATUS status = NT_STATUS_OK;
     197        size_t nbt_len;
    193198        bool ret = true;
    194199
     
    211216        } else {
    212217                node_name = talloc_strdup(tmp_ctx, name);
     218        }
     219
     220        nbt_len = strlen(node_name);
     221        if (nbt_len > MAX_NETBIOSNAME_LEN - 1) {
     222                printf("The specified netbios name [%s] is too long.\n",
     223                       node_name);
     224                talloc_free(tmp_ctx);
     225                return false;
    213226        }
    214227
     
    247260                int i, num_interfaces;
    248261
    249                 num_interfaces = iface_count(ifaces);
     262                num_interfaces = iface_list_count(ifaces);
    250263                for (i=0;i<num_interfaces;i++) {
    251                         const char *bcast = iface_n_bcast(ifaces, i);
     264                        const char *bcast = iface_list_n_bcast(ifaces, i);
    252265                        if (bcast == NULL) continue;
    253266                        status = do_node_query(nbtsock, bcast, nbt_port,
     
    358371        }
    359372
    360         load_interfaces(NULL, lpcfg_interfaces(cmdline_lp_ctx), &ifaces);
     373        load_interface_list(NULL, cmdline_lp_ctx, &ifaces);
    361374
    362375        ev = s4_event_context_init(talloc_autofree_context());
  • vendor/current/libcli/nbt/wscript_build

    r740 r988  
    1212                    )
    1313
    14 if bld.env._SAMBA_BUILD_ == 4:
    15     bld.SAMBA_LIBRARY('cli-nbt',
    16                       source='nbtsocket.c namequery.c nameregister.c namerefresh.c namerelease.c dns_hosts_file.c',
    17                       public_deps='ndr NDR_NBT tevent UTIL_TEVENT NDR_SECURITY samba_socket samba-util lmhosts',
    18                       private_library=True
    19                       )
     14bld.SAMBA_LIBRARY('cli-nbt',
     15                  source='nbtsocket.c namequery.c nameregister.c namerefresh.c namerelease.c',
     16                  public_deps='ndr ndr_nbt tevent tevent-util NDR_SECURITY samba_socket samba-util lmhosts',
     17                  private_library=True
     18                  )
    2019
    21     bld.SAMBA_BINARY('nmblookup',
    22                      source='tools/nmblookup.c',
    23                      manpages='man/nmblookup.1',
    24                      deps='samba-hostconfig samba-util cli-nbt popt POPT_SAMBA netif LIBCLI_RESOLVE'
    25                      )
     20bld.SAMBA_BINARY('nmblookup' + bld.env.suffix4,
     21                 source='tools/nmblookup.c',
     22                 manpages='man/nmblookup4.1',
     23                 deps='samba-hostconfig samba-util cli-nbt popt POPT_SAMBA netif LIBCLI_RESOLVE',
     24                 install=False
     25                 )
    2626
    27     bld.SAMBA_PYTHON('python_netbios',
    28                      source='pynbt.c',
    29                      public_deps='cli-nbt DYNCONFIG samba-hostconfig',
    30                      realname='samba/netbios.so'
    31                      )
     27bld.SAMBA_PYTHON('python_netbios',
     28                 source='pynbt.c',
     29                 public_deps='cli-nbt DYNCONFIG samba-hostconfig',
     30                 realname='samba/netbios.so'
     31                 )
    3232
  • vendor/current/libcli/netlogon/netlogon.c

    r740 r988  
    9292                        ntver);
    9393                if (ndr->offset < ndr->data_size) {
    94                         ndr_err = ndr_pull_error(ndr, NDR_ERR_UNREAD_BYTES,
    95                                                  "not all bytes consumed ofs[%u] size[%u]",
    96                                                  ndr->offset, ndr->data_size);
     94                        TALLOC_FREE(ndr);
     95                        /*
     96                         * We need to handle a bug in FreeIPA (at least <= 4.1.2).
     97                         *
     98                         * They include the ip address information without setting
     99                         * NETLOGON_NT_VERSION_5EX_WITH_IP, while using
     100                         * ndr_push_NETLOGON_SAM_LOGON_RESPONSE_EX instead of
     101                         * ndr_push_NETLOGON_SAM_LOGON_RESPONSE_EX_with_flags.
     102                         */
     103                        ndr_err = ndr_pull_struct_blob_all(data, mem_ctx,
     104                                                   &response->data.nt5,
     105                                                   (ndr_pull_flags_fn_t)ndr_pull_NETLOGON_SAM_LOGON_RESPONSE_EX);
    97106                }
    98107                response->ntver = NETLOGON_NT_VERSION_5EX;
  • vendor/current/libcli/netlogon/netlogon.h

    r740 r988  
    2727#include "librpc/gen_ndr/ndr_misc.h"
    2828#include "librpc/gen_ndr/ndr_security.h"
    29 #include "librpc/gen_ndr/ndr_svcctl.h"
    30 #include "librpc/gen_ndr/ndr_samr.h"
    31 
    32 struct netlogon_samlogon_response
    33 {
    34         uint32_t ntver;
    35         union {
    36                 struct NETLOGON_SAM_LOGON_RESPONSE_NT40 nt4;
    37                 struct NETLOGON_SAM_LOGON_RESPONSE nt5;
    38                 struct NETLOGON_SAM_LOGON_RESPONSE_EX nt5_ex;
    39         } data;
    40 
    41 };
    4229
    4330struct nbt_netlogon_response
     
    5239
    5340#include "../libcli/netlogon/netlogon_proto.h"
    54 #include "../libcli/netlogon/ndr_netlogon_proto.h"
    5541#endif /* __CLDAP_SERVER_PROTO_H__ */
  • vendor/current/libcli/netlogon/wscript_build

    r740 r988  
    11#!/usr/bin/env python
    2 
    3 bld.SAMBA_SUBSYSTEM('LIBCLI_NDR_NETLOGON',
    4         source='ndr_netlogon.c',
    5         public_deps='ndr NDR_SECURITY'
    6         )
    72
    83bld.SAMBA_SUBSYSTEM('LIBCLI_NETLOGON',
    94        source='netlogon.c',
    10         public_deps='samba-util LIBCLI_NDR_NETLOGON'
     5        public_deps='samba-util ndr_nbt'
    116        )
  • vendor/current/libcli/registry/wscript_build

    r740 r988  
    11
    2 bld.SAMBA_SUBSYSTEM('util_reg',
     2bld.SAMBA_LIBRARY('util_reg',
    33                    source='util_reg.c',
    4                     deps='ndr')
     4                    deps='ndr',
     5                    private_library=True)
  • vendor/current/libcli/security/access_check.c

    r746 r988  
    160160        uint32_t bits_remaining;
    161161        uint32_t explicitly_denied_bits = 0;
     162        /*
     163         * Up until Windows Server 2008, owner always had these rights. Now
     164         * we have to use Owner Rights perms if they are on the file.
     165         *
     166         * In addition we have to accumulate these bits and apply them
     167         * correctly. See bug #8795
     168         */
     169        uint32_t owner_rights_allowed = 0;
     170        uint32_t owner_rights_denied = 0;
     171        bool owner_rights_default = true;
    162172
    163173        *access_granted = access_desired;
     
    179189        }
    180190
    181         /* the owner always gets SEC_STD_WRITE_DAC and SEC_STD_READ_CONTROL */
    182         if ((bits_remaining & (SEC_STD_WRITE_DAC|SEC_STD_READ_CONTROL)) &&
    183             security_token_has_sid(token, sd->owner_sid)) {
    184                 bits_remaining &= ~(SEC_STD_WRITE_DAC|SEC_STD_READ_CONTROL);
    185         }
    186 
    187191        /* a NULL dacl allows access */
    188192        if ((sd->type & SEC_DESC_DACL_PRESENT) && sd->dacl == NULL) {
     
    203207                }
    204208
     209                /*
     210                 * We need the Owner Rights permissions to ensure we
     211                 * give or deny the correct permissions to the owner. Replace
     212                 * owner_rights with the perms here if it is present.
     213                 *
     214                 * We don't care if we are not the owner because that is taken
     215                 * care of below when we check if our token has the owner SID.
     216                 *
     217                 */
     218                if (dom_sid_equal(&ace->trustee, &global_sid_Owner_Rights)) {
     219                        if (ace->type == SEC_ACE_TYPE_ACCESS_ALLOWED) {
     220                                owner_rights_allowed |= ace->access_mask;
     221                                owner_rights_default = false;
     222                        } else if (ace->type == SEC_ACE_TYPE_ACCESS_DENIED) {
     223                                owner_rights_denied |= ace->access_mask;
     224                                owner_rights_default = false;
     225                        }
     226                        continue;
     227                }
     228
    205229                if (!security_token_has_sid(token, &ace->trustee)) {
    206230                        continue;
     
    220244        }
    221245
     246        /* Explicitly denied bits always override */
    222247        bits_remaining |= explicitly_denied_bits;
     248
     249        /* The owner always gets owner rights as defined above. */
     250        if (security_token_has_sid(token, sd->owner_sid)) {
     251                if (owner_rights_default) {
     252                        /*
     253                         * Just remove them, no need to check if they are
     254                         * there.
     255                         */
     256                        bits_remaining &= ~(SEC_STD_WRITE_DAC |
     257                                                SEC_STD_READ_CONTROL);
     258                } else {
     259                        bits_remaining &= ~owner_rights_allowed;
     260                        bits_remaining |= owner_rights_denied;
     261                }
     262        }
    223263
    224264        /*
     
    235275        }
    236276
    237         /* TODO: remove this, as it is file server specific */
    238         if ((bits_remaining & SEC_RIGHTS_PRIV_RESTORE) &&
    239             security_token_has_privilege(token, SEC_PRIV_RESTORE)) {
    240                 bits_remaining &= ~(SEC_RIGHTS_PRIV_RESTORE);
    241         }
    242         if ((bits_remaining & SEC_RIGHTS_PRIV_BACKUP) &&
    243             security_token_has_privilege(token, SEC_PRIV_BACKUP)) {
    244                 bits_remaining &= ~(SEC_RIGHTS_PRIV_BACKUP);
    245         }
    246 
    247277        if ((bits_remaining & SEC_STD_WRITE_OWNER) &&
    248278             security_token_has_privilege(token, SEC_PRIV_TAKE_OWNERSHIP)) {
     
    259289}
    260290
     291/*
     292  The main entry point for access checking FOR THE FILE SERVER ONLY !
     293  If returning ACCESS_DENIED this function returns the denied bits in
     294  the uint32_t pointed to by the access_granted pointer.
     295*/
     296NTSTATUS se_file_access_check(const struct security_descriptor *sd,
     297                          const struct security_token *token,
     298                          bool priv_open_requested,
     299                          uint32_t access_desired,
     300                          uint32_t *access_granted)
     301{
     302        uint32_t bits_remaining;
     303        NTSTATUS status;
     304
     305        if (!priv_open_requested) {
     306                /* Fall back to generic se_access_check(). */
     307                return se_access_check(sd,
     308                                token,
     309                                access_desired,
     310                                access_granted);
     311        }
     312
     313        /*
     314         * We need to handle the maximum allowed flag
     315         * outside of se_access_check(), as we need to
     316         * add in the access allowed by the privileges
     317         * as well.
     318         */
     319
     320        if (access_desired & SEC_FLAG_MAXIMUM_ALLOWED) {
     321                uint32_t orig_access_desired = access_desired;
     322
     323                access_desired |= access_check_max_allowed(sd, token);
     324                access_desired &= ~SEC_FLAG_MAXIMUM_ALLOWED;
     325
     326                if (security_token_has_privilege(token, SEC_PRIV_BACKUP)) {
     327                        access_desired |= SEC_RIGHTS_PRIV_BACKUP;
     328                }
     329
     330                if (security_token_has_privilege(token, SEC_PRIV_RESTORE)) {
     331                        access_desired |= SEC_RIGHTS_PRIV_RESTORE;
     332                }
     333
     334                DEBUG(10,("se_file_access_check: MAX desired = 0x%x "
     335                        "mapped to 0x%x\n",
     336                        orig_access_desired,
     337                        access_desired));
     338        }
     339
     340        status = se_access_check(sd,
     341                                token,
     342                                access_desired,
     343                                access_granted);
     344
     345        if (!NT_STATUS_EQUAL(status, NT_STATUS_ACCESS_DENIED)) {
     346                return status;
     347        }
     348
     349        bits_remaining = *access_granted;
     350
     351        /* Check if we should override with privileges. */
     352        if ((bits_remaining & SEC_RIGHTS_PRIV_BACKUP) &&
     353            security_token_has_privilege(token, SEC_PRIV_BACKUP)) {
     354                bits_remaining &= ~(SEC_RIGHTS_PRIV_BACKUP);
     355        }
     356        if ((bits_remaining & SEC_RIGHTS_PRIV_RESTORE) &&
     357            security_token_has_privilege(token, SEC_PRIV_RESTORE)) {
     358                bits_remaining &= ~(SEC_RIGHTS_PRIV_RESTORE);
     359        }
     360        if (bits_remaining != 0) {
     361                *access_granted = bits_remaining;
     362                return NT_STATUS_ACCESS_DENIED;
     363        }
     364
     365        return NT_STATUS_OK;
     366}
    261367
    262368static const struct GUID *get_ace_object_type(struct security_ace *ace)
    263369{
    264         struct GUID *type;
    265 
    266         if (ace->object.object.flags & SEC_ACE_OBJECT_TYPE_PRESENT)
    267                 type = &ace->object.object.type.type;
    268         else if (ace->object.object.flags & SEC_ACE_INHERITED_OBJECT_TYPE_PRESENT)
    269                 type = &ace->object.object.inherited_type.inherited_type; /* This doesn't look right. Is something wrong with the IDL? */
    270         else
    271                 type = NULL;
    272 
    273         return type;
    274 
    275 }
    276 
    277 /* modified access check for the purposes of DS security
     370        if (ace->object.object.flags & SEC_ACE_OBJECT_TYPE_PRESENT) {
     371                return &ace->object.object.type.type;
     372        }
     373
     374        return NULL;
     375}
     376
     377/**
     378 * @brief Perform directoryservice (DS) related access checks for a given user
     379 *
     380 * Perform DS access checks for the user represented by its security_token, on
     381 * the provided security descriptor. If an tree associating GUID and access
     382 * required is provided then object access (OA) are checked as well. *
     383 * @param[in]   sd             The security descritor against which the required
     384 *                             access are requested
     385 *
     386 * @param[in]   token          The security_token associated with the user to
     387 *                             test
     388 *
     389 * @param[in]   access_desired A bitfield of rights that must be granted for the
     390 *                             given user in the specified SD.
     391 *
     392 * If one
     393 * of the entry in the tree grants all the requested rights for the given GUID
     394 * FIXME
     395 * tree can be null if not null it's the
    278396 * Lots of code duplication, it will ve united in just one
    279397 * function eventually */
     
    286404                             struct dom_sid *replace_sid)
    287405{
    288         uint32_t i;
    289         uint32_t bits_remaining;
    290         struct object_tree *node;
    291         const struct GUID *type;
    292         struct dom_sid *ps_sid = dom_sid_parse_talloc(NULL, SID_NT_SELF);
    293 
    294         *access_granted = access_desired;
    295         bits_remaining = access_desired;
    296 
    297         /* handle the maximum allowed flag */
    298         if (access_desired & SEC_FLAG_MAXIMUM_ALLOWED) {
    299                 access_desired |= access_check_max_allowed(sd, token);
    300                 access_desired &= ~SEC_FLAG_MAXIMUM_ALLOWED;
    301                 *access_granted = access_desired;
     406        uint32_t i;
     407        uint32_t bits_remaining;
     408        struct object_tree *node;
     409        const struct GUID *type;
     410        struct dom_sid self_sid;
     411
     412        dom_sid_parse(SID_NT_SELF, &self_sid);
     413
     414        *access_granted = access_desired;
     415        bits_remaining = access_desired;
     416
     417        /* handle the maximum allowed flag */
     418        if (access_desired & SEC_FLAG_MAXIMUM_ALLOWED) {
     419                access_desired |= access_check_max_allowed(sd, token);
     420                access_desired &= ~SEC_FLAG_MAXIMUM_ALLOWED;
     421                *access_granted = access_desired;
    302422                bits_remaining = access_desired;
    303         }
    304 
    305         if (access_desired & SEC_FLAG_SYSTEM_SECURITY) {
    306                 if (security_token_has_privilege(token, SEC_PRIV_SECURITY)) {
    307                         bits_remaining &= ~SEC_FLAG_SYSTEM_SECURITY;
    308                 } else {
    309                         talloc_free(ps_sid);
    310                         return NT_STATUS_PRIVILEGE_NOT_HELD;
    311                 }
    312         }
     423        }
     424
     425        if (access_desired & SEC_FLAG_SYSTEM_SECURITY) {
     426                if (security_token_has_privilege(token, SEC_PRIV_SECURITY)) {
     427                        bits_remaining &= ~SEC_FLAG_SYSTEM_SECURITY;
     428                } else {
     429                        return NT_STATUS_PRIVILEGE_NOT_HELD;
     430                }
     431        }
    313432
    314433        /* the owner always gets SEC_STD_WRITE_DAC and SEC_STD_READ_CONTROL */
     
    318437        }
    319438
    320         /* TODO: remove this, as it is file server specific */
    321         if ((bits_remaining & SEC_RIGHTS_PRIV_RESTORE) &&
    322             security_token_has_privilege(token, SEC_PRIV_RESTORE)) {
    323                 bits_remaining &= ~(SEC_RIGHTS_PRIV_RESTORE);
    324         }
    325         if ((bits_remaining & SEC_RIGHTS_PRIV_BACKUP) &&
    326             security_token_has_privilege(token, SEC_PRIV_BACKUP)) {
    327                 bits_remaining &= ~(SEC_RIGHTS_PRIV_BACKUP);
    328         }
    329 
    330         /* a NULL dacl allows access */
    331         if ((sd->type & SEC_DESC_DACL_PRESENT) && sd->dacl == NULL) {
    332                 *access_granted = access_desired;
    333                 talloc_free(ps_sid);
    334                 return NT_STATUS_OK;
    335         }
    336 
    337         if (sd->dacl == NULL) {
    338                 goto done;
    339         }
    340 
    341         /* check each ace in turn. */
    342         for (i=0; bits_remaining && i < sd->dacl->num_aces; i++) {
     439        /* SEC_PRIV_TAKE_OWNERSHIP grants SEC_STD_WRITE_OWNER */
     440        if ((bits_remaining & (SEC_STD_WRITE_OWNER)) &&
     441            security_token_has_privilege(token, SEC_PRIV_TAKE_OWNERSHIP)) {
     442                bits_remaining &= ~(SEC_STD_WRITE_OWNER);
     443        }
     444
     445        /* a NULL dacl allows access */
     446        if ((sd->type & SEC_DESC_DACL_PRESENT) && sd->dacl == NULL) {
     447                *access_granted = access_desired;
     448                return NT_STATUS_OK;
     449        }
     450
     451        if (sd->dacl == NULL) {
     452                goto done;
     453        }
     454
     455        /* check each ace in turn. */
     456        for (i=0; bits_remaining && i < sd->dacl->num_aces; i++) {
    343457                struct dom_sid *trustee;
    344458                struct security_ace *ace = &sd->dacl->aces[i];
    345459
    346                 if (ace->flags & SEC_ACE_FLAG_INHERIT_ONLY) {
    347                         continue;
    348                 }
    349                 if (dom_sid_equal(&ace->trustee, ps_sid) && replace_sid) {
     460                if (ace->flags & SEC_ACE_FLAG_INHERIT_ONLY) {
     461                        continue;
     462                }
     463
     464                if (dom_sid_equal(&ace->trustee, &self_sid) && replace_sid) {
    350465                        trustee = replace_sid;
    351                 }
    352                 else
    353                 {
     466                } else {
    354467                        trustee = &ace->trustee;
    355468                }
    356                 if (!security_token_has_sid(token, trustee)) {
    357                         continue;
    358                 }
    359 
    360                 switch (ace->type) {
    361                 case SEC_ACE_TYPE_ACCESS_ALLOWED:
    362                         if (tree)
    363                                 object_tree_modify_access(tree, ace->access_mask);
    364 
    365                         bits_remaining &= ~ace->access_mask;
    366                         break;
    367                 case SEC_ACE_TYPE_ACCESS_DENIED:
    368                         if (bits_remaining & ace->access_mask) {
    369                                 talloc_free(ps_sid);
    370                                 return NT_STATUS_ACCESS_DENIED;
    371                         }
    372                         break;
    373                 case SEC_ACE_TYPE_ACCESS_DENIED_OBJECT:
    374                 case SEC_ACE_TYPE_ACCESS_ALLOWED_OBJECT:
    375                         /* check only in case we have provided a tree,
    376                          * the ACE has an object type and that type
    377                          * is in the tree                           */
    378                         type = get_ace_object_type(ace);
    379 
    380                         if (!tree)
    381                                 continue;
    382 
    383                         if (!type)
    384                                 node = tree;
    385                         else
    386                                 if (!(node = get_object_tree_by_GUID(tree, type)))
    387                                         continue;
    388 
    389                         if (ace->type == SEC_ACE_TYPE_ACCESS_ALLOWED_OBJECT) {
    390                                 object_tree_modify_access(node, ace->access_mask);
    391                                 if (node->remaining_access == 0) {
    392                                         talloc_free(ps_sid);
    393                                         return NT_STATUS_OK;
    394                                 }
    395                         } else {
    396                                 if (node->remaining_access & ace->access_mask){
    397                                         talloc_free(ps_sid);
    398                                         return NT_STATUS_ACCESS_DENIED;
    399                                 }
    400                         }
    401                         break;
    402                 default:        /* Other ACE types not handled/supported */
    403                         break;
    404                 }
    405         }
     469
     470                if (!security_token_has_sid(token, trustee)) {
     471                        continue;
     472                }
     473
     474                switch (ace->type) {
     475                case SEC_ACE_TYPE_ACCESS_ALLOWED:
     476                        if (tree) {
     477                                object_tree_modify_access(tree, ace->access_mask);
     478                        }
     479
     480                        bits_remaining &= ~ace->access_mask;
     481                        break;
     482                case SEC_ACE_TYPE_ACCESS_DENIED:
     483                        if (bits_remaining & ace->access_mask) {
     484                                return NT_STATUS_ACCESS_DENIED;
     485                        }
     486                        break;
     487                case SEC_ACE_TYPE_ACCESS_DENIED_OBJECT:
     488                case SEC_ACE_TYPE_ACCESS_ALLOWED_OBJECT:
     489                        /*
     490                         * check only in case we have provided a tree,
     491                         * the ACE has an object type and that type
     492                         * is in the tree
     493                         */
     494                        type = get_ace_object_type(ace);
     495
     496                        if (!tree) {
     497                                continue;
     498                        }
     499
     500                        if (!type) {
     501                                node = tree;
     502                        } else {
     503                                if (!(node = get_object_tree_by_GUID(tree, type))) {
     504                                        continue;
     505                                }
     506                        }
     507
     508                        if (ace->type == SEC_ACE_TYPE_ACCESS_ALLOWED_OBJECT) {
     509                                object_tree_modify_access(node, ace->access_mask);
     510                                if (node->remaining_access == 0) {
     511                                        return NT_STATUS_OK;
     512                                }
     513                        } else {
     514                                if (node->remaining_access & ace->access_mask){
     515                                        return NT_STATUS_ACCESS_DENIED;
     516                                }
     517                        }
     518                        break;
     519                default:        /* Other ACE types not handled/supported */
     520                        break;
     521                }
     522        }
    406523
    407524done:
    408         talloc_free(ps_sid);
    409         if (bits_remaining != 0) {
    410                 return NT_STATUS_ACCESS_DENIED;
    411         }
    412 
    413         return NT_STATUS_OK;
    414 }
     525        if (bits_remaining != 0) {
     526                return NT_STATUS_ACCESS_DENIED;
     527        }
     528
     529        return NT_STATUS_OK;
     530}
  • vendor/current/libcli/security/access_check.h

    r740 r988  
    5555                         uint32_t *access_granted);
    5656
     57/*
     58  The main entry point for access checking FOR THE FILE SERVER ONLY !
     59  If returning ACCESS_DENIED this function returns the denied bits in
     60  the uint32_t pointed to by the access_granted pointer.
     61*/
     62NTSTATUS se_file_access_check(const struct security_descriptor *sd,
     63                         const struct security_token *token,
     64                         bool priv_open_requested,
     65                         uint32_t access_desired,
     66                         uint32_t *access_granted);
     67
    5768/* modified access check for the purposes of DS security
    5869 * Lots of code duplication, it will ve united in just one
     
    6778
    6879bool insert_in_object_tree(TALLOC_CTX *mem_ctx,
    69                           const struct GUID *guid,
    70                           uint32_t init_access,
    71                           struct object_tree **root,
    72                            struct object_tree **new_node);
     80                           const struct GUID *guid,
     81                           uint32_t init_access,
     82                           struct object_tree *root,
     83                           struct object_tree **new_node_out);
    7384
    7485/* search by GUID */
  • vendor/current/libcli/security/create_descriptor.c

    r740 r988  
    8181static bool object_in_list(struct GUID *object_list, struct GUID *object)
    8282{
    83         return true;
    84 }
    85  
     83        size_t i;
     84
     85        if (object_list == NULL) {
     86                return true;
     87        }
     88
     89        if (GUID_all_zero(object)) {
     90                return true;
     91        }
     92
     93        for (i=0; ; i++) {
     94                if (GUID_all_zero(&object_list[i])) {
     95                        return false;
     96                }
     97                if (!GUID_equal(&object_list[i], object)) {
     98                        continue;
     99                }
     100
     101                return true;
     102        }
     103
     104        return false;
     105}
     106
    86107/* returns true if the ACE gontains generic information
    87108 * that needs to be processed additionally */
    88109 
    89 static bool desc_ace_has_generic(TALLOC_CTX *mem_ctx,
    90                              struct security_ace *ace)
    91 {
    92         struct dom_sid *co, *cg;
    93         co = dom_sid_parse_talloc(mem_ctx,  SID_CREATOR_OWNER);
    94         cg = dom_sid_parse_talloc(mem_ctx,  SID_CREATOR_GROUP);
     110static bool desc_ace_has_generic(struct security_ace *ace)
     111{
    95112        if (ace->access_mask & SEC_GENERIC_ALL || ace->access_mask & SEC_GENERIC_READ ||
    96113            ace->access_mask & SEC_GENERIC_WRITE || ace->access_mask & SEC_GENERIC_EXECUTE) {
    97114                return true;
    98115        }
    99         if (dom_sid_equal(&ace->trustee, co) || dom_sid_equal(&ace->trustee, cg)) {
     116        if (dom_sid_equal(&ace->trustee, &global_sid_Creator_Owner) ||
     117            dom_sid_equal(&ace->trustee, &global_sid_Creator_Group)) {
    100118                return true;
    101119        }
     
    105123/* creates an ace in which the generic information is expanded */
    106124
    107 static void desc_expand_generic(TALLOC_CTX *mem_ctx,
    108                                 struct security_ace *new_ace,
     125static void desc_expand_generic(struct security_ace *new_ace,
    109126                                struct dom_sid *owner,
    110127                                struct dom_sid *group)
    111128{
    112         struct dom_sid *co, *cg;
    113         co = dom_sid_parse_talloc(mem_ctx,  SID_CREATOR_OWNER);
    114         cg = dom_sid_parse_talloc(mem_ctx,  SID_CREATOR_GROUP);
    115129        new_ace->access_mask = map_generic_rights_ds(new_ace->access_mask);
    116         if (dom_sid_equal(&new_ace->trustee, co)) {
     130        if (dom_sid_equal(&new_ace->trustee, &global_sid_Creator_Owner)) {
    117131                new_ace->trustee = *owner;
    118132        }
    119         if (dom_sid_equal(&new_ace->trustee, cg)) {
     133        if (dom_sid_equal(&new_ace->trustee, &global_sid_Creator_Group)) {
    120134                new_ace->trustee = *group;
    121135        }
     
    133147        TALLOC_CTX *tmp_ctx = talloc_new(mem_ctx);
    134148        struct security_acl *tmp_acl = talloc_zero(mem_ctx, struct security_acl);
    135         struct dom_sid *co, *cg;
    136149        if (!tmp_acl) {
    137150                return NULL;
     
    141154                return NULL;
    142155        }
    143         co = dom_sid_parse_talloc(tmp_ctx,  SID_CREATOR_OWNER);
    144         cg = dom_sid_parse_talloc(tmp_ctx,  SID_CREATOR_GROUP);
    145156
    146157        for (i=0; i < acl->num_aces; i++) {
     
    148159                if ((ace->flags & SEC_ACE_FLAG_CONTAINER_INHERIT) ||
    149160                    (ace->flags & SEC_ACE_FLAG_OBJECT_INHERIT)) {
     161                        struct GUID inherited_object = GUID_zero();
     162
    150163                        tmp_acl->aces = talloc_realloc(tmp_acl, tmp_acl->aces,
    151164                                                       struct security_ace,
     
    160173                        /* remove IO flag from the child's ace */
    161174                        if (ace->flags & SEC_ACE_FLAG_INHERIT_ONLY &&
    162                             !desc_ace_has_generic(tmp_ctx, ace)) {
     175                            !desc_ace_has_generic(ace)) {
    163176                                tmp_acl->aces[tmp_acl->num_aces].flags &= ~SEC_ACE_FLAG_INHERIT_ONLY;
    164177                        }
     
    167180                            tmp_acl->aces[tmp_acl->num_aces].flags |= SEC_ACE_FLAG_INHERIT_ONLY;
    168181
    169                         if (ace->type == SEC_ACE_TYPE_ACCESS_ALLOWED_OBJECT ||
    170                             ace->type == SEC_ACE_TYPE_ACCESS_DENIED_OBJECT) {
    171                                 if (!object_in_list(object_list, &ace->object.object.type.type)) {
     182                        switch (ace->type) {
     183                        case SEC_ACE_TYPE_ACCESS_ALLOWED:
     184                        case SEC_ACE_TYPE_ACCESS_DENIED:
     185                        case SEC_ACE_TYPE_SYSTEM_AUDIT:
     186                        case SEC_ACE_TYPE_SYSTEM_ALARM:
     187                        case SEC_ACE_TYPE_ALLOWED_COMPOUND:
     188                                break;
     189
     190                        case SEC_ACE_TYPE_ACCESS_ALLOWED_OBJECT:
     191                        case SEC_ACE_TYPE_ACCESS_DENIED_OBJECT:
     192                        case SEC_ACE_TYPE_SYSTEM_ALARM_OBJECT:
     193                        case SEC_ACE_TYPE_SYSTEM_AUDIT_OBJECT:
     194                                if (ace->object.object.flags & SEC_ACE_INHERITED_OBJECT_TYPE_PRESENT) {
     195                                        inherited_object = ace->object.object.inherited_type.inherited_type;
     196                                }
     197
     198                                if (!object_in_list(object_list, &inherited_object)) {
    172199                                        tmp_acl->aces[tmp_acl->num_aces].flags |= SEC_ACE_FLAG_INHERIT_ONLY;
    173200                                }
    174201
    175                         }
     202                                break;
     203                        }
     204
    176205                        tmp_acl->num_aces++;
    177206                        if (is_container) {
    178207                                if (!(ace->flags & SEC_ACE_FLAG_NO_PROPAGATE_INHERIT) &&
    179                                     (desc_ace_has_generic(tmp_ctx, ace))) {
     208                                    (desc_ace_has_generic(ace))) {
    180209                                            tmp_acl->aces = talloc_realloc(tmp_acl,
    181210                                                                           tmp_acl->aces,
     
    187216                                            }
    188217                                            tmp_acl->aces[tmp_acl->num_aces] = *ace;
    189                                             desc_expand_generic(tmp_ctx,
    190                                                                 &tmp_acl->aces[tmp_acl->num_aces],
     218                                            desc_expand_generic(&tmp_acl->aces[tmp_acl->num_aces],
    191219                                                                owner,
    192220                                                                group);
     
    218246        struct security_acl *tmp_acl = talloc_zero(tmp_ctx, struct security_acl);
    219247        struct security_acl *new_acl;
    220         struct dom_sid *co, *cg;
    221248
    222249        if (!acl)
     
    228255        tmp_acl->revision = acl->revision;
    229256        DEBUG(6,(__location__ ": acl revision %d\n", acl->revision));
    230 
    231         co = dom_sid_parse_talloc(tmp_ctx,  SID_CREATOR_OWNER);
    232         cg = dom_sid_parse_talloc(tmp_ctx,  SID_CREATOR_GROUP);
    233257
    234258        for (i=0; i < acl->num_aces; i++){
     
    261285                 * it has to be expanded to two aces, the original as IO,
    262286                 * and another one where these are translated */
    263                 if (desc_ace_has_generic(tmp_ctx, ace)) {
     287                if (desc_ace_has_generic(ace)) {
    264288                        if (!(ace->flags & SEC_ACE_FLAG_CONTAINER_INHERIT)) {
    265                                 desc_expand_generic(tmp_ctx,
    266                                                     &tmp_acl->aces[tmp_acl->num_aces-1],
     289                                desc_expand_generic(&tmp_acl->aces[tmp_acl->num_aces-1],
    267290                                                    owner,
    268291                                                    group);
     
    275298                                /* add a new ACE with expanded generic info */
    276299                                tmp_acl->aces[tmp_acl->num_aces] = *ace;
    277                                 desc_expand_generic(tmp_ctx,
    278                                                     &tmp_acl->aces[tmp_acl->num_aces],
     300                                desc_expand_generic(&tmp_acl->aces[tmp_acl->num_aces],
    279301                                                    owner,
    280302                                                    group);
  • vendor/current/libcli/security/display_sec.c

    r740 r988  
    1 /* 
     1/*
    22   Unix SMB/CIFS implementation.
    33   Samba utility functions
    44   Copyright (C) Andrew Tridgell 1992-1999
    55   Copyright (C) Luke Kenneth Casson Leighton 1996 - 1999
    6    
     6
    77   This program is free software; you can redistribute it and/or modify
    88   it under the terms of the GNU General Public License as published by
    99   the Free Software Foundation; either version 3 of the License, or
    1010   (at your option) any later version.
    11    
    12    This program is distributed in the hope that it will be useful, 
     11
     12   This program is distributed in the hope that it will be useful,
    1313   but WITHOUT ANY WARRANTY; without even the implied warranty of
    1414   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    1515   GNU General Public License for more details.
    16    
     16
    1717   You should have received a copy of the GNU General Public License
    1818   along with this program.  If not, see <http://www.gnu.org/licenses/>.
     
    238238
    239239        printf("\tACL\tNum ACEs:\t%u\trevision:\t%x\n",
    240                          sec_acl->num_aces, sec_acl->revision);
     240               sec_acl->num_aces, sec_acl->revision);
    241241        printf("\t---\n");
    242242
     
    284284        if (type & SEC_DESC_SELF_RELATIVE)      /* 0x8000 */
    285285                printf("SEC_DESC_SELF_RELATIVE ");
    286        
     286
    287287        printf("\n");
    288288}
  • vendor/current/libcli/security/dom_sid.c

    r740 r988  
    121121 Return the first character not parsed in endp.
    122122*****************************************************************/
     123#define AUTHORITY_MASK (~(0xffffffffffffULL))
    123124
    124125bool dom_sid_parse_endp(const char *sidstr,struct dom_sid *sidout,
     
    128129        char *q;
    129130        /* BIG NOTE: this function only does SIDS where the identauth is not >= 2^32 */
    130         uint32_t conv;
     131        uint64_t conv;
    131132
    132133        ZERO_STRUCTP(sidout);
     
    143144        }
    144145
    145         conv = (uint32_t) strtoul(p, &q, 10);
    146         if (!q || (*q != '-')) {
     146        conv = strtoul(p, &q, 10);
     147        if (!q || (*q != '-') || conv > UINT8_MAX) {
    147148                goto format_error;
    148149        }
     
    155156
    156157        /* get identauth */
    157         conv = (uint32_t) strtoul(q, &q, 10);
    158         if (!q) {
     158        conv = strtoull(q, &q, 0);
     159        if (!q || conv & AUTHORITY_MASK) {
    159160                goto format_error;
    160161        }
    161162
    162         /* identauth in decimal should be <  2^32 */
     163        /* When identauth >= UINT32_MAX, it's in hex with a leading 0x */
    163164        /* NOTE - the conv value is in big-endian format. */
    164         sidout->id_auth[0] = 0;
    165         sidout->id_auth[1] = 0;
    166         sidout->id_auth[2] = (conv & 0xff000000) >> 24;
    167         sidout->id_auth[3] = (conv & 0x00ff0000) >> 16;
    168         sidout->id_auth[4] = (conv & 0x0000ff00) >> 8;
    169         sidout->id_auth[5] = (conv & 0x000000ff);
     165        sidout->id_auth[0] = (conv & 0xff0000000000ULL) >> 40;
     166        sidout->id_auth[1] = (conv & 0x00ff00000000ULL) >> 32;
     167        sidout->id_auth[2] = (conv & 0x0000ff000000ULL) >> 24;
     168        sidout->id_auth[3] = (conv & 0x000000ff0000ULL) >> 16;
     169        sidout->id_auth[4] = (conv & 0x00000000ff00ULL) >> 8;
     170        sidout->id_auth[5] = (conv & 0x0000000000ffULL);
    170171
    171172        sidout->num_auths = 0;
     
    184185                }
    185186
    186                 conv = strtoul(q, &end, 10);
    187                 if (end == q) {
     187                conv = strtoull(q, &end, 10);
     188                if (end == q || conv > UINT32_MAX) {
    188189                        goto format_error;
    189190                }
     
    243244struct dom_sid *dom_sid_parse_length(TALLOC_CTX *mem_ctx, const DATA_BLOB *sid)
    244245{
    245         struct dom_sid *ret;
    246         char *p = talloc_strndup(mem_ctx, (char *)sid->data, sid->length);
    247         if (!p) {
    248                 return NULL;
    249         }
    250         ret = dom_sid_parse_talloc(mem_ctx, p);
    251         talloc_free(p);
    252         return ret;
     246        char p[sid->length+1];
     247        memcpy(p, sid->data, sid->length);
     248        p[sid->length] = '\0';
     249        return dom_sid_parse_talloc(mem_ctx, p);
    253250}
    254251
     
    365362{
    366363        int i, ofs;
    367         uint32_t ia;
     364        uint64_t ia;
    368365
    369366        if (!sid) {
    370                 strlcpy(buf, "(NULL SID)", buflen);
    371                 return 10;      /* strlen("(NULL SID)") */
    372         }
    373 
    374         ia = (sid->id_auth[5]) +
    375                 (sid->id_auth[4] << 8 ) +
    376                 (sid->id_auth[3] << 16) +
    377                 (sid->id_auth[2] << 24);
    378 
    379         ofs = snprintf(buf, buflen, "S-%u-%lu",
    380                        (unsigned int)sid->sid_rev_num, (unsigned long)ia);
     367                return strlcpy(buf, "(NULL SID)", buflen);
     368        }
     369
     370        ia = ((uint64_t)sid->id_auth[5]) +
     371                ((uint64_t)sid->id_auth[4] << 8 ) +
     372                ((uint64_t)sid->id_auth[3] << 16) +
     373                ((uint64_t)sid->id_auth[2] << 24) +
     374                ((uint64_t)sid->id_auth[1] << 32) +
     375                ((uint64_t)sid->id_auth[0] << 40);
     376
     377        ofs = snprintf(buf, buflen, "S-%hhu-", (unsigned char)sid->sid_rev_num);
     378        if (ia >= UINT32_MAX) {
     379                ofs += snprintf(buf + ofs, MAX(buflen - ofs, 0), "0x%llx",
     380                                (unsigned long long)ia);
     381        } else {
     382                ofs += snprintf(buf + ofs, MAX(buflen - ofs, 0), "%llu",
     383                                (unsigned long long)ia);
     384        }
    381385
    382386        for (i = 0; i < sid->num_auths; i++) {
    383                 ofs += snprintf(buf + ofs, MAX(buflen - ofs, 0), "-%lu",
    384                                 (unsigned long)sid->sub_auths[i]);
     387                ofs += snprintf(buf + ofs, MAX(buflen - ofs, 0), "-%u",
     388                                (unsigned int)sid->sub_auths[i]);
    385389        }
    386390        return ofs;
     
    407411         */
    408412        result = (char *)talloc_memdup(mem_ctx, buf, len+1);
     413        if (result == NULL) {
     414                return NULL;
     415        }
    409416
    410417        /*
  • vendor/current/libcli/security/dom_sid.h

    r740 r988  
    2929extern const struct dom_sid global_sid_World_Domain;
    3030extern const struct dom_sid global_sid_World;
     31extern const struct dom_sid global_sid_Local_Authority;
    3132extern const struct dom_sid global_sid_Creator_Owner_Domain;
    3233extern const struct dom_sid global_sid_NT_Authority;
     
    3637extern const struct dom_sid global_sid_Authenticated_Users;
    3738extern const struct dom_sid global_sid_Network;
     39extern const struct dom_sid global_sid_Asserted_Identity;
     40extern const struct dom_sid global_sid_Asserted_Identity_Service;
     41extern const struct dom_sid global_sid_Asserted_Identity_Authentication_Authority;
    3842extern const struct dom_sid global_sid_Creator_Owner;
    3943extern const struct dom_sid global_sid_Creator_Group;
     44extern const struct dom_sid global_sid_Owner_Rights;
    4045extern const struct dom_sid global_sid_Anonymous;
    4146extern const struct dom_sid global_sid_Builtin;
     
    5257extern const struct dom_sid global_sid_Unix_Users;
    5358extern const struct dom_sid global_sid_Unix_Groups;
     59extern const struct dom_sid global_sid_Unix_NFS;
     60extern const struct dom_sid global_sid_Unix_NFS_Users;
     61extern const struct dom_sid global_sid_Unix_NFS_Groups;
     62extern const struct dom_sid global_sid_Unix_NFS_Mode;
     63extern const struct dom_sid global_sid_Unix_NFS_Other;
    5464
    5565int dom_sid_compare_auth(const struct dom_sid *sid1,
     
    8797bool sid_peek_check_rid(const struct dom_sid *exp_dom_sid, const struct dom_sid *sid, uint32_t *rid);
    8898void sid_copy(struct dom_sid *dst, const struct dom_sid *src);
    89 bool sid_blob_parse(DATA_BLOB in, struct dom_sid *sid);
    90 bool sid_parse(const char *inbuf, size_t len, struct dom_sid *sid);
     99bool sid_parse(const uint8_t *inbuf, size_t len, struct dom_sid *sid);
    91100int sid_compare_domain(const struct dom_sid *sid1, const struct dom_sid *sid2);
    92 bool sid_equal(const struct dom_sid *sid1, const struct dom_sid *sid2);
    93101NTSTATUS add_sid_to_array(TALLOC_CTX *mem_ctx, const struct dom_sid *sid,
    94102                          struct dom_sid **sids, uint32_t *num);
  • vendor/current/libcli/security/object_tree.c

    r740 r988  
    3939
    4040bool insert_in_object_tree(TALLOC_CTX *mem_ctx,
    41                           const struct GUID *guid,
    42                           uint32_t init_access,
    43                           struct object_tree **root,
    44                           struct object_tree **new_node)
     41                           const struct GUID *guid,
     42                           uint32_t init_access,
     43                           struct object_tree *root,
     44                           struct object_tree **new_node_out)
    4545{
     46        struct object_tree *new_node;
     47
    4648        if (!guid || GUID_all_zero(guid)){
    4749                return true;
    4850        }
    4951
    50         if (!*root){
    51                 *root = talloc_zero(mem_ctx, struct object_tree);
    52                 if (!*root) {
     52        if (!root) {
     53                root = talloc_zero(mem_ctx, struct object_tree);
     54                if (!root) {
    5355                        return false;
    5456                }
    55                 (*root)->guid = *guid;
    56                 *new_node = *root;
    57                 return true;
    58         }
     57                new_node = root;
     58        } else {
     59                int i;
    5960
    60         if (!(*root)->children) {
    61                 (*root)->children = talloc_array(mem_ctx, struct object_tree, 1);
    62                 (*root)->children[0].guid = *guid;
    63                 (*root)->children[0].num_of_children = 0;
    64                 (*root)->children[0].children = NULL;
    65                 (*root)->num_of_children++;
    66                 (*root)->children[0].remaining_access = init_access;
    67                 *new_node = &((*root)->children[0]);
    68                 return true;
    69         }
    70         else {
    71                 int i;
    72                 for (i = 0; i < (*root)->num_of_children; i++) {
    73                         if (GUID_equal(&((*root)->children[i].guid), guid)) {
    74                                 *new_node = &((*root)->children[i]);
     61                for (i = 0; i < root->num_of_children; i++) {
     62                        if (GUID_equal(&root->children[i].guid, guid)) {
     63                                new_node = &root->children[i];
     64                                new_node->remaining_access |= init_access;
     65                                *new_node_out = new_node;
    7566                                return true;
    7667                        }
    7768                }
    78                 (*root)->children = talloc_realloc(mem_ctx, (*root)->children, struct object_tree,
    79                                                    (*root)->num_of_children +1);
    80                 (*root)->children[(*root)->num_of_children].guid = *guid;
    81                 (*root)->children[(*root)->num_of_children].remaining_access = init_access;
    82                 *new_node = &((*root)->children[(*root)->num_of_children]);
    83                 (*root)->num_of_children++;
    84                 return true;
     69
     70                root->children = talloc_realloc(mem_ctx, root->children,
     71                                                struct object_tree,
     72                                                root->num_of_children + 1);
     73                if (!root->children) {
     74                        return false;
     75                }
     76                new_node = &root->children[root->num_of_children];
     77                root->num_of_children++;
    8578        }
     79
     80        new_node->children = NULL;
     81        new_node->guid = *guid;
     82        new_node->remaining_access = init_access;
     83        new_node->num_of_children = 0;
     84
     85        *new_node_out = new_node;
     86        return true;
    8687}
    8788
     
    9798                return result;
    9899        }
    99         else if (root->num_of_children > 0) {
    100                 for (i = 0; i < root->num_of_children; i++) {
     100        for (i = 0; i < root->num_of_children; i++) {
    101101                if ((result = get_object_tree_by_GUID(&root->children[i], guid)))
    102102                        break;
    103                 }
    104103        }
    105104        return result;
    106105}
    107106
    108 /* Change the granted access per each ACE */
    109 
     107/**
     108 * @brief Modify the tree to mark specified access rights as granted
     109 *
     110 * This function will modify the root and the child of the tree pointed by
     111 * root, so that for each tree element the bits set in access_mask are
     112 * marked as granted.
     113 *
     114 * @param[in]  root        An object_tree structure that we want to modify
     115 *
     116 * @param[in]  access_mask A bitfield of access right that we want to mark as
     117 *                         granted in the whole tree.
     118 */
    110119void object_tree_modify_access(struct object_tree *root,
    111120                               uint32_t access_mask)
    112121{
     122        int i;
    113123        root->remaining_access &= ~access_mask;
    114         if (root->num_of_children > 0) {
    115                 int i;
    116                 for (i = 0; i < root->num_of_children; i++) {
    117                         object_tree_modify_access(&root->children[i], access_mask);
    118                 }
     124        for (i = 0; i < root->num_of_children; i++) {
     125                object_tree_modify_access(&root->children[i], access_mask);
    119126        }
    120127}
  • vendor/current/libcli/security/privileges.c

    r740 r988  
    423423}
    424424
     425bool security_token_system_privilege(const struct security_token *token)
     426{
     427        if (token == NULL) {
     428                return false;
     429        }
     430
     431        if (token->privilege_mask == (uint64_t)~0) {
     432                return true;
     433        }
     434
     435        return false;
     436}
     437
    425438/*
    426439  set a bit in the privilege mask
  • vendor/current/libcli/security/privileges.h

    r740 r988  
    9090bool security_token_has_privilege(const struct security_token *token, enum sec_privilege privilege);
    9191
     92
     93/**
     94 * @brief Check if the security token has system privileges.
     95 *
     96 * @param[in]  token    The token to check.
     97 *
     98 * @return              True if the token has system privileges, false if not.
     99 */
     100bool security_token_system_privilege(const struct security_token *token);
     101
    92102/*
    93103  set a bit in the privilege mask
  • vendor/current/libcli/security/pysecurity.c

    r740 r988  
    4545        }
    4646
    47         security_descriptor = py_talloc_get_type(py_sec_desc, struct security_descriptor);
     47        security_descriptor = pytalloc_get_type(py_sec_desc, struct security_descriptor);
    4848        if (!security_descriptor) {
    4949                PyErr_Format(PyExc_TypeError,
    5050                             "Expected dcerpc.security.descriptor for security_descriptor argument got  %s",
    51                              talloc_get_name(py_talloc_get_ptr(py_sec_desc)));
     51                             talloc_get_name(pytalloc_get_ptr(py_sec_desc)));
    5252                return NULL;
    5353        }
    5454
    55         security_token = py_talloc_get_type(py_security_token, struct security_token);
     55        security_token = pytalloc_get_type(py_security_token, struct security_token);
    5656        if (!security_token) {
    5757                PyErr_Format(PyExc_TypeError,
    5858                             "Expected dcerpc.security.token for token argument, got %s",
    59                              talloc_get_name(py_talloc_get_ptr(py_security_token)));
     59                             talloc_get_name(pytalloc_get_ptr(py_security_token)));
    6060                return NULL;
    6161        }
  • vendor/current/libcli/security/sddl.c

    r740 r988  
    8282        { "LS", SID_NT_LOCAL_SERVICE },
    8383        { "NS", SID_NT_NETWORK_SERVICE },
     84        { "IS", SID_NT_IUSR },
    8485
    8586        { "BA", SID_BUILTIN_ADMINISTRATORS },
  • vendor/current/libcli/security/secace.c

    r740 r988  
    6868
    6969        t->trustee = *sid;
    70 }
    71 
    72 /*******************************************************************
    73  adds new SID with its permissions to ACE list
    74 ********************************************************************/
    75 
    76 NTSTATUS sec_ace_add_sid(TALLOC_CTX *ctx, struct security_ace **pp_new, struct security_ace *old, unsigned *num, const struct dom_sid *sid, uint32_t mask)
    77 {
    78         unsigned int i = 0;
    79        
    80         if (!ctx || !pp_new || !old || !sid || !num)  return NT_STATUS_INVALID_PARAMETER;
    81 
    82         *num += 1;
    83        
    84         if((pp_new[0] = talloc_zero_array(ctx, struct security_ace, *num )) == 0)
    85                 return NT_STATUS_NO_MEMORY;
    86 
    87         for (i = 0; i < *num - 1; i ++)
    88                 sec_ace_copy(&(*pp_new)[i], &old[i]);
    89 
    90         (*pp_new)[i].type  = SEC_ACE_TYPE_ACCESS_ALLOWED;
    91         (*pp_new)[i].flags = 0;
    92         (*pp_new)[i].size  = SEC_ACE_HEADER_SIZE + ndr_size_dom_sid(sid, 0);
    93         (*pp_new)[i].access_mask = mask;
    94         (*pp_new)[i].trustee = *sid;
    95         return NT_STATUS_OK;
    96 }
    97 
    98 /*******************************************************************
    99   modify SID's permissions at ACL
    100 ********************************************************************/
    101 
    102 NTSTATUS sec_ace_mod_sid(struct security_ace *ace, size_t num, const struct dom_sid *sid, uint32_t mask)
    103 {
    104         unsigned int i = 0;
    105 
    106         if (!ace || !sid)  return NT_STATUS_INVALID_PARAMETER;
    107 
    108         for (i = 0; i < num; i ++) {
    109                 if (dom_sid_equal(&ace[i].trustee, sid)) {
    110                         ace[i].access_mask = mask;
    111                         return NT_STATUS_OK;
    112                 }
    113         }
    114         return NT_STATUS_NOT_FOUND;
    115 }
    116 
    117 /*******************************************************************
    118  delete SID from ACL
    119 ********************************************************************/
    120 
    121 NTSTATUS sec_ace_del_sid(TALLOC_CTX *ctx, struct security_ace **pp_new, struct security_ace *old, uint32_t *num, const struct dom_sid *sid)
    122 {
    123         unsigned int i     = 0;
    124         unsigned int n_del = 0;
    125 
    126         if (!ctx || !pp_new || !old || !sid || !num)  return NT_STATUS_INVALID_PARAMETER;
    127 
    128         if (*num) {
    129                 if((pp_new[0] = talloc_zero_array(ctx, struct security_ace, *num )) == 0)
    130                         return NT_STATUS_NO_MEMORY;
    131         } else {
    132                 pp_new[0] = NULL;
    133         }
    134 
    135         for (i = 0; i < *num; i ++) {
    136                 if (!dom_sid_equal(&old[i].trustee, sid))
    137                         sec_ace_copy(&(*pp_new)[i], &old[i]);
    138                 else
    139                         n_del ++;
    140         }
    141         if (n_del == 0)
    142                 return NT_STATUS_NOT_FOUND;
    143         else {
    144                 *num -= n_del;
    145                 return NT_STATUS_OK;
    146         }
    147 }
    148 
    149 /*******************************************************************
    150  Compares two struct security_ace structures
    151 ********************************************************************/
    152 
    153 bool sec_ace_equal(const struct security_ace *s1, const struct security_ace *s2)
    154 {
    155         /* Trivial case */
    156 
    157         if (!s1 && !s2) {
    158                 return true;
    159         }
    160 
    161         if (!s1 || !s2) {
    162                 return false;
    163         }
    164 
    165         /* Check top level stuff */
    166 
    167         if (s1->type != s2->type || s1->flags != s2->flags ||
    168             s1->access_mask != s2->access_mask) {
    169                 return false;
    170         }
    171 
    172         /* Check SID */
    173 
    174         if (!dom_sid_equal(&s1->trustee, &s2->trustee)) {
    175                 return false;
    176         }
    177 
    178         return true;
    17970}
    18071
  • vendor/current/libcli/security/secace.h

    r740 r988  
    2828void init_sec_ace(struct security_ace *t, const struct dom_sid *sid, enum security_ace_type type,
    2929                  uint32_t mask, uint8_t flag);
    30 NTSTATUS sec_ace_add_sid(TALLOC_CTX *ctx, struct security_ace **pp_new, struct security_ace *old, unsigned *num, const struct dom_sid *sid, uint32_t mask);
    31 NTSTATUS sec_ace_mod_sid(struct security_ace *ace, size_t num, const struct dom_sid *sid, uint32_t mask);
    32 NTSTATUS sec_ace_del_sid(TALLOC_CTX *ctx, struct security_ace **pp_new, struct security_ace *old, uint32_t *num, const struct dom_sid *sid);
    33 bool sec_ace_equal(const struct security_ace *s1, const struct security_ace *s2);
    3430int nt_ace_inherit_comp( const struct security_ace *a1, const struct security_ace *a2);
    3531int nt_ace_canon_comp( const struct security_ace *a1, const struct security_ace *a2);
  • vendor/current/libcli/security/secacl.c

    r740 r988  
    1 /* 
     1/*
    22 *  Unix SMB/Netbios implementation.
    33 *  SEC_ACL handling routines
     
    66 *  Copyright (C) Luke Kenneth Casson Leighton 1996-1998,
    77 *  Copyright (C) Paul Ashton                  1997-1998.
    8  * 
     8 *
    99 *  This program is free software; you can redistribute it and/or modify
    1010 *  it under the terms of the GNU General Public License as published by
    1111 *  the Free Software Foundation; either version 3 of the License, or
    1212 *  (at your option) any later version.
    13  * 
     13 *
    1414 *  This program is distributed in the hope that it will be useful,
    1515 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
    1616 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    1717 *  GNU General Public License for more details.
    18  * 
     18 *
    1919 *  You should have received a copy of the GNU General Public License
    2020 *  along with this program; if not, see <http://www.gnu.org/licenses/>.
     
    2929
    3030/*******************************************************************
    31  Create a SEC_ACL structure. 
     31 Create a SEC_ACL structure.
    3232********************************************************************/
    3333
    34 struct security_acl *make_sec_acl(TALLOC_CTX *ctx, 
    35                                                                   enum security_acl_revision revision,
    36                                                                   int num_aces, struct security_ace *ace_list)
     34struct security_acl *make_sec_acl(TALLOC_CTX *ctx,
     35                                  enum security_acl_revision revision,
     36                                  int num_aces, struct security_ace *ace_list)
    3737{
    3838        struct security_acl *dst;
    3939        int i;
    4040
    41         if((dst = talloc_zero(ctx, struct security_acl)) == NULL)
     41        dst = talloc(ctx, struct security_acl);
     42        if (dst == NULL) {
    4243                return NULL;
     44        }
    4345
    4446        dst->revision = revision;
    4547        dst->num_aces = num_aces;
    4648        dst->size = SEC_ACL_HEADER_SIZE;
     49        dst->aces = NULL;
    4750
    4851        /* Now we need to return a non-NULL address for the ace list even
     
    5255           positive number. */
    5356
    54         if ((num_aces) &&
    55             ((dst->aces = talloc_array(dst, struct security_ace, num_aces))
    56              == NULL)) {
     57        if (num_aces == 0) {
     58                return dst;
     59        }
     60
     61        dst->aces = talloc_array(dst, struct security_ace, num_aces);
     62        if (dst->aces == NULL) {
     63                TALLOC_FREE(dst);
    5764                return NULL;
    5865        }
    59        
     66
    6067        for (i = 0; i < num_aces; i++) {
    6168                dst->aces[i] = ace_list[i]; /* Structure copy. */
     
    6572        return dst;
    6673}
    67 
    68 /*******************************************************************
    69  Duplicate a SEC_ACL structure. 
    70 ********************************************************************/
    71 
    72 struct security_acl *dup_sec_acl(TALLOC_CTX *ctx, struct security_acl *src)
    73 {
    74         if(src == NULL)
    75                 return NULL;
    76 
    77         return make_sec_acl(ctx, src->revision, src->num_aces, src->aces);
    78 }
  • vendor/current/libcli/security/secacl.h

    r740 r988  
    2626struct security_acl *make_sec_acl(TALLOC_CTX *ctx, enum security_acl_revision revision,
    2727                      int num_aces, struct security_ace *ace_list);
    28 struct security_acl *dup_sec_acl(TALLOC_CTX *ctx, struct security_acl *src);
    2928
    3029
  • vendor/current/libcli/security/security.h

    r740 r988  
    9090#define SHARE_READ_ONLY       (FILE_GENERIC_READ|FILE_EXECUTE)
    9191
     92/**
     93 * Remaining access is a bit mask of remaining access rights (bits) that have
     94 * to be granted in order to fulfill the requested access.
     95 *
     96 * The GUID is optional, if specified it restricts this object tree and its
     97 * childs to object/attributes that inherits from this GUID.
     98 * For DS access an object inherits from a GUID if one of its class has this GUID
     99 * in the schemaIDGUID attribute.
     100 */
    92101struct object_tree {
    93102        uint32_t remaining_access;
     
    101110#include "libcli/security/secace.h"
    102111#include "libcli/security/secacl.h"
     112#include "libcli/security/secdesc.h"
    103113#include "libcli/security/security_descriptor.h"
    104114#include "libcli/security/security_token.h"
  • vendor/current/libcli/security/security_descriptor.c

    r740 r988  
    183183}
    184184
     185NTSTATUS security_descriptor_for_client(TALLOC_CTX *mem_ctx,
     186                                        const struct security_descriptor *ssd,
     187                                        uint32_t sec_info,
     188                                        uint32_t access_granted,
     189                                        struct security_descriptor **_csd)
     190{
     191        struct security_descriptor *csd = NULL;
     192        uint32_t access_required = 0;
     193
     194        *_csd = NULL;
     195
     196        if (sec_info & (SECINFO_OWNER|SECINFO_GROUP)) {
     197                access_required |= SEC_STD_READ_CONTROL;
     198        }
     199        if (sec_info & SECINFO_DACL) {
     200                access_required |= SEC_STD_READ_CONTROL;
     201        }
     202        if (sec_info & SECINFO_SACL) {
     203                access_required |= SEC_FLAG_SYSTEM_SECURITY;
     204        }
     205
     206        if (access_required & (~access_granted)) {
     207                return NT_STATUS_ACCESS_DENIED;
     208        }
     209
     210        /*
     211         * make a copy...
     212         */
     213        csd = security_descriptor_copy(mem_ctx, ssd);
     214        if (csd == NULL) {
     215                return NT_STATUS_NO_MEMORY;
     216        }
     217
     218        /*
     219         * ... and remove everthing not wanted
     220         */
     221
     222        if (!(sec_info & SECINFO_OWNER)) {
     223                TALLOC_FREE(csd->owner_sid);
     224                csd->type &= ~SEC_DESC_OWNER_DEFAULTED;
     225        }
     226        if (!(sec_info & SECINFO_GROUP)) {
     227                TALLOC_FREE(csd->group_sid);
     228                csd->type &= ~SEC_DESC_GROUP_DEFAULTED;
     229        }
     230        if (!(sec_info & SECINFO_DACL)) {
     231                TALLOC_FREE(csd->dacl);
     232                csd->type &= ~(
     233                        SEC_DESC_DACL_PRESENT |
     234                        SEC_DESC_DACL_DEFAULTED|
     235                        SEC_DESC_DACL_AUTO_INHERIT_REQ |
     236                        SEC_DESC_DACL_AUTO_INHERITED |
     237                        SEC_DESC_DACL_PROTECTED |
     238                        SEC_DESC_DACL_TRUSTED);
     239        }
     240        if (!(sec_info & SECINFO_SACL)) {
     241                TALLOC_FREE(csd->sacl);
     242                csd->type &= ~(
     243                        SEC_DESC_SACL_PRESENT |
     244                        SEC_DESC_SACL_DEFAULTED |
     245                        SEC_DESC_SACL_AUTO_INHERIT_REQ |
     246                        SEC_DESC_SACL_AUTO_INHERITED |
     247                        SEC_DESC_SACL_PROTECTED |
     248                        SEC_DESC_SERVER_SECURITY);
     249        }
     250
     251        *_csd = csd;
     252        return NT_STATUS_OK;
     253}
     254
    185255/*
    186256  add an ACE to an ACL of a security_descriptor
     
    345415  compare two security ace structures
    346416*/
    347 bool security_ace_equal(const struct security_ace *ace1, 
     417bool security_ace_equal(const struct security_ace *ace1,
    348418                        const struct security_ace *ace2)
    349419{
    350         if (ace1 == ace2) return true;
    351         if (!ace1 || !ace2) return false;
    352         if (ace1->type != ace2->type) return false;
    353         if (ace1->flags != ace2->flags) return false;
    354         if (ace1->access_mask != ace2->access_mask) return false;
    355         if (!dom_sid_equal(&ace1->trustee, &ace2->trustee)) return false;
    356 
    357         return true;   
     420        if (ace1 == ace2) {
     421                return true;
     422        }
     423        if ((ace1 == NULL) || (ace2 == NULL)) {
     424                return false;
     425        }
     426        if (ace1->type != ace2->type) {
     427                return false;
     428        }
     429        if (ace1->flags != ace2->flags) {
     430                return false;
     431        }
     432        if (ace1->access_mask != ace2->access_mask) {
     433                return false;
     434        }
     435        if (!dom_sid_equal(&ace1->trustee, &ace2->trustee)) {
     436                return false;
     437        }
     438
     439        return true;
    358440}
    359441
     
    565647
    566648{
    567         struct dom_sid *sid;
    568649        struct security_ace *ace;
     650        bool ok;
    569651
    570652        ace = talloc_zero(mem_ctx, struct security_ace);
     
    573655        }
    574656
    575         sid = dom_sid_parse_talloc(ace, sid_str);
    576         if (sid == NULL) {
     657        ok = dom_sid_parse(sid_str, &ace->trustee);
     658        if (!ok) {
    577659                talloc_free(ace);
    578660                return NULL;
    579661        }
    580 
    581         ace->trustee = *sid;
    582662        ace->type = type;
    583663        ace->access_mask = access_mask;
     
    586666        return ace;
    587667}
     668
     669/*******************************************************************
     670 Check for MS NFS ACEs in a sd
     671*******************************************************************/
     672bool security_descriptor_with_ms_nfs(const struct security_descriptor *psd)
     673{
     674        int i;
     675
     676        if (psd->dacl == NULL) {
     677                return false;
     678        }
     679
     680        for (i = 0; i < psd->dacl->num_aces; i++) {
     681                if (dom_sid_compare_domain(
     682                            &global_sid_Unix_NFS,
     683                            &psd->dacl->aces[i].trustee) == 0) {
     684                        return true;
     685                }
     686        }
     687
     688        return false;
     689}
  • vendor/current/libcli/security/security_descriptor.h

    r740 r988  
    2727struct security_descriptor *security_descriptor_copy(TALLOC_CTX *mem_ctx,
    2828                                                     const struct security_descriptor *osd);
     29NTSTATUS security_descriptor_for_client(TALLOC_CTX *mem_ctx,
     30                                        const struct security_descriptor *ssd,
     31                                        uint32_t sec_info,
     32                                        uint32_t access_granted,
     33                                        struct security_descriptor **_csd);
    2934NTSTATUS security_descriptor_sacl_add(struct security_descriptor *sd,
    3035                                      const struct security_ace *ace);
     
    8287                                                       uint32_t (*generic_map)(uint32_t access_mask));
    8388
     89bool security_descriptor_with_ms_nfs(const struct security_descriptor *psd);
     90
    8491#endif /* __SECURITY_DESCRIPTOR_H__ */
  • vendor/current/libcli/security/security_token.c

    r740 r988  
    8585{
    8686        bool ret;
    87         struct dom_sid *sid = dom_sid_parse_talloc(NULL, sid_string);
    88         if (!sid) return false;
     87        struct dom_sid sid;
    8988
    90         ret = security_token_is_sid(token, sid);
     89        ret = dom_sid_parse(sid_string, &sid);
     90        if (!ret) {
     91                return false;
     92        }
    9193
    92         talloc_free(sid);
     94        ret = security_token_is_sid(token, &sid);
    9395        return ret;
    9496}
     
    118120{
    119121        bool ret;
    120         struct dom_sid *sid = dom_sid_parse_talloc(NULL, sid_string);
    121         if (!sid) return false;
     122        struct dom_sid sid;
    122123
    123         ret = security_token_has_sid(token, sid);
     124        ret = dom_sid_parse(sid_string, &sid);
     125        if (!ret) {
     126                return false;
     127        }
    124128
    125         talloc_free(sid);
     129        ret = security_token_has_sid(token, &sid);
    126130        return ret;
     131}
     132
     133bool security_token_has_builtin_guests(const struct security_token *token)
     134{
     135        return security_token_has_sid(token, &global_sid_Builtin_Guests);
    127136}
    128137
  • vendor/current/libcli/security/security_token.h

    r740 r988  
    5252bool security_token_has_sid_string(const struct security_token *token, const char *sid_string);
    5353
     54bool security_token_has_builtin_guests(const struct security_token *token);
     55
    5456bool security_token_has_builtin_administrators(const struct security_token *token);
    5557
  • vendor/current/libcli/security/session.c

    r740 r988  
    3939        }
    4040
     41        if (security_token_has_builtin_guests(session_info->security_token)) {
     42                return SECURITY_GUEST;
     43        }
     44
    4145        if (security_token_has_builtin_administrators(session_info->security_token)) {
    4246                return SECURITY_ADMINISTRATOR;
  • vendor/current/libcli/security/session.h

    r740 r988  
    2525enum security_user_level {
    2626        SECURITY_ANONYMOUS            = 0,
     27        SECURITY_GUEST                = 1,
    2728        SECURITY_USER                 = 10,
    2829        SECURITY_RO_DOMAIN_CONTROLLER = 20,
     
    3637struct auth_user_info;
    3738struct auth_user_info_torture;
    38 
    39 struct auth_session_info {
    40         struct security_token *security_token;
    41         struct security_unix_token *unix_token;
    42         struct auth_user_info *info;
    43         struct auth_user_info_unix *unix_info;
    44         struct auth_user_info_torture *torture;
    45         DATA_BLOB session_key;
    46         struct cli_credentials *credentials;
    47 };
     39struct auth_session_info;
    4840
    4941enum security_user_level security_session_user_level(struct auth_session_info *session_info,
  • vendor/current/libcli/security/util_sid.c

    r740 r988  
    3939const struct dom_sid global_sid_World =                      /* Everyone */
    4040{ 1, 1, {0,0,0,0,0,1}, {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0}};
     41const struct dom_sid global_sid_Local_Authority =            /* Local Authority */
     42{ 1, 0, {0,0,0,0,0,2}, {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0}};
    4143const struct dom_sid global_sid_Creator_Owner_Domain =       /* Creator Owner domain */
    4244{ 1, 0, {0,0,0,0,0,3}, {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0}};
     
    5456{ 1, 1, {0,0,0,0,0,5}, {12,0,0,0,0,0,0,0,0,0,0,0,0,0,0}};
    5557#endif
     58
     59const struct dom_sid global_sid_Asserted_Identity =       /* Asserted Identity */
     60{ 1, 0, {0,0,0,0,0,18}, {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0}};
     61const struct dom_sid global_sid_Asserted_Identity_Service =     /* Asserted Identity Service */
     62{ 1, 1, {0,0,0,0,0,18}, {1,0,0,0,0,0,0,0,0,0,0,0,0,0,0}};
     63const struct dom_sid global_sid_Asserted_Identity_Authentication_Authority =    /* Asserted Identity Authentication Authority */
     64{ 1, 1, {0,0,0,0,0,18}, {2,0,0,0,0,0,0,0,0,0,0,0,0,0,0}};
     65
    5666const struct dom_sid global_sid_Network =                       /* Network rids */
    5767{ 1, 1, {0,0,0,0,0,5}, {2,0,0,0,0,0,0,0,0,0,0,0,0,0,0}};
     
    6171const struct dom_sid global_sid_Creator_Group =         /* Creator Group */
    6272{ 1, 1, {0,0,0,0,0,3}, {1,0,0,0,0,0,0,0,0,0,0,0,0,0,0}};
     73const struct dom_sid global_sid_Owner_Rights =          /* Owner Rights */
     74{ 1, 1, {0,0,0,0,0,3}, {4,0,0,0,0,0,0,0,0,0,0,0,0,0,0}};
    6375const struct dom_sid global_sid_Anonymous =                     /* Anonymous login */
    6476{ 1, 1, {0,0,0,0,0,5}, {7,0,0,0,0,0,0,0,0,0,0,0,0,0,0}};
     
    93105{ 1, 1, {0,0,0,0,0,22}, {2,0,0,0,0,0,0,0,0,0,0,0,0,0,0}};
    94106
     107/*
     108 * http://technet.microsoft.com/en-us/library/hh509017(v=ws.10).aspx
     109 */
     110const struct dom_sid global_sid_Unix_NFS =             /* MS NFS and Apple style */
     111{ 1, 1, {0,0,0,0,0,5}, {88,0,0,0,0,0,0,0,0,0,0,0,0,0,0}};
     112const struct dom_sid global_sid_Unix_NFS_Users =                /* Unix uid, MS NFS and Apple style */
     113{ 1, 2, {0,0,0,0,0,5}, {88,1,0,0,0,0,0,0,0,0,0,0,0,0,0}};
     114const struct dom_sid global_sid_Unix_NFS_Groups =               /* Unix gid, MS NFS and Apple style */
     115{ 1, 2, {0,0,0,0,0,5}, {88,2,0,0,0,0,0,0,0,0,0,0,0,0,0}};
     116const struct dom_sid global_sid_Unix_NFS_Mode =                 /* Unix mode */
     117{ 1, 2, {0,0,0,0,0,5}, {88,3,0,0,0,0,0,0,0,0,0,0,0,0,0}};
     118/* Unused, left here for documentary purposes */
     119#if 0
     120const struct dom_sid global_sid_Unix_NFS_Other =                /* Unix other, MS NFS and Apple style */
     121{ 1, 2, {0,0,0,0,0,5}, {88,4,0,0,0,0,0,0,0,0,0,0,0,0,0}};
     122#endif
     123
    95124/* Unused, left here for documentary purposes */
    96125#if 0
     
    222251        int i;
    223252
    224         ZERO_STRUCTP(dst);
    225 
    226         dst->sid_rev_num = src->sid_rev_num;
    227         dst->num_auths = src->num_auths;
     253        *dst = (struct dom_sid) {
     254                .sid_rev_num = src->sid_rev_num,
     255                .num_auths = src->num_auths,
     256        };
    228257
    229258        memcpy(&dst->id_auth[0], &src->id_auth[0], sizeof(src->id_auth));
     
    234263
    235264/*****************************************************************
    236  Parse a on-the-wire SID (in a DATA_BLOB) to a struct dom_sid.
    237 *****************************************************************/
    238 
    239 bool sid_blob_parse(DATA_BLOB in, struct dom_sid *sid)
    240 {
     265 Parse a on-the-wire SID to a struct dom_sid.
     266*****************************************************************/
     267
     268bool sid_parse(const uint8_t *inbuf, size_t len, struct dom_sid *sid)
     269{
     270        DATA_BLOB in = data_blob_const(inbuf, len);
    241271        enum ndr_err_code ndr_err;
    242         ndr_err = ndr_pull_struct_blob_all(&in, NULL, sid,
    243                                            (ndr_pull_flags_fn_t)ndr_pull_dom_sid);
     272
     273        ndr_err = ndr_pull_struct_blob_all(
     274                &in, NULL, sid, (ndr_pull_flags_fn_t)ndr_pull_dom_sid);
    244275        if (!NDR_ERR_CODE_IS_SUCCESS(ndr_err)) {
    245276                return false;
    246277        }
    247278        return true;
    248 }
    249 
    250 /*****************************************************************
    251  Parse a on-the-wire SID to a struct dom_sid.
    252 *****************************************************************/
    253 
    254 bool sid_parse(const char *inbuf, size_t len, struct dom_sid *sid)
    255 {
    256         DATA_BLOB in = data_blob_const(inbuf, len);
    257         return sid_blob_parse(in, sid);
    258279}
    259280
     
    274295
    275296        return dom_sid_compare_auth(sid1, sid2);
    276 }
    277 
    278 /*****************************************************************
    279  Compare two sids.
    280 *****************************************************************/
    281 
    282 bool sid_equal(const struct dom_sid *sid1, const struct dom_sid *sid2)
    283 {
    284         return dom_sid_compare(sid1, sid2) == 0;
    285297}
    286298
     
    316328
    317329        for (i=0; i<(*num_sids); i++) {
    318                 if (dom_sid_compare(sid, &(*sids)[i]) == 0)
     330                if (dom_sid_equal(sid, &(*sids)[i])) {
    319331                        return NT_STATUS_OK;
     332                }
    320333        }
    321334
     
    338351                   and break out of the loop */
    339352
    340                 if ( sid_equal(sid, &sid_list[i]) ) {
     353                if (dom_sid_equal(sid, &sid_list[i])) {
    341354                        *num -= 1;
    342355                        break;
     
    345358
    346359        /* This loop will copy the remainder of the array
    347            if i < num of sids ni the array */
    348 
    349         for ( ; i<*num; i++ )
     360           if i < num of sids in the array */
     361
     362        for ( ; i<*num; i++ ) {
    350363                sid_copy( &sid_list[i], &sid_list[i+1] );
     364        }
    351365
    352366        return;
     
    378392{
    379393        static const struct dom_sid null_sid = {0};
    380         return sid_equal(sid, &null_sid);
    381 }
     394        return dom_sid_equal(sid, &null_sid);
     395}
  • vendor/current/libcli/security/wscript_build

    r740 r988  
    22
    33
    4 bld.SAMBA_LIBRARY('security',
    5                   source='dom_sid.c display_sec.c secace.c secacl.c security_descriptor.c sddl.c privileges.c security_token.c access_check.c object_tree.c create_descriptor.c util_sid.c session.c',
     4bld.SAMBA_LIBRARY('samba-security',
     5                  source='dom_sid.c display_sec.c secace.c secacl.c security_descriptor.c sddl.c privileges.c security_token.c access_check.c object_tree.c create_descriptor.c util_sid.c session.c secdesc.c',
    66                  private_library=True,
    77                  deps='talloc ndr NDR_SECURITY'
    88                  )
    99
    10 if getattr(bld.env, '_SAMBA_BUILD_', 0) == 4:
    11     bld.SAMBA_PYTHON('pysecurity',
    12                      source='pysecurity.c',
    13                      deps='security pytalloc-util',
    14                      realname='samba/security.so'
    15                      )
     10bld.SAMBA_PYTHON('pysecurity',
     11                 source='pysecurity.c',
     12                 deps='samba-security pytalloc-util',
     13                 realname='samba/security.so'
     14                 )
  • vendor/current/libcli/smb/smb2_constants.h

    r746 r988  
    2222#ifndef __LIBCLI_SMB2_SMB2_CONSTANTS_H__
    2323#define __LIBCLI_SMB2_SMB2_CONSTANTS_H__
     24
     25/* offsets into SMB2_TRANSFORM header elements */
     26#define SMB2_TF_PROTOCOL_ID     0x00 /*  4 bytes */
     27#define SMB2_TF_SIGNATURE       0x04 /* 16 bytes */
     28#define SMB2_TF_NONCE           0x14 /* 16 bytes */
     29#define SMB2_TF_MSG_SIZE        0x24 /*  4 bytes */
     30#define SMB2_TF_RESERVED        0x28 /*  2 bytes */
     31#define SMB2_TF_FLAGS           0x2A /*  2 bytes */
     32#define SMB2_TF_SESSION_ID      0x2C /*  8 bytes */
     33
     34#define SMB2_TF_HDR_SIZE        0x34 /* 52 bytes */
     35
     36#define SMB2_TF_MAGIC 0x424D53FD /* 0xFD 'S' 'M' 'B' */
     37
     38#define SMB2_TF_FLAGS_ENCRYPTED     0x0001
    2439
    2540/* offsets into header elements for a sync SMB2 request */
     
    2944#define SMB2_HDR_EPOCH          SMB2_HDR_CREDIT_CHARGE /* TODO: remove this */
    3045#define SMB2_HDR_STATUS         0x08
     46#define SMB2_HDR_CHANNEL_SEQUENCE SMB2_HDR_STATUS /* in requests */
    3147#define SMB2_HDR_OPCODE         0x0c
    3248#define SMB2_HDR_CREDIT         0x0e
     
    4864#define SMB2_HDR_FLAG_CHAINED   0x04
    4965#define SMB2_HDR_FLAG_SIGNED    0x08
     66#define SMB2_HDR_FLAG_PRIORITY_MASK 0x70
    5067#define SMB2_HDR_FLAG_DFS       0x10000000
     68#define SMB2_HDR_FLAG_REPLAY_OPERATION 0x20000000
     69
     70#define SMB2_PRIORITY_MASK_TO_VALUE(__m) (((__m) & SMB2_HDR_FLAG_PRIORITY_MASK) >> 4)
     71#define SMB2_PRIORITY_VALUE_TO_MASK(__v) (((__v) << 4) & SMB2_HDR_FLAG_PRIORITY_MASK)
    5172
    5273/* SMB2 opcodes */
    53 #define SMB2_OP_NEGPROT   0x00
    54 #define SMB2_OP_SESSSETUP 0x01
    55 #define SMB2_OP_LOGOFF    0x02
    56 #define SMB2_OP_TCON      0x03
    57 #define SMB2_OP_TDIS      0x04
    58 #define SMB2_OP_CREATE    0x05
    59 #define SMB2_OP_CLOSE     0x06
    60 #define SMB2_OP_FLUSH     0x07
    61 #define SMB2_OP_READ      0x08
    62 #define SMB2_OP_WRITE     0x09
    63 #define SMB2_OP_LOCK      0x0a
    64 #define SMB2_OP_IOCTL     0x0b
    65 #define SMB2_OP_CANCEL    0x0c
    66 #define SMB2_OP_KEEPALIVE 0x0d
    67 #define SMB2_OP_FIND      0x0e
    68 #define SMB2_OP_NOTIFY    0x0f
    69 #define SMB2_OP_GETINFO   0x10
    70 #define SMB2_OP_SETINFO   0x11
    71 #define SMB2_OP_BREAK     0x12
     74#define SMB2_OP_NEGPROT         0x00
     75#define SMB2_OP_SESSSETUP       0x01
     76#define SMB2_OP_LOGOFF          0x02
     77#define SMB2_OP_TCON            0x03
     78#define SMB2_OP_TDIS            0x04
     79#define SMB2_OP_CREATE          0x05
     80#define SMB2_OP_CLOSE           0x06
     81#define SMB2_OP_FLUSH           0x07
     82#define SMB2_OP_READ            0x08
     83#define SMB2_OP_WRITE           0x09
     84#define SMB2_OP_LOCK            0x0a
     85#define SMB2_OP_IOCTL           0x0b
     86#define SMB2_OP_CANCEL          0x0c
     87#define SMB2_OP_KEEPALIVE       0x0d
     88#define SMB2_OP_QUERY_DIRECTORY 0x0e
     89#define SMB2_OP_NOTIFY          0x0f
     90#define SMB2_OP_GETINFO         0x10
     91#define SMB2_OP_SETINFO         0x11
     92#define SMB2_OP_BREAK           0x12
    7293
    7394#define SMB2_MAGIC 0x424D53FE /* 0xFE 'S' 'M' 'B' */
     
    7798#define SMB2_DIALECT_REVISION_202       0x0202
    7899#define SMB2_DIALECT_REVISION_210       0x0210
     100#define SMB2_DIALECT_REVISION_222       0x0222
     101#define SMB2_DIALECT_REVISION_224       0x0224
     102#define SMB3_DIALECT_REVISION_300       0x0300
     103#define SMB3_DIALECT_REVISION_302       0x0302
     104#define SMB3_DIALECT_REVISION_310       0x0310
     105#define SMB3_DIALECT_REVISION_311       0x0311
    79106#define SMB2_DIALECT_REVISION_2FF       0x02FF
    80107
     
    83110#define SMB2_NEGOTIATE_SIGNING_REQUIRED  0x02
    84111
    85 /* SMB2 capabilities - only 1 so far. I'm sure more will be added */
    86 #define SMB2_CAP_DFS                     0x00000001
    87 #define SMB2_CAP_LEASING                 0x00000002 /* only in dialect 0x210 */
    88 #define SMB2_CAP_LARGE_MTU               0x00000004 /* only in dialect 0x210 */
     112/* SMB2 global capabilities */
     113#define SMB2_CAP_DFS                    0x00000001
     114#define SMB2_CAP_LEASING                0x00000002 /* only in dialect >= 0x210 */
     115#define SMB2_CAP_LARGE_MTU              0x00000004 /* only in dialect >= 0x210 */
     116#define SMB2_CAP_MULTI_CHANNEL          0x00000008 /* only in dialect >= 0x222 */
     117#define SMB2_CAP_PERSISTENT_HANDLES     0x00000010 /* only in dialect >= 0x222 */
     118#define SMB2_CAP_DIRECTORY_LEASING      0x00000020 /* only in dialect >= 0x222 */
     119#define SMB2_CAP_ENCRYPTION             0x00000040 /* only in dialect >= 0x222 */
     120
    89121/* so we can spot new caps as added */
    90 #define SMB2_CAP_ALL                     SMB2_CAP_DFS
    91 
    92 /* SMB2 session flags */
     122#define SMB2_CAP_ALL (\
     123                SMB2_CAP_DFS | \
     124                SMB2_CAP_LEASING | \
     125                SMB2_CAP_LARGE_MTU | \
     126                SMB2_CAP_MULTI_CHANNEL | \
     127                SMB2_CAP_PERSISTENT_HANDLES | \
     128                SMB2_CAP_DIRECTORY_LEASING | \
     129                SMB2_CAP_ENCRYPTION)
     130
     131/* Types of SMB2 Negotiate Contexts - only in dialect >= 0x310 */
     132#define SMB2_PREAUTH_INTEGRITY_CAPABILITIES 0x0001
     133#define SMB2_ENCRYPTION_CAPABILITIES        0x0002
     134
     135/* Values for the SMB2_PREAUTH_INTEGRITY_CAPABILITIES Context (>= 0x310) */
     136#define SMB2_PREAUTH_INTEGRITY_SHA512       0x0001
     137
     138/* Values for the SMB2_ENCRYPTION_CAPABILITIES Context (>= 0x310) */
     139#define SMB2_ENCRYPTION_AES128_CCM         0x0001 /* only in dialect >= 0x224 */
     140#define SMB2_ENCRYPTION_AES128_GCM         0x0002 /* only in dialect >= 0x310 */
     141#define SMB2_NONCE_HIGH_MAX(nonce_len_bytes) ((uint64_t)(\
     142        ((nonce_len_bytes) >= 16) ? UINT64_MAX : \
     143        ((nonce_len_bytes) <= 8) ? 0 : \
     144        (((uint64_t)1 << (((nonce_len_bytes) - 8)*8)) - 1) \
     145        ))
     146
     147/* SMB2 session (request) flags */
     148#define SMB2_SESSION_FLAG_BINDING       0x01
     149/*      SMB2_SESSION_FLAG_ENCRYPT_DATA  0x04       only in dialect >= 0x310 */
     150
     151/* SMB2 session (response) flags */
    93152#define SMB2_SESSION_FLAG_IS_GUEST       0x0001
    94153#define SMB2_SESSION_FLAG_IS_NULL        0x0002
     154#define SMB2_SESSION_FLAG_ENCRYPT_DATA   0x0004 /* in dialect >= 0x224 */
     155
     156/* SMB2 tree connect (request) flags */
     157#define SMB2_SHAREFLAG_CLUSTER_RECONNECT 0x0001 /* only in dialect >= 0x310 */
    95158
    96159/* SMB2 sharetype flags */
     
    110173#define SMB2_SHAREFLAG_ALLOW_NAMESPACE_CACHING           0x0400
    111174#define SMB2_SHAREFLAG_ACCESS_BASED_DIRECTORY_ENUM       0x0800
    112 #define SMB2_SHAREFLAG_ALL                               0x0F33
    113 
    114 /* SMB2 share capafilities */
    115 #define SMB2_SHARE_CAP_DFS              0x8
     175#define SMB2_SHAREFLAG_FORCE_LEVELII_OPLOCKS             0x1000
     176#define SMB2_SHAREFLAG_ENABLE_HASH_V1                    0x2000
     177#define SMB2_SHAREFLAG_ENABLE_HASH_V2                    0x4000
     178#define SMB2_SHAREFLAG_ENCRYPT_DATA                      0x8000
     179#define SMB2_SHAREFLAG_ALL                               0xFF33
     180
     181/* SMB2 share capabilities */
     182#define SMB2_SHARE_CAP_DFS                      0x8
     183#define SMB2_SHARE_CAP_CONTINUOUS_AVAILABILITY  0x10 /* in dialect >= 0x222 */
     184#define SMB2_SHARE_CAP_SCALEOUT                 0x20 /* in dialect >= 0x222 */
     185#define SMB2_SHARE_CAP_CLUSTER                  0x40 /* in dialect >= 0x222 */
     186#define SMB2_SHARE_CAP_ASYMMETRIC               0x80 /* in dialect >= 0x302 */
    116187
    117188/* SMB2 create security flags */
     
    136207/* SMB2 lease bits */
    137208#define SMB2_LEASE_NONE                                  0x00
    138 #define SMB2_LEASE_READ                                  0x01
    139 #define SMB2_LEASE_HANDLE                                0x02
    140 #define SMB2_LEASE_WRITE                                 0x04
     209
     210/* SMB2 lease flags */
     211#define SMB2_LEASE_FLAG_BREAK_IN_PROGRESS                0x00000002
     212#define SMB2_LEASE_FLAG_PARENT_LEASE_KEY_SET             0x00000004
    141213
    142214/* SMB2 lease break flags */
     
    159231#define SMB2_CREATE_TAG_QFID "QFid"
    160232#define SMB2_CREATE_TAG_RQLS "RqLs"
     233#define SMB2_CREATE_TAG_DH2Q "DH2Q"
     234#define SMB2_CREATE_TAG_DH2C "DH2C"
     235#define SMB2_CREATE_TAG_AAPL "AAPL"
     236#define SMB2_CREATE_TAG_APP_INSTANCE_ID "\x45\xBC\xA6\x6A\xEF\xA7\xF7\x4A\x90\x08\xFA\x46\x2E\x14\x4D\x74"
     237#define SVHDX_OPEN_DEVICE_CONTEXT "\x9C\xCB\xCF\x9E\x04\xC1\xE6\x43\x98\x0E\x15\x8D\xA1\xF6\xEC\x83"
     238
     239/* SMB2 notify flags */
     240#define SMB2_WATCH_TREE 0x0001
    161241
    162242/* SMB2 Create ignore some more create_options */
     
    188268#define SMB2_CLOSE_FLAGS_FULL_INFORMATION (0x01)
    189269
     270#define SMB2_READFLAG_READ_UNBUFFERED   0x01
     271
     272#define SMB2_WRITEFLAG_WRITE_THROUGH    0x00000001
     273#define SMB2_WRITEFLAG_WRITE_UNBUFFERED 0x00000002
     274
     275/* 2.2.31 SMB2 IOCTL Request */
     276#define SMB2_IOCTL_FLAG_IS_FSCTL                0x00000001
     277
     278/*
     279 * Flags for durable handle v2 requests
     280 */
     281#define SMB2_DHANDLE_FLAG_PERSISTENT 0x00000002
     282
    190283#endif
  • vendor/current/libcli/smb/smb2_create_blob.c

    r746 r988  
    4242                uint32_t next;
    4343                uint32_t name_offset, name_length;
    44                 uint32_t reserved, data_offset;
     44                uint32_t data_offset;
    4545                uint32_t data_length;
    4646                char *tag;
     
    5454                name_offset = SVAL(data, 4);
    5555                name_length = SVAL(data, 6);
     56#if 0
    5657                reserved    = SVAL(data, 8);
     58#endif
    5759                data_offset = SVAL(data, 10);
    5860                data_length = IVAL(data, 12);
     
    197199                NT_STATUS_HAVE_NO_MEMORY(b->blobs[b->num_blobs].data.data);
    198200        } else {
    199                 b->blobs[b->num_blobs].data = data_blob(NULL, 0);
     201                b->blobs[b->num_blobs].data = data_blob_null;
    200202        }
    201203
  • vendor/current/libcli/smb/smb2_create_blob.h

    r414 r988  
    3434};
    3535
     36struct smb_create_returns {
     37        uint8_t oplock_level;
     38        uint32_t create_action;
     39        NTTIME creation_time;
     40        NTTIME last_access_time;
     41        NTTIME last_write_time;
     42        NTTIME change_time;
     43        uint64_t allocation_size;
     44        uint64_t end_of_file;
     45        uint32_t file_attributes;
     46};
     47
    3648/*
    3749  parse a set of SMB2 create blobs
  • vendor/current/libcli/smb/smb_common.h

    r414 r988  
    2323#define __LIBCLI_SMB_SMB_COMMON_H__
    2424
    25 #include "../libcli/smb/smb2_constants.h"
    26 #include "../libcli/smb/smb2_create_blob.h"
     25#include "libcli/smb/smb_constants.h"
     26#include "libcli/smb/smb2_constants.h"
     27#include "libcli/smb/smb2_create_blob.h"
     28#include "libcli/smb/smb2_lease.h"
     29#include "libcli/smb/smb2_signing.h"
     30#include "libcli/smb/smb_util.h"
     31#include "libcli/smb/smb_unix_ext.h"
    2732
    2833#endif
  • vendor/current/libcli/smbreadline/smbreadline.c

    r740 r988  
    138138                warnings in some.  */
    139139                rl_attempted_completion_function = RL_COMPLETION_CAST completion_fn;
     140
     141                /*
     142                 * We only want sensible characters as the word-break chars
     143                 * for the most part. This allows us to tab through a path.
     144                 */
     145                rl_basic_word_break_characters = " \t\n";
    140146        }
    141147
    142148#if HAVE_DECL_RL_EVENT_HOOK
    143149        if (callback)
    144                 rl_event_hook = (Function *)callback;
     150                rl_event_hook = (rl_hook_func_t *)callback;
    145151#endif
    146152        ret = readline(prompt);
  • vendor/current/libcli/util/doserr.c

    r740 r988  
    4444        { "WERR_NOT_SUPPORTED", WERR_NOT_SUPPORTED },
    4545        { "WERR_DUP_NAME", WERR_DUP_NAME },
    46         { "WERR_BAD_PASSWORD", WERR_BAD_PASSWORD },
    4746        { "WERR_NOMEM", WERR_NOMEM },
    4847        { "WERR_INVALID_NAME", WERR_INVALID_NAME },
    49         { "WERR_UNKNOWN_LEVEL", WERR_UNKNOWN_LEVEL },
    5048        { "WERR_OBJECT_PATH_INVALID", WERR_OBJECT_PATH_INVALID },
    5149        { "WERR_ALREADY_EXISTS", WERR_ALREADY_EXISTS },
     
    310308        { "WERR_WRONG_PASSWORD", WERR_WRONG_PASSWORD },
    311309        { "WERR_CLASS_NOT_REGISTERED", WERR_CLASS_NOT_REGISTERED },
     310        { "WERR_PRINT_PROCESSOR_ALREADY_INSTALLED", WERR_PRINT_PROCESSOR_ALREADY_INSTALLED },
    312311        /*****************************************************************************
    313312         Auto-generated Win32 error from:
     
    27072706        { WERR_INVALID_PARAM, "Invalid parameter" },
    27082707        { WERR_NOT_SUPPORTED, "Not supported" },
    2709         { WERR_BAD_PASSWORD, "A bad password was supplied" },
    27102708        { WERR_NOMEM, "Out of memory" },
    27112709        { WERR_NO_LOGON_SERVERS, "No logon servers found" },
  • vendor/current/libcli/util/error.h

    r740 r988  
    2323#include "libcli/util/doserr.h"
    2424#include "libcli/util/ntstatus.h"
    25 
    26 /** NT error on DOS connection! (NT_STATUS_OK) */
    27 bool ntstatus_dos_equal(NTSTATUS status1, NTSTATUS status2);
     25#include "libcli/util/hresult.h"
    2826
    2927/*****************************************************************************
     
    4543 Map an NT error code from a Unix error code.
    4644*********************************************************************/
    47 NTSTATUS map_nt_error_from_unix(int unix_error);
    48 
    49 /*********************************************************************
    50 convert a Unix error code to a WERROR
    51 *********************************************************************/
    52 WERROR unix_to_werror(int unix_error);
     45NTSTATUS map_nt_error_from_unix_common(int unix_error);
    5346
    5447NTSTATUS nt_status_squash(NTSTATUS nt_status);
    5548
     49/*****************************************************************************
     50convert a Unix error to a WERROR
     51 *****************************************************************************/
     52WERROR unix_to_werror(int unix_error);
     53
    5654#endif /* _SAMBA_ERROR_H */
  • vendor/current/libcli/util/ntstatus.h

    r740 r988  
    4949#define STATUS_INVALID_EA_FLAG            NT_STATUS(0x80000015)
    5050#define NT_STATUS_NO_MORE_ENTRIES         NT_STATUS(0x8000001a)
     51#define STATUS_STOPPED_ON_SYMLINK         NT_STATUS(0x8000002d)
    5152
    5253#define STATUS_PENDING                    NT_STATUS(0x0103)
     
    598599#define NT_STATUS_DS_NO_MORE_RIDS NT_STATUS(0xC0000000 | 0x02A8)
    599600#define NT_STATUS_NOT_A_REPARSE_POINT NT_STATUS(0xC0000000 | 0x0275)
     601#define NT_STATUS_IO_REPARSE_DATA_INVALID NT_STATUS(0xC0000000 | 0x0278)
     602#define NT_STATUS_IO_REPARSE_TAG_NOT_HANDLED NT_STATUS(0xC0000000 | 0x0279)
    600603#define NT_STATUS_CURRENT_DOMAIN_NOT_ALLOWED NT_STATUS(0xC0000000 | 0x02E9)
    601604#define NT_STATUS_OBJECTID_NOT_FOUND NT_STATUS(0xC0000000 | 0x02F0)
    602605#define NT_STATUS_NO_SUCH_JOB NT_STATUS(0xC0000000 | 0xEDE) /* scheduler */
     606#define NT_STATUS_NETWORK_SESSION_EXPIRED NT_STATUS(0xC0000000 | 0x035C)
     607#define NT_STATUS_ALL_SIDS_FILTERED NT_STATUS(0xC0000000 | 0x035E)
    603608#define NT_STATUS_DOWNGRADE_DETECTED NT_STATUS(0xC0000000 | 0x0388)
    604609#define NT_STATUS_NO_S4U_PROT_SUPPORT NT_STATUS(0xC0000000 | 0x040A)
    605610#define NT_STATUS_CROSSREALM_DELEGATION_FAILURE NT_STATUS(0xC0000000 | 0x040B)
    606 #define NT_STATUS_NO_SUCH_JOB NT_STATUS(0xC0000000 | 0xEDE) /* scheduler */
     611#define NT_STATUS_FILE_NOT_AVAILABLE NT_STATUS(0xC0000000 | 0x0467)
    607612#define NT_STATUS_RPC_PROTSEQ_NOT_SUPPORTED NT_STATUS(0xC0000000 | 0x20004)
    608613#define NT_STATUS_RPC_UNSUPPORTED_NAME_SYNTAX NT_STATUS(0xC0000000 | 0x20026)
     
    614619#define NT_STATUS_RPC_SEC_PKG_ERROR NT_STATUS(0xC0000000 | 0x20057)
    615620#define NT_STATUS_RPC_SS_CONTEXT_MISMATCH NT_STATUS(0xC0000000 | 0x30005)
    616 #define NT_STATUS_RPC_ENUM_VALUE_OUT_OF_RANGE NT_STATUS(0xC000000 | 0x3000A)
     621#define NT_STATUS_RPC_ENUM_VALUE_OUT_OF_RANGE NT_STATUS(0xC0000000 | 0x3000A)
    617622#define NT_STATUS_RPC_BAD_STUB_DATA NT_STATUS(0xC0000000 | 0x3000C)
    618623#define NT_STATUS_RPC_INVALID_PIPE_OBJECT NT_STATUS(0xC0000000 | 0x3005C)
     
    625630#define NT_STATUS_ERROR_DS_INCOMPATIBLE_VERSION NT_STATUS(0xC0000000 | 0x00002177)
    626631
     632/*
     633 * New descriptions for new errors generated from
     634 * [MS-ERREF] http://msdn.microsoft.com/en-us/library/cc704588.aspx
     635 */
     636
     637#define NT_STATUS_WAIT_1                                  NT_STATUS(0x00000001)
     638#define NT_STATUS_WAIT_2                                  NT_STATUS(0x00000002)
     639#define NT_STATUS_WAIT_3                                  NT_STATUS(0x00000003)
     640#define NT_STATUS_WAIT_63                                 NT_STATUS(0x0000003F)
     641#define NT_STATUS_ABANDONED                               NT_STATUS(0x00000080)
     642#define NT_STATUS_ABANDONED_WAIT_0                        NT_STATUS(0x00000080)
     643#define NT_STATUS_ABANDONED_WAIT_63                       NT_STATUS(0x000000BF)
     644#define NT_STATUS_USER_APC                                NT_STATUS(0x000000C0)
     645#define NT_STATUS_ALERTED                                 NT_STATUS(0x00000101)
     646#define NT_STATUS_TIMEOUT                                 NT_STATUS(0x00000102)
     647#define NT_STATUS_REPARSE                                 NT_STATUS(0x00000104)
     648#define NT_STATUS_NOT_ALL_ASSIGNED                        NT_STATUS(0x00000106)
     649#define NT_STATUS_OPLOCK_BREAK_IN_PROGRESS                NT_STATUS(0x00000108)
     650#define NT_STATUS_VOLUME_MOUNTED                          NT_STATUS(0x00000109)
     651#define NT_STATUS_RXACT_COMMITTED                         NT_STATUS(0x0000010A)
     652#define NT_STATUS_NO_QUOTAS_FOR_ACCOUNT                   NT_STATUS(0x0000010D)
     653#define NT_STATUS_PRIMARY_TRANSPORT_CONNECT_FAILED        NT_STATUS(0x0000010E)
     654#define NT_STATUS_PAGE_FAULT_TRANSITION                   NT_STATUS(0x00000110)
     655#define NT_STATUS_PAGE_FAULT_DEMAND_ZERO                  NT_STATUS(0x00000111)
     656#define NT_STATUS_PAGE_FAULT_COPY_ON_WRITE                NT_STATUS(0x00000112)
     657#define NT_STATUS_PAGE_FAULT_GUARD_PAGE                   NT_STATUS(0x00000113)
     658#define NT_STATUS_PAGE_FAULT_PAGING_FILE                  NT_STATUS(0x00000114)
     659#define NT_STATUS_CACHE_PAGE_LOCKED                       NT_STATUS(0x00000115)
     660#define NT_STATUS_CRASH_DUMP                              NT_STATUS(0x00000116)
     661#define NT_STATUS_BUFFER_ALL_ZEROS                        NT_STATUS(0x00000117)
     662#define NT_STATUS_REPARSE_OBJECT                          NT_STATUS(0x00000118)
     663#define NT_STATUS_RESOURCE_REQUIREMENTS_CHANGED           NT_STATUS(0x00000119)
     664#define NT_STATUS_TRANSLATION_COMPLETE                    NT_STATUS(0x00000120)
     665#define NT_STATUS_DS_MEMBERSHIP_EVALUATED_LOCALLY         NT_STATUS(0x00000121)
     666#define NT_STATUS_NOTHING_TO_TERMINATE                    NT_STATUS(0x00000122)
     667#define NT_STATUS_PROCESS_NOT_IN_JOB                      NT_STATUS(0x00000123)
     668#define NT_STATUS_PROCESS_IN_JOB                          NT_STATUS(0x00000124)
     669#define NT_STATUS_VOLSNAP_HIBERNATE_READY                 NT_STATUS(0x00000125)
     670#define NT_STATUS_FSFILTER_OP_COMPLETED_SUCCESSFULLY      NT_STATUS(0x00000126)
     671#define NT_STATUS_INTERRUPT_VECTOR_ALREADY_CONNECTED      NT_STATUS(0x00000127)
     672#define NT_STATUS_INTERRUPT_STILL_CONNECTED               NT_STATUS(0x00000128)
     673#define NT_STATUS_PROCESS_CLONED                          NT_STATUS(0x00000129)
     674#define NT_STATUS_FILE_LOCKED_WITH_ONLY_READERS           NT_STATUS(0x0000012A)
     675#define NT_STATUS_FILE_LOCKED_WITH_WRITERS                NT_STATUS(0x0000012B)
     676#define NT_STATUS_RESOURCEMANAGER_READ_ONLY               NT_STATUS(0x00000202)
     677#define NT_STATUS_WAIT_FOR_OPLOCK                         NT_STATUS(0x00000367)
     678#define NT_STATUS_DBG_EXCEPTION_HANDLED                   NT_STATUS(0x00010001)
     679#define NT_STATUS_DBG_CONTINUE                            NT_STATUS(0x00010002)
     680#define NT_STATUS_FLT_IO_COMPLETE                         NT_STATUS(0x001C0001)
     681#define NT_STATUS_CALLBACK_RETURNED_THREAD_AFFINITY       NT_STATUS(0xC0000721)
     682#define NT_STATUS_OBJECT_NAME_EXISTS                      NT_STATUS(0x40000000)
     683#define NT_STATUS_THREAD_WAS_SUSPENDED                    NT_STATUS(0x40000001)
     684#define NT_STATUS_WORKING_SET_LIMIT_RANGE                 NT_STATUS(0x40000002)
     685#define NT_STATUS_IMAGE_NOT_AT_BASE                       NT_STATUS(0x40000003)
     686#define NT_STATUS_RXACT_STATE_CREATED                     NT_STATUS(0x40000004)
     687#define NT_STATUS_SEGMENT_NOTIFICATION                    NT_STATUS(0x40000005)
     688#define NT_STATUS_LOCAL_USER_SESSION_KEY                  NT_STATUS(0x40000006)
     689#define NT_STATUS_BAD_CURRENT_DIRECTORY                   NT_STATUS(0x40000007)
     690#define NT_STATUS_SERIAL_MORE_WRITES                      NT_STATUS(0x40000008)
     691#define NT_STATUS_REGISTRY_RECOVERED                      NT_STATUS(0x40000009)
     692#define NT_STATUS_FT_READ_RECOVERY_FROM_BACKUP            NT_STATUS(0x4000000A)
     693#define NT_STATUS_FT_WRITE_RECOVERY                       NT_STATUS(0x4000000B)
     694#define NT_STATUS_SERIAL_COUNTER_TIMEOUT                  NT_STATUS(0x4000000C)
     695#define NT_STATUS_NULL_LM_PASSWORD                        NT_STATUS(0x4000000D)
     696#define NT_STATUS_IMAGE_MACHINE_TYPE_MISMATCH             NT_STATUS(0x4000000E)
     697#define NT_STATUS_RECEIVE_PARTIAL                         NT_STATUS(0x4000000F)
     698#define NT_STATUS_RECEIVE_EXPEDITED                       NT_STATUS(0x40000010)
     699#define NT_STATUS_RECEIVE_PARTIAL_EXPEDITED               NT_STATUS(0x40000011)
     700#define NT_STATUS_EVENT_DONE                              NT_STATUS(0x40000012)
     701#define NT_STATUS_EVENT_PENDING                           NT_STATUS(0x40000013)
     702#define NT_STATUS_CHECKING_FILE_SYSTEM                    NT_STATUS(0x40000014)
     703#define NT_STATUS_FATAL_APP_EXIT                          NT_STATUS(0x40000015)
     704#define NT_STATUS_PREDEFINED_HANDLE                       NT_STATUS(0x40000016)
     705#define NT_STATUS_WAS_UNLOCKED                            NT_STATUS(0x40000017)
     706#define NT_STATUS_SERVICE_NOTIFICATION                    NT_STATUS(0x40000018)
     707#define NT_STATUS_WAS_LOCKED                              NT_STATUS(0x40000019)
     708#define NT_STATUS_LOG_HARD_ERROR                          NT_STATUS(0x4000001A)
     709#define NT_STATUS_ALREADY_WIN32                           NT_STATUS(0x4000001B)
     710#define NT_STATUS_WX86_UNSIMULATE                         NT_STATUS(0x4000001C)
     711#define NT_STATUS_WX86_CONTINUE                           NT_STATUS(0x4000001D)
     712#define NT_STATUS_WX86_SINGLE_STEP                        NT_STATUS(0x4000001E)
     713#define NT_STATUS_WX86_BREAKPOINT                         NT_STATUS(0x4000001F)
     714#define NT_STATUS_WX86_EXCEPTION_CONTINUE                 NT_STATUS(0x40000020)
     715#define NT_STATUS_WX86_EXCEPTION_LASTCHANCE               NT_STATUS(0x40000021)
     716#define NT_STATUS_WX86_EXCEPTION_CHAIN                    NT_STATUS(0x40000022)
     717#define NT_STATUS_IMAGE_MACHINE_TYPE_MISMATCH_EXE         NT_STATUS(0x40000023)
     718#define NT_STATUS_NO_YIELD_PERFORMED                      NT_STATUS(0x40000024)
     719#define NT_STATUS_TIMER_RESUME_IGNORED                    NT_STATUS(0x40000025)
     720#define NT_STATUS_ARBITRATION_UNHANDLED                   NT_STATUS(0x40000026)
     721#define NT_STATUS_CARDBUS_NOT_SUPPORTED                   NT_STATUS(0x40000027)
     722#define NT_STATUS_WX86_CREATEWX86TIB                      NT_STATUS(0x40000028)
     723#define NT_STATUS_MP_PROCESSOR_MISMATCH                   NT_STATUS(0x40000029)
     724#define NT_STATUS_HIBERNATED                              NT_STATUS(0x4000002A)
     725#define NT_STATUS_RESUME_HIBERNATION                      NT_STATUS(0x4000002B)
     726#define NT_STATUS_FIRMWARE_UPDATED                        NT_STATUS(0x4000002C)
     727#define NT_STATUS_DRIVERS_LEAKING_LOCKED_PAGES            NT_STATUS(0x4000002D)
     728#define NT_STATUS_MESSAGE_RETRIEVED                       NT_STATUS(0x4000002E)
     729#define NT_STATUS_SYSTEM_POWERSTATE_TRANSITION            NT_STATUS(0x4000002F)
     730#define NT_STATUS_ALPC_CHECK_COMPLETION_LIST              NT_STATUS(0x40000030)
     731#define NT_STATUS_SYSTEM_POWERSTATE_COMPLEX_TRANSITION    NT_STATUS(0x40000031)
     732#define NT_STATUS_ACCESS_AUDIT_BY_POLICY                  NT_STATUS(0x40000032)
     733#define NT_STATUS_ABANDON_HIBERFILE                       NT_STATUS(0x40000033)
     734#define NT_STATUS_BIZRULES_NOT_ENABLED                    NT_STATUS(0x40000034)
     735#define NT_STATUS_WAKE_SYSTEM                             NT_STATUS(0x40000294)
     736#define NT_STATUS_DS_SHUTTING_DOWN                        NT_STATUS(0x40000370)
     737#define NT_STATUS_DBG_REPLY_LATER                         NT_STATUS(0x40010001)
     738#define NT_STATUS_DBG_UNABLE_TO_PROVIDE_HANDLE            NT_STATUS(0x40010002)
     739#define NT_STATUS_DBG_TERMINATE_THREAD                    NT_STATUS(0x40010003)
     740#define NT_STATUS_DBG_TERMINATE_PROCESS                   NT_STATUS(0x40010004)
     741#define NT_STATUS_DBG_CONTROL_C                           NT_STATUS(0x40010005)
     742#define NT_STATUS_DBG_PRINTEXCEPTION_C                    NT_STATUS(0x40010006)
     743#define NT_STATUS_DBG_RIPEXCEPTION                        NT_STATUS(0x40010007)
     744#define NT_STATUS_DBG_CONTROL_BREAK                       NT_STATUS(0x40010008)
     745#define NT_STATUS_DBG_COMMAND_EXCEPTION                   NT_STATUS(0x40010009)
     746#define NT_STATUS_RPC_UUID_LOCAL_ONLY                     NT_STATUS(0x40020056)
     747#define NT_STATUS_RPC_SEND_INCOMPLETE                     NT_STATUS(0x400200AF)
     748#define NT_STATUS_CTX_CDM_CONNECT                         NT_STATUS(0x400A0004)
     749#define NT_STATUS_CTX_CDM_DISCONNECT                      NT_STATUS(0x400A0005)
     750#define NT_STATUS_SXS_RELEASE_ACTIVATION_CONTEXT          NT_STATUS(0x4015000D)
     751#define NT_STATUS_RECOVERY_NOT_NEEDED                     NT_STATUS(0x40190034)
     752#define NT_STATUS_RM_ALREADY_STARTED                      NT_STATUS(0x40190035)
     753#define NT_STATUS_LOG_NO_RESTART                          NT_STATUS(0x401A000C)
     754#define NT_STATUS_VIDEO_DRIVER_DEBUG_REPORT_REQUEST       NT_STATUS(0x401B00EC)
     755#define NT_STATUS_GRAPHICS_PARTIAL_DATA_POPULATED         NT_STATUS(0x401E000A)
     756#define NT_STATUS_GRAPHICS_DRIVER_MISMATCH                NT_STATUS(0x401E0117)
     757#define NT_STATUS_GRAPHICS_MODE_NOT_PINNED                NT_STATUS(0x401E0307)
     758#define NT_STATUS_GRAPHICS_NO_PREFERRED_MODE              NT_STATUS(0x401E031E)
     759#define NT_STATUS_GRAPHICS_DATASET_IS_EMPTY               NT_STATUS(0x401E034B)
     760#define NT_STATUS_GRAPHICS_NO_MORE_ELEMENTS_IN_DATASET    NT_STATUS(0x401E034C)
     761#define NT_STATUS_GRAPHICS_PATH_CONTENT_GEOMETRY_TRANSFORMATION_NOT_PINNED NT_STATUS(0x401E0351)
     762#define NT_STATUS_GRAPHICS_UNKNOWN_CHILD_STATUS           NT_STATUS(0x401E042F)
     763#define NT_STATUS_GRAPHICS_LEADLINK_START_DEFERRED        NT_STATUS(0x401E0437)
     764#define NT_STATUS_GRAPHICS_POLLING_TOO_FREQUENTLY         NT_STATUS(0x401E0439)
     765#define NT_STATUS_GRAPHICS_START_DEFERRED                 NT_STATUS(0x401E043A)
     766#define NT_STATUS_NDIS_INDICATION_REQUIRED                NT_STATUS(0x40230001)
     767#define NT_STATUS_GUARD_PAGE_VIOLATION                    NT_STATUS(0x80000001)
     768#define NT_STATUS_DATATYPE_MISALIGNMENT                   NT_STATUS(0x80000002)
     769#define NT_STATUS_BREAKPOINT                              NT_STATUS(0x80000003)
     770#define NT_STATUS_SINGLE_STEP                             NT_STATUS(0x80000004)
     771#define NT_STATUS_WAKE_SYSTEM_DEBUGGER                    NT_STATUS(0x80000007)
     772#define NT_STATUS_HANDLES_CLOSED                          NT_STATUS(0x8000000A)
     773#define NT_STATUS_NO_INHERITANCE                          NT_STATUS(0x8000000B)
     774#define NT_STATUS_GUID_SUBSTITUTION_MADE                  NT_STATUS(0x8000000C)
     775#define NT_STATUS_PARTIAL_COPY                            NT_STATUS(0x8000000D)
     776#define NT_STATUS_DEVICE_PAPER_EMPTY                      NT_STATUS(0x8000000E)
     777#define NT_STATUS_DEVICE_POWERED_OFF                      NT_STATUS(0x8000000F)
     778#define NT_STATUS_DEVICE_OFF_LINE                         NT_STATUS(0x80000010)
     779#define NT_STATUS_DEVICE_BUSY                             NT_STATUS(0x80000011)
     780#define NT_STATUS_VERIFY_REQUIRED                         NT_STATUS(0x80000016)
     781#define NT_STATUS_EXTRANEOUS_INFORMATION                  NT_STATUS(0x80000017)
     782#define NT_STATUS_RXACT_COMMIT_NECESSARY                  NT_STATUS(0x80000018)
     783#define NT_STATUS_FILEMARK_DETECTED                       NT_STATUS(0x8000001B)
     784#define NT_STATUS_MEDIA_CHANGED                           NT_STATUS(0x8000001C)
     785#define NT_STATUS_BUS_RESET                               NT_STATUS(0x8000001D)
     786#define NT_STATUS_END_OF_MEDIA                            NT_STATUS(0x8000001E)
     787#define NT_STATUS_BEGINNING_OF_MEDIA                      NT_STATUS(0x8000001F)
     788#define NT_STATUS_MEDIA_CHECK                             NT_STATUS(0x80000020)
     789#define NT_STATUS_SETMARK_DETECTED                        NT_STATUS(0x80000021)
     790#define NT_STATUS_NO_DATA_DETECTED                        NT_STATUS(0x80000022)
     791#define NT_STATUS_REDIRECTOR_HAS_OPEN_HANDLES             NT_STATUS(0x80000023)
     792#define NT_STATUS_SERVER_HAS_OPEN_HANDLES                 NT_STATUS(0x80000024)
     793#define NT_STATUS_ALREADY_DISCONNECTED                    NT_STATUS(0x80000025)
     794#define NT_STATUS_LONGJUMP                                NT_STATUS(0x80000026)
     795#define NT_STATUS_CLEANER_CARTRIDGE_INSTALLED             NT_STATUS(0x80000027)
     796#define NT_STATUS_PLUGPLAY_QUERY_VETOED                   NT_STATUS(0x80000028)
     797#define NT_STATUS_UNWIND_CONSOLIDATE                      NT_STATUS(0x80000029)
     798#define NT_STATUS_REGISTRY_HIVE_RECOVERED                 NT_STATUS(0x8000002A)
     799#define NT_STATUS_DLL_MIGHT_BE_INSECURE                   NT_STATUS(0x8000002B)
     800#define NT_STATUS_DLL_MIGHT_BE_INCOMPATIBLE               NT_STATUS(0x8000002C)
     801#define NT_STATUS_DEVICE_REQUIRES_CLEANING                NT_STATUS(0x80000288)
     802#define NT_STATUS_DEVICE_DOOR_OPEN                        NT_STATUS(0x80000289)
     803#define NT_STATUS_DATA_LOST_REPAIR                        NT_STATUS(0x80000803)
     804#define NT_STATUS_DBG_EXCEPTION_NOT_HANDLED               NT_STATUS(0x80010001)
     805#define NT_STATUS_CLUSTER_NODE_ALREADY_UP                 NT_STATUS(0x80130001)
     806#define NT_STATUS_CLUSTER_NODE_ALREADY_DOWN               NT_STATUS(0x80130002)
     807#define NT_STATUS_CLUSTER_NETWORK_ALREADY_ONLINE          NT_STATUS(0x80130003)
     808#define NT_STATUS_CLUSTER_NETWORK_ALREADY_OFFLINE         NT_STATUS(0x80130004)
     809#define NT_STATUS_CLUSTER_NODE_ALREADY_MEMBER             NT_STATUS(0x80130005)
     810#define NT_STATUS_COULD_NOT_RESIZE_LOG                    NT_STATUS(0x80190009)
     811#define NT_STATUS_NO_TXF_METADATA                         NT_STATUS(0x80190029)
     812#define NT_STATUS_CANT_RECOVER_WITH_HANDLE_OPEN           NT_STATUS(0x80190031)
     813#define NT_STATUS_TXF_METADATA_ALREADY_PRESENT            NT_STATUS(0x80190041)
     814#define NT_STATUS_TRANSACTION_SCOPE_CALLBACKS_NOT_SET     NT_STATUS(0x80190042)
     815#define NT_STATUS_VIDEO_HUNG_DISPLAY_DRIVER_THREAD_RECOVERED NT_STATUS(0x801B00EB)
     816#define NT_STATUS_FLT_BUFFER_TOO_SMALL                    NT_STATUS(0x801C0001)
     817#define NT_STATUS_FVE_PARTIAL_METADATA                    NT_STATUS(0x80210001)
     818#define NT_STATUS_FVE_TRANSIENT_STATE                     NT_STATUS(0x80210002)
     819#define NT_STATUS_VARIABLE_NOT_FOUND                      NT_STATUS(0xC0000100)
     820#define NT_STATUS_BIOS_FAILED_TO_CONNECT_INTERRUPT        NT_STATUS(0xC000016E)
     821#define NT_STATUS_IMAGE_ALREADY_LOADED_AS_DLL             NT_STATUS(0xC000019D)
     822#define NT_STATUS_INCOMPATIBLE_WITH_GLOBAL_SHORT_NAME_REGISTRY_SETTING NT_STATUS(0xC000019E)
     823#define NT_STATUS_SHORT_NAMES_NOT_ENABLED_ON_VOLUME       NT_STATUS(0xC000019F)
     824#define NT_STATUS_SECURITY_STREAM_IS_INCONSISTENT         NT_STATUS(0xC00001A0)
     825#define NT_STATUS_INVALID_ACE_CONDITION                   NT_STATUS(0xC00001A2)
     826#define NT_STATUS_IMAGE_SUBSYSTEM_NOT_PRESENT             NT_STATUS(0xC00001A3)
     827#define NT_STATUS_NOTIFICATION_GUID_ALREADY_DEFINED       NT_STATUS(0xC00001A4)
     828#define NT_STATUS_NETWORK_OPEN_RESTRICTION                NT_STATUS(0xC0000201)
     829#define NT_STATUS_EVALUATION_EXPIRATION                   NT_STATUS(0xC0000268)
     830#define NT_STATUS_ILLEGAL_DLL_RELOCATION                  NT_STATUS(0xC0000269)
     831#define NT_STATUS_LICENSE_VIOLATION                       NT_STATUS(0xC000026A)
     832#define NT_STATUS_DLL_INIT_FAILED_LOGOFF                  NT_STATUS(0xC000026B)
     833#define NT_STATUS_DRIVER_UNABLE_TO_LOAD                   NT_STATUS(0xC000026C)
     834#define NT_STATUS_DFS_UNAVAILABLE                         NT_STATUS(0xC000026D)
     835#define NT_STATUS_VOLUME_DISMOUNTED                       NT_STATUS(0xC000026E)
     836#define NT_STATUS_WX86_INTERNAL_ERROR                     NT_STATUS(0xC000026F)
     837#define NT_STATUS_WX86_FLOAT_STACK_CHECK                  NT_STATUS(0xC0000270)
     838#define NT_STATUS_VALIDATE_CONTINUE                       NT_STATUS(0xC0000271)
     839#define NT_STATUS_NO_MATCH                                NT_STATUS(0xC0000272)
     840#define NT_STATUS_NO_MORE_MATCHES                         NT_STATUS(0xC0000273)
     841#define NT_STATUS_IO_REPARSE_TAG_INVALID                  NT_STATUS(0xC0000276)
     842#define NT_STATUS_IO_REPARSE_TAG_MISMATCH                 NT_STATUS(0xC0000277)
     843#define NT_STATUS_REPARSE_POINT_NOT_RESOLVED              NT_STATUS(0xC0000280)
     844#define NT_STATUS_DIRECTORY_IS_A_REPARSE_POINT            NT_STATUS(0xC0000281)
     845#define NT_STATUS_RANGE_LIST_CONFLICT                     NT_STATUS(0xC0000282)
     846#define NT_STATUS_SOURCE_ELEMENT_EMPTY                    NT_STATUS(0xC0000283)
     847#define NT_STATUS_DESTINATION_ELEMENT_FULL                NT_STATUS(0xC0000284)
     848#define NT_STATUS_ILLEGAL_ELEMENT_ADDRESS                 NT_STATUS(0xC0000285)
     849#define NT_STATUS_MAGAZINE_NOT_PRESENT                    NT_STATUS(0xC0000286)
     850#define NT_STATUS_REINITIALIZATION_NEEDED                 NT_STATUS(0xC0000287)
     851#define NT_STATUS_ENCRYPTION_FAILED                       NT_STATUS(0xC000028A)
     852#define NT_STATUS_DECRYPTION_FAILED                       NT_STATUS(0xC000028B)
     853#define NT_STATUS_RANGE_NOT_FOUND                         NT_STATUS(0xC000028C)
     854#define NT_STATUS_NO_RECOVERY_POLICY                      NT_STATUS(0xC000028D)
     855#define NT_STATUS_NO_EFS                                  NT_STATUS(0xC000028E)
     856#define NT_STATUS_WRONG_EFS                               NT_STATUS(0xC000028F)
     857#define NT_STATUS_NO_USER_KEYS                            NT_STATUS(0xC0000290)
     858#define NT_STATUS_FILE_NOT_ENCRYPTED                      NT_STATUS(0xC0000291)
     859#define NT_STATUS_NOT_EXPORT_FORMAT                       NT_STATUS(0xC0000292)
     860#define NT_STATUS_FILE_ENCRYPTED                          NT_STATUS(0xC0000293)
     861#define NT_STATUS_WMI_GUID_NOT_FOUND                      NT_STATUS(0xC0000295)
     862#define NT_STATUS_WMI_INSTANCE_NOT_FOUND                  NT_STATUS(0xC0000296)
     863#define NT_STATUS_WMI_ITEMID_NOT_FOUND                    NT_STATUS(0xC0000297)
     864#define NT_STATUS_WMI_TRY_AGAIN                           NT_STATUS(0xC0000298)
     865#define NT_STATUS_SHARED_POLICY                           NT_STATUS(0xC0000299)
     866#define NT_STATUS_POLICY_OBJECT_NOT_FOUND                 NT_STATUS(0xC000029A)
     867#define NT_STATUS_POLICY_ONLY_IN_DS                       NT_STATUS(0xC000029B)
     868#define NT_STATUS_VOLUME_NOT_UPGRADED                     NT_STATUS(0xC000029C)
     869#define NT_STATUS_REMOTE_STORAGE_NOT_ACTIVE               NT_STATUS(0xC000029D)
     870#define NT_STATUS_REMOTE_STORAGE_MEDIA_ERROR              NT_STATUS(0xC000029E)
     871#define NT_STATUS_NO_TRACKING_SERVICE                     NT_STATUS(0xC000029F)
     872#define NT_STATUS_SERVER_SID_MISMATCH                     NT_STATUS(0xC00002A0)
     873#define NT_STATUS_DS_NO_ATTRIBUTE_OR_VALUE                NT_STATUS(0xC00002A1)
     874#define NT_STATUS_DS_INVALID_ATTRIBUTE_SYNTAX             NT_STATUS(0xC00002A2)
     875#define NT_STATUS_DS_ATTRIBUTE_TYPE_UNDEFINED             NT_STATUS(0xC00002A3)
     876#define NT_STATUS_DS_ATTRIBUTE_OR_VALUE_EXISTS            NT_STATUS(0xC00002A4)
     877#define NT_STATUS_DS_BUSY                                 NT_STATUS(0xC00002A5)
     878#define NT_STATUS_DS_UNAVAILABLE                          NT_STATUS(0xC00002A6)
     879#define NT_STATUS_DS_NO_RIDS_ALLOCATED                    NT_STATUS(0xC00002A7)
     880#define NT_STATUS_DS_INCORRECT_ROLE_OWNER                 NT_STATUS(0xC00002A9)
     881#define NT_STATUS_DS_RIDMGR_INIT_ERROR                    NT_STATUS(0xC00002AA)
     882#define NT_STATUS_DS_OBJ_CLASS_VIOLATION                  NT_STATUS(0xC00002AB)
     883#define NT_STATUS_DS_CANT_ON_NON_LEAF                     NT_STATUS(0xC00002AC)
     884#define NT_STATUS_DS_CANT_ON_RDN                          NT_STATUS(0xC00002AD)
     885#define NT_STATUS_DS_CANT_MOD_OBJ_CLASS                   NT_STATUS(0xC00002AE)
     886#define NT_STATUS_DS_CROSS_DOM_MOVE_FAILED                NT_STATUS(0xC00002AF)
     887#define NT_STATUS_DS_GC_NOT_AVAILABLE                     NT_STATUS(0xC00002B0)
     888#define NT_STATUS_DIRECTORY_SERVICE_REQUIRED              NT_STATUS(0xC00002B1)
     889#define NT_STATUS_REPARSE_ATTRIBUTE_CONFLICT              NT_STATUS(0xC00002B2)
     890#define NT_STATUS_CANT_ENABLE_DENY_ONLY                   NT_STATUS(0xC00002B3)
     891#define NT_STATUS_FLOAT_MULTIPLE_FAULTS                   NT_STATUS(0xC00002B4)
     892#define NT_STATUS_FLOAT_MULTIPLE_TRAPS                    NT_STATUS(0xC00002B5)
     893#define NT_STATUS_DEVICE_REMOVED                          NT_STATUS(0xC00002B6)
     894#define NT_STATUS_JOURNAL_DELETE_IN_PROGRESS              NT_STATUS(0xC00002B7)
     895#define NT_STATUS_JOURNAL_NOT_ACTIVE                      NT_STATUS(0xC00002B8)
     896#define NT_STATUS_NOINTERFACE                             NT_STATUS(0xC00002B9)
     897#define NT_STATUS_DS_ADMIN_LIMIT_EXCEEDED                 NT_STATUS(0xC00002C1)
     898#define NT_STATUS_DRIVER_FAILED_SLEEP                     NT_STATUS(0xC00002C2)
     899#define NT_STATUS_MUTUAL_AUTHENTICATION_FAILED            NT_STATUS(0xC00002C3)
     900#define NT_STATUS_CORRUPT_SYSTEM_FILE                     NT_STATUS(0xC00002C4)
     901#define NT_STATUS_DATATYPE_MISALIGNMENT_ERROR             NT_STATUS(0xC00002C5)
     902#define NT_STATUS_WMI_READ_ONLY                           NT_STATUS(0xC00002C6)
     903#define NT_STATUS_WMI_SET_FAILURE                         NT_STATUS(0xC00002C7)
     904#define NT_STATUS_COMMITMENT_MINIMUM                      NT_STATUS(0xC00002C8)
     905#define NT_STATUS_REG_NAT_CONSUMPTION                     NT_STATUS(0xC00002C9)
     906#define NT_STATUS_TRANSPORT_FULL                          NT_STATUS(0xC00002CA)
     907#define NT_STATUS_DS_SAM_INIT_FAILURE                     NT_STATUS(0xC00002CB)
     908#define NT_STATUS_ONLY_IF_CONNECTED                       NT_STATUS(0xC00002CC)
     909#define NT_STATUS_DS_SENSITIVE_GROUP_VIOLATION            NT_STATUS(0xC00002CD)
     910#define NT_STATUS_PNP_RESTART_ENUMERATION                 NT_STATUS(0xC00002CE)
     911#define NT_STATUS_JOURNAL_ENTRY_DELETED                   NT_STATUS(0xC00002CF)
     912#define NT_STATUS_DS_CANT_MOD_PRIMARYGROUPID              NT_STATUS(0xC00002D0)
     913#define NT_STATUS_SYSTEM_IMAGE_BAD_SIGNATURE              NT_STATUS(0xC00002D1)
     914#define NT_STATUS_PNP_REBOOT_REQUIRED                     NT_STATUS(0xC00002D2)
     915#define NT_STATUS_POWER_STATE_INVALID                     NT_STATUS(0xC00002D3)
     916#define NT_STATUS_DS_INVALID_GROUP_TYPE                   NT_STATUS(0xC00002D4)
     917#define NT_STATUS_DS_NO_NEST_GLOBALGROUP_IN_MIXEDDOMAIN   NT_STATUS(0xC00002D5)
     918#define NT_STATUS_DS_NO_NEST_LOCALGROUP_IN_MIXEDDOMAIN    NT_STATUS(0xC00002D6)
     919#define NT_STATUS_DS_GLOBAL_CANT_HAVE_LOCAL_MEMBER        NT_STATUS(0xC00002D7)
     920#define NT_STATUS_DS_GLOBAL_CANT_HAVE_UNIVERSAL_MEMBER    NT_STATUS(0xC00002D8)
     921#define NT_STATUS_DS_UNIVERSAL_CANT_HAVE_LOCAL_MEMBER     NT_STATUS(0xC00002D9)
     922#define NT_STATUS_DS_GLOBAL_CANT_HAVE_CROSSDOMAIN_MEMBER  NT_STATUS(0xC00002DA)
     923#define NT_STATUS_DS_LOCAL_CANT_HAVE_CROSSDOMAIN_LOCAL_MEMBER NT_STATUS(0xC00002DB)
     924#define NT_STATUS_DS_HAVE_PRIMARY_MEMBERS                 NT_STATUS(0xC00002DC)
     925#define NT_STATUS_WMI_NOT_SUPPORTED                       NT_STATUS(0xC00002DD)
     926#define NT_STATUS_INSUFFICIENT_POWER                      NT_STATUS(0xC00002DE)
     927#define NT_STATUS_SAM_NEED_BOOTKEY_PASSWORD               NT_STATUS(0xC00002DF)
     928#define NT_STATUS_SAM_NEED_BOOTKEY_FLOPPY                 NT_STATUS(0xC00002E0)
     929#define NT_STATUS_DS_CANT_START                           NT_STATUS(0xC00002E1)
     930#define NT_STATUS_DS_INIT_FAILURE                         NT_STATUS(0xC00002E2)
     931#define NT_STATUS_SAM_INIT_FAILURE                        NT_STATUS(0xC00002E3)
     932#define NT_STATUS_DS_GC_REQUIRED                          NT_STATUS(0xC00002E4)
     933#define NT_STATUS_DS_LOCAL_MEMBER_OF_LOCAL_ONLY           NT_STATUS(0xC00002E5)
     934#define NT_STATUS_DS_NO_FPO_IN_UNIVERSAL_GROUPS           NT_STATUS(0xC00002E6)
     935#define NT_STATUS_DS_MACHINE_ACCOUNT_QUOTA_EXCEEDED       NT_STATUS(0xC00002E7)
     936#define NT_STATUS_CANNOT_MAKE                             NT_STATUS(0xC00002EA)
     937#define NT_STATUS_SYSTEM_SHUTDOWN                         NT_STATUS(0xC00002EB)
     938#define NT_STATUS_DS_INIT_FAILURE_CONSOLE                 NT_STATUS(0xC00002EC)
     939#define NT_STATUS_DS_SAM_INIT_FAILURE_CONSOLE             NT_STATUS(0xC00002ED)
     940#define NT_STATUS_UNFINISHED_CONTEXT_DELETED              NT_STATUS(0xC00002EE)
     941#define NT_STATUS_NO_TGT_REPLY                            NT_STATUS(0xC00002EF)
     942#define NT_STATUS_NO_IP_ADDRESSES                         NT_STATUS(0xC00002F1)
     943#define NT_STATUS_WRONG_CREDENTIAL_HANDLE                 NT_STATUS(0xC00002F2)
     944#define NT_STATUS_CRYPTO_SYSTEM_INVALID                   NT_STATUS(0xC00002F3)
     945#define NT_STATUS_MAX_REFERRALS_EXCEEDED                  NT_STATUS(0xC00002F4)
     946#define NT_STATUS_MUST_BE_KDC                             NT_STATUS(0xC00002F5)
     947#define NT_STATUS_STRONG_CRYPTO_NOT_SUPPORTED             NT_STATUS(0xC00002F6)
     948#define NT_STATUS_TOO_MANY_PRINCIPALS                     NT_STATUS(0xC00002F7)
     949#define NT_STATUS_NO_PA_DATA                              NT_STATUS(0xC00002F8)
     950#define NT_STATUS_PKINIT_NAME_MISMATCH                    NT_STATUS(0xC00002F9)
     951#define NT_STATUS_SMARTCARD_LOGON_REQUIRED                NT_STATUS(0xC00002FA)
     952#define NT_STATUS_KDC_INVALID_REQUEST                     NT_STATUS(0xC00002FB)
     953#define NT_STATUS_KDC_UNABLE_TO_REFER                     NT_STATUS(0xC00002FC)
     954#define NT_STATUS_KDC_UNKNOWN_ETYPE                       NT_STATUS(0xC00002FD)
     955#define NT_STATUS_SHUTDOWN_IN_PROGRESS                    NT_STATUS(0xC00002FE)
     956#define NT_STATUS_SERVER_SHUTDOWN_IN_PROGRESS             NT_STATUS(0xC00002FF)
     957#define NT_STATUS_NOT_SUPPORTED_ON_SBS                    NT_STATUS(0xC0000300)
     958#define NT_STATUS_WMI_GUID_DISCONNECTED                   NT_STATUS(0xC0000301)
     959#define NT_STATUS_WMI_ALREADY_DISABLED                    NT_STATUS(0xC0000302)
     960#define NT_STATUS_WMI_ALREADY_ENABLED                     NT_STATUS(0xC0000303)
     961#define NT_STATUS_MFT_TOO_FRAGMENTED                      NT_STATUS(0xC0000304)
     962#define NT_STATUS_COPY_PROTECTION_FAILURE                 NT_STATUS(0xC0000305)
     963#define NT_STATUS_CSS_AUTHENTICATION_FAILURE              NT_STATUS(0xC0000306)
     964#define NT_STATUS_CSS_KEY_NOT_PRESENT                     NT_STATUS(0xC0000307)
     965#define NT_STATUS_CSS_KEY_NOT_ESTABLISHED                 NT_STATUS(0xC0000308)
     966#define NT_STATUS_CSS_SCRAMBLED_SECTOR                    NT_STATUS(0xC0000309)
     967#define NT_STATUS_CSS_REGION_MISMATCH                     NT_STATUS(0xC000030A)
     968#define NT_STATUS_CSS_RESETS_EXHAUSTED                    NT_STATUS(0xC000030B)
     969#define NT_STATUS_PKINIT_FAILURE                          NT_STATUS(0xC0000320)
     970#define NT_STATUS_SMARTCARD_SUBSYSTEM_FAILURE             NT_STATUS(0xC0000321)
     971#define NT_STATUS_NO_KERB_KEY                             NT_STATUS(0xC0000322)
     972#define NT_STATUS_HOST_DOWN                               NT_STATUS(0xC0000350)
     973#define NT_STATUS_UNSUPPORTED_PREAUTH                     NT_STATUS(0xC0000351)
     974#define NT_STATUS_EFS_ALG_BLOB_TOO_BIG                    NT_STATUS(0xC0000352)
     975#define NT_STATUS_PORT_NOT_SET                            NT_STATUS(0xC0000353)
     976#define NT_STATUS_DEBUGGER_INACTIVE                       NT_STATUS(0xC0000354)
     977#define NT_STATUS_DS_VERSION_CHECK_FAILURE                NT_STATUS(0xC0000355)
     978#define NT_STATUS_AUDITING_DISABLED                       NT_STATUS(0xC0000356)
     979#define NT_STATUS_PRENT4_MACHINE_ACCOUNT                  NT_STATUS(0xC0000357)
     980#define NT_STATUS_DS_AG_CANT_HAVE_UNIVERSAL_MEMBER        NT_STATUS(0xC0000358)
     981#define NT_STATUS_INVALID_IMAGE_WIN_32                    NT_STATUS(0xC0000359)
     982#define NT_STATUS_INVALID_IMAGE_WIN_64                    NT_STATUS(0xC000035A)
     983#define NT_STATUS_BAD_BINDINGS                            NT_STATUS(0xC000035B)
     984#define NT_STATUS_APPHELP_BLOCK                           NT_STATUS(0xC000035D)
     985#define NT_STATUS_NOT_SAFE_MODE_DRIVER                    NT_STATUS(0xC000035F)
     986#define NT_STATUS_ACCESS_DISABLED_BY_POLICY_DEFAULT       NT_STATUS(0xC0000361)
     987#define NT_STATUS_ACCESS_DISABLED_BY_POLICY_PATH          NT_STATUS(0xC0000362)
     988#define NT_STATUS_ACCESS_DISABLED_BY_POLICY_PUBLISHER     NT_STATUS(0xC0000363)
     989#define NT_STATUS_ACCESS_DISABLED_BY_POLICY_OTHER         NT_STATUS(0xC0000364)
     990#define NT_STATUS_FAILED_DRIVER_ENTRY                     NT_STATUS(0xC0000365)
     991#define NT_STATUS_DEVICE_ENUMERATION_ERROR                NT_STATUS(0xC0000366)
     992#define NT_STATUS_MOUNT_POINT_NOT_RESOLVED                NT_STATUS(0xC0000368)
     993#define NT_STATUS_INVALID_DEVICE_OBJECT_PARAMETER         NT_STATUS(0xC0000369)
     994#define NT_STATUS_MCA_OCCURED                             NT_STATUS(0xC000036A)
     995#define NT_STATUS_DRIVER_BLOCKED_CRITICAL                 NT_STATUS(0xC000036B)
     996#define NT_STATUS_DRIVER_BLOCKED                          NT_STATUS(0xC000036C)
     997#define NT_STATUS_DRIVER_DATABASE_ERROR                   NT_STATUS(0xC000036D)
     998#define NT_STATUS_SYSTEM_HIVE_TOO_LARGE                   NT_STATUS(0xC000036E)
     999#define NT_STATUS_INVALID_IMPORT_OF_NON_DLL               NT_STATUS(0xC000036F)
     1000#define NT_STATUS_NO_SECRETS                              NT_STATUS(0xC0000371)
     1001#define NT_STATUS_ACCESS_DISABLED_NO_SAFER_UI_BY_POLICY   NT_STATUS(0xC0000372)
     1002#define NT_STATUS_FAILED_STACK_SWITCH                     NT_STATUS(0xC0000373)
     1003#define NT_STATUS_HEAP_CORRUPTION                         NT_STATUS(0xC0000374)
     1004#define NT_STATUS_SMARTCARD_WRONG_PIN                     NT_STATUS(0xC0000380)
     1005#define NT_STATUS_SMARTCARD_CARD_BLOCKED                  NT_STATUS(0xC0000381)
     1006#define NT_STATUS_SMARTCARD_CARD_NOT_AUTHENTICATED        NT_STATUS(0xC0000382)
     1007#define NT_STATUS_SMARTCARD_NO_CARD                       NT_STATUS(0xC0000383)
     1008#define NT_STATUS_SMARTCARD_NO_KEY_CONTAINER              NT_STATUS(0xC0000384)
     1009#define NT_STATUS_SMARTCARD_NO_CERTIFICATE                NT_STATUS(0xC0000385)
     1010#define NT_STATUS_SMARTCARD_NO_KEYSET                     NT_STATUS(0xC0000386)
     1011#define NT_STATUS_SMARTCARD_IO_ERROR                      NT_STATUS(0xC0000387)
     1012#define NT_STATUS_SMARTCARD_CERT_REVOKED                  NT_STATUS(0xC0000389)
     1013#define NT_STATUS_ISSUING_CA_UNTRUSTED                    NT_STATUS(0xC000038A)
     1014#define NT_STATUS_REVOCATION_OFFLINE_C                    NT_STATUS(0xC000038B)
     1015#define NT_STATUS_PKINIT_CLIENT_FAILURE                   NT_STATUS(0xC000038C)
     1016#define NT_STATUS_SMARTCARD_CERT_EXPIRED                  NT_STATUS(0xC000038D)
     1017#define NT_STATUS_DRIVER_FAILED_PRIOR_UNLOAD              NT_STATUS(0xC000038E)
     1018#define NT_STATUS_SMARTCARD_SILENT_CONTEXT                NT_STATUS(0xC000038F)
     1019#define NT_STATUS_PER_USER_TRUST_QUOTA_EXCEEDED           NT_STATUS(0xC0000401)
     1020#define NT_STATUS_ALL_USER_TRUST_QUOTA_EXCEEDED           NT_STATUS(0xC0000402)
     1021#define NT_STATUS_USER_DELETE_TRUST_QUOTA_EXCEEDED        NT_STATUS(0xC0000403)
     1022#define NT_STATUS_DS_NAME_NOT_UNIQUE                      NT_STATUS(0xC0000404)
     1023#define NT_STATUS_DS_DUPLICATE_ID_FOUND                   NT_STATUS(0xC0000405)
     1024#define NT_STATUS_DS_GROUP_CONVERSION_ERROR               NT_STATUS(0xC0000406)
     1025#define NT_STATUS_VOLSNAP_PREPARE_HIBERNATE               NT_STATUS(0xC0000407)
     1026#define NT_STATUS_USER2USER_REQUIRED                      NT_STATUS(0xC0000408)
     1027#define NT_STATUS_STACK_BUFFER_OVERRUN                    NT_STATUS(0xC0000409)
     1028#define NT_STATUS_REVOCATION_OFFLINE_KDC                  NT_STATUS(0xC000040C)
     1029#define NT_STATUS_ISSUING_CA_UNTRUSTED_KDC                NT_STATUS(0xC000040D)
     1030#define NT_STATUS_KDC_CERT_EXPIRED                        NT_STATUS(0xC000040E)
     1031#define NT_STATUS_KDC_CERT_REVOKED                        NT_STATUS(0xC000040F)
     1032#define NT_STATUS_PARAMETER_QUOTA_EXCEEDED                NT_STATUS(0xC0000410)
     1033#define NT_STATUS_HIBERNATION_FAILURE                     NT_STATUS(0xC0000411)
     1034#define NT_STATUS_DELAY_LOAD_FAILED                       NT_STATUS(0xC0000412)
     1035#define NT_STATUS_AUTHENTICATION_FIREWALL_FAILED          NT_STATUS(0xC0000413)
     1036#define NT_STATUS_VDM_DISALLOWED                          NT_STATUS(0xC0000414)
     1037#define NT_STATUS_HUNG_DISPLAY_DRIVER_THREAD              NT_STATUS(0xC0000415)
     1038#define NT_STATUS_INSUFFICIENT_RESOURCE_FOR_SPECIFIED_SHARED_SECTION_SIZE NT_STATUS(0xC0000416)
     1039#define NT_STATUS_INVALID_CRUNTIME_PARAMETER              NT_STATUS(0xC0000417)
     1040#define NT_STATUS_NTLM_BLOCKED                            NT_STATUS(0xC0000418)
     1041#define NT_STATUS_DS_SRC_SID_EXISTS_IN_FOREST             NT_STATUS(0xC0000419)
     1042#define NT_STATUS_DS_DOMAIN_NAME_EXISTS_IN_FOREST         NT_STATUS(0xC000041A)
     1043#define NT_STATUS_DS_FLAT_NAME_EXISTS_IN_FOREST           NT_STATUS(0xC000041B)
     1044#define NT_STATUS_INVALID_USER_PRINCIPAL_NAME             NT_STATUS(0xC000041C)
     1045#define NT_STATUS_ASSERTION_FAILURE                       NT_STATUS(0xC0000420)
     1046#define NT_STATUS_VERIFIER_STOP                           NT_STATUS(0xC0000421)
     1047#define NT_STATUS_CALLBACK_POP_STACK                      NT_STATUS(0xC0000423)
     1048#define NT_STATUS_INCOMPATIBLE_DRIVER_BLOCKED             NT_STATUS(0xC0000424)
     1049#define NT_STATUS_HIVE_UNLOADED                           NT_STATUS(0xC0000425)
     1050#define NT_STATUS_COMPRESSION_DISABLED                    NT_STATUS(0xC0000426)
     1051#define NT_STATUS_FILE_SYSTEM_LIMITATION                  NT_STATUS(0xC0000427)
     1052#define NT_STATUS_INVALID_IMAGE_HASH                      NT_STATUS(0xC0000428)
     1053#define NT_STATUS_NOT_CAPABLE                             NT_STATUS(0xC0000429)
     1054#define NT_STATUS_REQUEST_OUT_OF_SEQUENCE                 NT_STATUS(0xC000042A)
     1055#define NT_STATUS_IMPLEMENTATION_LIMIT                    NT_STATUS(0xC000042B)
     1056#define NT_STATUS_ELEVATION_REQUIRED                      NT_STATUS(0xC000042C)
     1057#define NT_STATUS_NO_SECURITY_CONTEXT                     NT_STATUS(0xC000042D)
     1058#define NT_STATUS_PKU2U_CERT_FAILURE                      NT_STATUS(0xC000042E)
     1059#define NT_STATUS_BEYOND_VDL                              NT_STATUS(0xC0000432)
     1060#define NT_STATUS_ENCOUNTERED_WRITE_IN_PROGRESS           NT_STATUS(0xC0000433)
     1061#define NT_STATUS_PTE_CHANGED                             NT_STATUS(0xC0000434)
     1062#define NT_STATUS_PURGE_FAILED                            NT_STATUS(0xC0000435)
     1063#define NT_STATUS_CRED_REQUIRES_CONFIRMATION              NT_STATUS(0xC0000440)
     1064#define NT_STATUS_CS_ENCRYPTION_INVALID_SERVER_RESPONSE   NT_STATUS(0xC0000441)
     1065#define NT_STATUS_CS_ENCRYPTION_UNSUPPORTED_SERVER        NT_STATUS(0xC0000442)
     1066#define NT_STATUS_CS_ENCRYPTION_EXISTING_ENCRYPTED_FILE   NT_STATUS(0xC0000443)
     1067#define NT_STATUS_CS_ENCRYPTION_NEW_ENCRYPTED_FILE        NT_STATUS(0xC0000444)
     1068#define NT_STATUS_CS_ENCRYPTION_FILE_NOT_CSE              NT_STATUS(0xC0000445)
     1069#define NT_STATUS_INVALID_LABEL                           NT_STATUS(0xC0000446)
     1070#define NT_STATUS_DRIVER_PROCESS_TERMINATED               NT_STATUS(0xC0000450)
     1071#define NT_STATUS_AMBIGUOUS_SYSTEM_DEVICE                 NT_STATUS(0xC0000451)
     1072#define NT_STATUS_SYSTEM_DEVICE_NOT_FOUND                 NT_STATUS(0xC0000452)
     1073#define NT_STATUS_RESTART_BOOT_APPLICATION                NT_STATUS(0xC0000453)
     1074#define NT_STATUS_INSUFFICIENT_NVRAM_RESOURCES            NT_STATUS(0xC0000454)
     1075#define NT_STATUS_NO_RANGES_PROCESSED                     NT_STATUS(0xC0000460)
     1076#define NT_STATUS_DEVICE_FEATURE_NOT_SUPPORTED            NT_STATUS(0xC0000463)
     1077#define NT_STATUS_DEVICE_UNREACHABLE                      NT_STATUS(0xC0000464)
     1078#define NT_STATUS_INVALID_TOKEN                           NT_STATUS(0xC0000465)
     1079#define NT_STATUS_INVALID_TASK_NAME                       NT_STATUS(0xC0000500)
     1080#define NT_STATUS_INVALID_TASK_INDEX                      NT_STATUS(0xC0000501)
     1081#define NT_STATUS_THREAD_ALREADY_IN_TASK                  NT_STATUS(0xC0000502)
     1082#define NT_STATUS_CALLBACK_BYPASS                         NT_STATUS(0xC0000503)
     1083#define NT_STATUS_FAIL_FAST_EXCEPTION                     NT_STATUS(0xC0000602)
     1084#define NT_STATUS_IMAGE_CERT_REVOKED                      NT_STATUS(0xC0000603)
     1085#define NT_STATUS_PORT_CLOSED                             NT_STATUS(0xC0000700)
     1086#define NT_STATUS_MESSAGE_LOST                            NT_STATUS(0xC0000701)
     1087#define NT_STATUS_INVALID_MESSAGE                         NT_STATUS(0xC0000702)
     1088#define NT_STATUS_REQUEST_CANCELED                        NT_STATUS(0xC0000703)
     1089#define NT_STATUS_RECURSIVE_DISPATCH                      NT_STATUS(0xC0000704)
     1090#define NT_STATUS_LPC_RECEIVE_BUFFER_EXPECTED             NT_STATUS(0xC0000705)
     1091#define NT_STATUS_LPC_INVALID_CONNECTION_USAGE            NT_STATUS(0xC0000706)
     1092#define NT_STATUS_LPC_REQUESTS_NOT_ALLOWED                NT_STATUS(0xC0000707)
     1093#define NT_STATUS_RESOURCE_IN_USE                         NT_STATUS(0xC0000708)
     1094#define NT_STATUS_HARDWARE_MEMORY_ERROR                   NT_STATUS(0xC0000709)
     1095#define NT_STATUS_THREADPOOL_HANDLE_EXCEPTION             NT_STATUS(0xC000070A)
     1096#define NT_STATUS_THREADPOOL_SET_EVENT_ON_COMPLETION_FAILED NT_STATUS(0xC000070B)
     1097#define NT_STATUS_THREADPOOL_RELEASE_SEMAPHORE_ON_COMPLETION_FAILED NT_STATUS(0xC000070C)
     1098#define NT_STATUS_THREADPOOL_RELEASE_MUTEX_ON_COMPLETION_FAILED NT_STATUS(0xC000070D)
     1099#define NT_STATUS_THREADPOOL_FREE_LIBRARY_ON_COMPLETION_FAILED NT_STATUS(0xC000070E)
     1100#define NT_STATUS_THREADPOOL_RELEASED_DURING_OPERATION    NT_STATUS(0xC000070F)
     1101#define NT_STATUS_CALLBACK_RETURNED_WHILE_IMPERSONATING   NT_STATUS(0xC0000710)
     1102#define NT_STATUS_APC_RETURNED_WHILE_IMPERSONATING        NT_STATUS(0xC0000711)
     1103#define NT_STATUS_PROCESS_IS_PROTECTED                    NT_STATUS(0xC0000712)
     1104#define NT_STATUS_MCA_EXCEPTION                           NT_STATUS(0xC0000713)
     1105#define NT_STATUS_CERTIFICATE_MAPPING_NOT_UNIQUE          NT_STATUS(0xC0000714)
     1106#define NT_STATUS_SYMLINK_CLASS_DISABLED                  NT_STATUS(0xC0000715)
     1107#define NT_STATUS_INVALID_IDN_NORMALIZATION               NT_STATUS(0xC0000716)
     1108#define NT_STATUS_NO_UNICODE_TRANSLATION                  NT_STATUS(0xC0000717)
     1109#define NT_STATUS_ALREADY_REGISTERED                      NT_STATUS(0xC0000718)
     1110#define NT_STATUS_CONTEXT_MISMATCH                        NT_STATUS(0xC0000719)
     1111#define NT_STATUS_PORT_ALREADY_HAS_COMPLETION_LIST        NT_STATUS(0xC000071A)
     1112#define NT_STATUS_CALLBACK_RETURNED_THREAD_PRIORITY       NT_STATUS(0xC000071B)
     1113#define NT_STATUS_INVALID_THREAD                          NT_STATUS(0xC000071C)
     1114#define NT_STATUS_CALLBACK_RETURNED_TRANSACTION           NT_STATUS(0xC000071D)
     1115#define NT_STATUS_CALLBACK_RETURNED_LDR_LOCK              NT_STATUS(0xC000071E)
     1116#define NT_STATUS_CALLBACK_RETURNED_LANG                  NT_STATUS(0xC000071F)
     1117#define NT_STATUS_CALLBACK_RETURNED_PRI_BACK              NT_STATUS(0xC0000720)
     1118#define NT_STATUS_DISK_REPAIR_DISABLED                    NT_STATUS(0xC0000800)
     1119#define NT_STATUS_DS_DOMAIN_RENAME_IN_PROGRESS            NT_STATUS(0xC0000801)
     1120#define NT_STATUS_DISK_QUOTA_EXCEEDED                     NT_STATUS(0xC0000802)
     1121#define NT_STATUS_CONTENT_BLOCKED                         NT_STATUS(0xC0000804)
     1122#define NT_STATUS_BAD_CLUSTERS                            NT_STATUS(0xC0000805)
     1123#define NT_STATUS_VOLUME_DIRTY                            NT_STATUS(0xC0000806)
     1124#define NT_STATUS_FILE_CHECKED_OUT                        NT_STATUS(0xC0000901)
     1125#define NT_STATUS_CHECKOUT_REQUIRED                       NT_STATUS(0xC0000902)
     1126#define NT_STATUS_BAD_FILE_TYPE                           NT_STATUS(0xC0000903)
     1127#define NT_STATUS_FILE_TOO_LARGE                          NT_STATUS(0xC0000904)
     1128#define NT_STATUS_FORMS_AUTH_REQUIRED                     NT_STATUS(0xC0000905)
     1129#define NT_STATUS_VIRUS_INFECTED                          NT_STATUS(0xC0000906)
     1130#define NT_STATUS_VIRUS_DELETED                           NT_STATUS(0xC0000907)
     1131#define NT_STATUS_BAD_MCFG_TABLE                          NT_STATUS(0xC0000908)
     1132#define NT_STATUS_CANNOT_BREAK_OPLOCK                     NT_STATUS(0xC0000909)
     1133#define NT_STATUS_WOW_ASSERTION                           NT_STATUS(0xC0009898)
     1134#define NT_STATUS_INVALID_SIGNATURE                       NT_STATUS(0xC000A000)
     1135#define NT_STATUS_HMAC_NOT_SUPPORTED                      NT_STATUS(0xC000A001)
     1136#define NT_STATUS_IPSEC_QUEUE_OVERFLOW                    NT_STATUS(0xC000A010)
     1137#define NT_STATUS_ND_QUEUE_OVERFLOW                       NT_STATUS(0xC000A011)
     1138#define NT_STATUS_HOPLIMIT_EXCEEDED                       NT_STATUS(0xC000A012)
     1139#define NT_STATUS_PROTOCOL_NOT_SUPPORTED                  NT_STATUS(0xC000A013)
     1140#define NT_STATUS_LOST_WRITEBEHIND_DATA_NETWORK_DISCONNECTED NT_STATUS(0xC000A080)
     1141#define NT_STATUS_LOST_WRITEBEHIND_DATA_NETWORK_SERVER_ERROR NT_STATUS(0xC000A081)
     1142#define NT_STATUS_LOST_WRITEBEHIND_DATA_LOCAL_DISK_ERROR  NT_STATUS(0xC000A082)
     1143#define NT_STATUS_XML_PARSE_ERROR                         NT_STATUS(0xC000A083)
     1144#define NT_STATUS_XMLDSIG_ERROR                           NT_STATUS(0xC000A084)
     1145#define NT_STATUS_WRONG_COMPARTMENT                       NT_STATUS(0xC000A085)
     1146#define NT_STATUS_AUTHIP_FAILURE                          NT_STATUS(0xC000A086)
     1147#define NT_STATUS_DS_OID_MAPPED_GROUP_CANT_HAVE_MEMBERS   NT_STATUS(0xC000A087)
     1148#define NT_STATUS_DS_OID_NOT_FOUND                        NT_STATUS(0xC000A088)
     1149#define NT_STATUS_HASH_NOT_SUPPORTED                      NT_STATUS(0xC000A100)
     1150#define NT_STATUS_HASH_NOT_PRESENT                        NT_STATUS(0xC000A101)
     1151#define NT_STATUS_OFFLOAD_READ_FLT_NOT_SUPPORTED          NT_STATUS(0xC000A2A1)
     1152#define NT_STATUS_OFFLOAD_WRITE_FLT_NOT_SUPPORTED         NT_STATUS(0xC000A2A2)
     1153#define NT_STATUS_OFFLOAD_READ_FILE_NOT_SUPPORTED         NT_STATUS(0xC000A2A3)
     1154#define NT_STATUS_OFFLOAD_WRITE_FILE_NOT_SUPPORTED        NT_STATUS(0xC000A2A4)
     1155#define NT_STATUS_DBG_NO_STATE_CHANGE                     NT_STATUS(0xC0010001)
     1156#define NT_STATUS_DBG_APP_NOT_IDLE                        NT_STATUS(0xC0010002)
     1157#define NT_STATUS_RPC_INVALID_STRING_BINDING              NT_STATUS(0xC0020001)
     1158#define NT_STATUS_RPC_WRONG_KIND_OF_BINDING               NT_STATUS(0xC0020002)
     1159#define NT_STATUS_RPC_INVALID_BINDING                     NT_STATUS(0xC0020003)
     1160#define NT_STATUS_RPC_INVALID_RPC_PROTSEQ                 NT_STATUS(0xC0020005)
     1161#define NT_STATUS_RPC_INVALID_STRING_UUID                 NT_STATUS(0xC0020006)
     1162#define NT_STATUS_RPC_INVALID_ENDPOINT_FORMAT             NT_STATUS(0xC0020007)
     1163#define NT_STATUS_RPC_INVALID_NET_ADDR                    NT_STATUS(0xC0020008)
     1164#define NT_STATUS_RPC_NO_ENDPOINT_FOUND                   NT_STATUS(0xC0020009)
     1165#define NT_STATUS_RPC_INVALID_TIMEOUT                     NT_STATUS(0xC002000A)
     1166#define NT_STATUS_RPC_OBJECT_NOT_FOUND                    NT_STATUS(0xC002000B)
     1167#define NT_STATUS_RPC_ALREADY_REGISTERED                  NT_STATUS(0xC002000C)
     1168#define NT_STATUS_RPC_TYPE_ALREADY_REGISTERED             NT_STATUS(0xC002000D)
     1169#define NT_STATUS_RPC_ALREADY_LISTENING                   NT_STATUS(0xC002000E)
     1170#define NT_STATUS_RPC_NO_PROTSEQS_REGISTERED              NT_STATUS(0xC002000F)
     1171#define NT_STATUS_RPC_NOT_LISTENING                       NT_STATUS(0xC0020010)
     1172#define NT_STATUS_RPC_UNKNOWN_MGR_TYPE                    NT_STATUS(0xC0020011)
     1173#define NT_STATUS_RPC_NO_BINDINGS                         NT_STATUS(0xC0020013)
     1174#define NT_STATUS_RPC_NO_PROTSEQS                         NT_STATUS(0xC0020014)
     1175#define NT_STATUS_RPC_CANT_CREATE_ENDPOINT                NT_STATUS(0xC0020015)
     1176#define NT_STATUS_RPC_OUT_OF_RESOURCES                    NT_STATUS(0xC0020016)
     1177#define NT_STATUS_RPC_SERVER_UNAVAILABLE                  NT_STATUS(0xC0020017)
     1178#define NT_STATUS_RPC_SERVER_TOO_BUSY                     NT_STATUS(0xC0020018)
     1179#define NT_STATUS_RPC_INVALID_NETWORK_OPTIONS             NT_STATUS(0xC0020019)
     1180#define NT_STATUS_RPC_NO_CALL_ACTIVE                      NT_STATUS(0xC002001A)
     1181#define NT_STATUS_RPC_CALL_FAILED_DNE                     NT_STATUS(0xC002001C)
     1182#define NT_STATUS_RPC_UNSUPPORTED_TRANS_SYN               NT_STATUS(0xC002001F)
     1183#define NT_STATUS_RPC_UNSUPPORTED_TYPE                    NT_STATUS(0xC0020021)
     1184#define NT_STATUS_RPC_INVALID_TAG                         NT_STATUS(0xC0020022)
     1185#define NT_STATUS_RPC_INVALID_BOUND                       NT_STATUS(0xC0020023)
     1186#define NT_STATUS_RPC_NO_ENTRY_NAME                       NT_STATUS(0xC0020024)
     1187#define NT_STATUS_RPC_INVALID_NAME_SYNTAX                 NT_STATUS(0xC0020025)
     1188#define NT_STATUS_RPC_UUID_NO_ADDRESS                     NT_STATUS(0xC0020028)
     1189#define NT_STATUS_RPC_DUPLICATE_ENDPOINT                  NT_STATUS(0xC0020029)
     1190#define NT_STATUS_RPC_UNKNOWN_AUTHN_TYPE                  NT_STATUS(0xC002002A)
     1191#define NT_STATUS_RPC_MAX_CALLS_TOO_SMALL                 NT_STATUS(0xC002002B)
     1192#define NT_STATUS_RPC_STRING_TOO_LONG                     NT_STATUS(0xC002002C)
     1193#define NT_STATUS_RPC_PROTSEQ_NOT_FOUND                   NT_STATUS(0xC002002D)
     1194#define NT_STATUS_RPC_BINDING_HAS_NO_AUTH                 NT_STATUS(0xC002002F)
     1195#define NT_STATUS_RPC_UNKNOWN_AUTHN_SERVICE               NT_STATUS(0xC0020030)
     1196#define NT_STATUS_RPC_UNKNOWN_AUTHN_LEVEL                 NT_STATUS(0xC0020031)
     1197#define NT_STATUS_RPC_INVALID_AUTH_IDENTITY               NT_STATUS(0xC0020032)
     1198#define NT_STATUS_RPC_UNKNOWN_AUTHZ_SERVICE               NT_STATUS(0xC0020033)
     1199#define NT_STATUS_EPT_INVALID_ENTRY                       NT_STATUS(0xC0020034)
     1200#define NT_STATUS_EPT_CANT_PERFORM_OP                     NT_STATUS(0xC0020035)
     1201#define NT_STATUS_EPT_NOT_REGISTERED                      NT_STATUS(0xC0020036)
     1202#define NT_STATUS_RPC_NOTHING_TO_EXPORT                   NT_STATUS(0xC0020037)
     1203#define NT_STATUS_RPC_INCOMPLETE_NAME                     NT_STATUS(0xC0020038)
     1204#define NT_STATUS_RPC_INVALID_VERS_OPTION                 NT_STATUS(0xC0020039)
     1205#define NT_STATUS_RPC_NO_MORE_MEMBERS                     NT_STATUS(0xC002003A)
     1206#define NT_STATUS_RPC_NOT_ALL_OBJS_UNEXPORTED             NT_STATUS(0xC002003B)
     1207#define NT_STATUS_RPC_INTERFACE_NOT_FOUND                 NT_STATUS(0xC002003C)
     1208#define NT_STATUS_RPC_ENTRY_ALREADY_EXISTS                NT_STATUS(0xC002003D)
     1209#define NT_STATUS_RPC_ENTRY_NOT_FOUND                     NT_STATUS(0xC002003E)
     1210#define NT_STATUS_RPC_NAME_SERVICE_UNAVAILABLE            NT_STATUS(0xC002003F)
     1211#define NT_STATUS_RPC_INVALID_NAF_ID                      NT_STATUS(0xC0020040)
     1212#define NT_STATUS_RPC_NO_CONTEXT_AVAILABLE                NT_STATUS(0xC0020042)
     1213#define NT_STATUS_RPC_INTERNAL_ERROR                      NT_STATUS(0xC0020043)
     1214#define NT_STATUS_RPC_ZERO_DIVIDE                         NT_STATUS(0xC0020044)
     1215#define NT_STATUS_RPC_ADDRESS_ERROR                       NT_STATUS(0xC0020045)
     1216#define NT_STATUS_RPC_FP_DIV_ZERO                         NT_STATUS(0xC0020046)
     1217#define NT_STATUS_RPC_FP_UNDERFLOW                        NT_STATUS(0xC0020047)
     1218#define NT_STATUS_RPC_FP_OVERFLOW                         NT_STATUS(0xC0020048)
     1219#define NT_STATUS_RPC_CALL_IN_PROGRESS                    NT_STATUS(0xC0020049)
     1220#define NT_STATUS_RPC_NO_MORE_BINDINGS                    NT_STATUS(0xC002004A)
     1221#define NT_STATUS_RPC_GROUP_MEMBER_NOT_FOUND              NT_STATUS(0xC002004B)
     1222#define NT_STATUS_EPT_CANT_CREATE                         NT_STATUS(0xC002004C)
     1223#define NT_STATUS_RPC_INVALID_OBJECT                      NT_STATUS(0xC002004D)
     1224#define NT_STATUS_RPC_NO_INTERFACES                       NT_STATUS(0xC002004F)
     1225#define NT_STATUS_RPC_CALL_CANCELLED                      NT_STATUS(0xC0020050)
     1226#define NT_STATUS_RPC_BINDING_INCOMPLETE                  NT_STATUS(0xC0020051)
     1227#define NT_STATUS_RPC_COMM_FAILURE                        NT_STATUS(0xC0020052)
     1228#define NT_STATUS_RPC_UNSUPPORTED_AUTHN_LEVEL             NT_STATUS(0xC0020053)
     1229#define NT_STATUS_RPC_NO_PRINC_NAME                       NT_STATUS(0xC0020054)
     1230#define NT_STATUS_RPC_NOT_RPC_ERROR                       NT_STATUS(0xC0020055)
     1231#define NT_STATUS_RPC_NOT_CANCELLED                       NT_STATUS(0xC0020058)
     1232#define NT_STATUS_RPC_INVALID_ASYNC_HANDLE                NT_STATUS(0xC0020062)
     1233#define NT_STATUS_RPC_INVALID_ASYNC_CALL                  NT_STATUS(0xC0020063)
     1234#define NT_STATUS_RPC_PROXY_ACCESS_DENIED                 NT_STATUS(0xC0020064)
     1235#define NT_STATUS_RPC_NO_MORE_ENTRIES                     NT_STATUS(0xC0030001)
     1236#define NT_STATUS_RPC_SS_CHAR_TRANS_OPEN_FAIL             NT_STATUS(0xC0030002)
     1237#define NT_STATUS_RPC_SS_CHAR_TRANS_SHORT_FILE            NT_STATUS(0xC0030003)
     1238#define NT_STATUS_RPC_SS_IN_NULL_CONTEXT                  NT_STATUS(0xC0030004)
     1239#define NT_STATUS_RPC_SS_CONTEXT_DAMAGED                  NT_STATUS(0xC0030006)
     1240#define NT_STATUS_RPC_SS_HANDLES_MISMATCH                 NT_STATUS(0xC0030007)
     1241#define NT_STATUS_RPC_SS_CANNOT_GET_CALL_HANDLE           NT_STATUS(0xC0030008)
     1242#define NT_STATUS_RPC_NULL_REF_POINTER                    NT_STATUS(0xC0030009)
     1243#define NT_STATUS_RPC_BYTE_COUNT_TOO_SMALL                NT_STATUS(0xC003000B)
     1244#define NT_STATUS_RPC_INVALID_ES_ACTION                   NT_STATUS(0xC0030059)
     1245#define NT_STATUS_RPC_WRONG_ES_VERSION                    NT_STATUS(0xC003005A)
     1246#define NT_STATUS_RPC_WRONG_STUB_VERSION                  NT_STATUS(0xC003005B)
     1247#define NT_STATUS_PNP_BAD_MPS_TABLE                       NT_STATUS(0xC0040035)
     1248#define NT_STATUS_PNP_TRANSLATION_FAILED                  NT_STATUS(0xC0040036)
     1249#define NT_STATUS_PNP_IRQ_TRANSLATION_FAILED              NT_STATUS(0xC0040037)
     1250#define NT_STATUS_PNP_INVALID_ID                          NT_STATUS(0xC0040038)
     1251#define NT_STATUS_IO_REISSUE_AS_CACHED                    NT_STATUS(0xC0040039)
     1252#define NT_STATUS_CTX_WINSTATION_NAME_INVALID             NT_STATUS(0xC00A0001)
     1253#define NT_STATUS_CTX_INVALID_PD                          NT_STATUS(0xC00A0002)
     1254#define NT_STATUS_CTX_PD_NOT_FOUND                        NT_STATUS(0xC00A0003)
     1255#define NT_STATUS_CTX_CLOSE_PENDING                       NT_STATUS(0xC00A0006)
     1256#define NT_STATUS_CTX_NO_OUTBUF                           NT_STATUS(0xC00A0007)
     1257#define NT_STATUS_CTX_MODEM_INF_NOT_FOUND                 NT_STATUS(0xC00A0008)
     1258#define NT_STATUS_CTX_INVALID_MODEMNAME                   NT_STATUS(0xC00A0009)
     1259#define NT_STATUS_CTX_RESPONSE_ERROR                      NT_STATUS(0xC00A000A)
     1260#define NT_STATUS_CTX_MODEM_RESPONSE_TIMEOUT              NT_STATUS(0xC00A000B)
     1261#define NT_STATUS_CTX_MODEM_RESPONSE_NO_CARRIER           NT_STATUS(0xC00A000C)
     1262#define NT_STATUS_CTX_MODEM_RESPONSE_NO_DIALTONE          NT_STATUS(0xC00A000D)
     1263#define NT_STATUS_CTX_MODEM_RESPONSE_BUSY                 NT_STATUS(0xC00A000E)
     1264#define NT_STATUS_CTX_MODEM_RESPONSE_VOICE                NT_STATUS(0xC00A000F)
     1265#define NT_STATUS_CTX_TD_ERROR                            NT_STATUS(0xC00A0010)
     1266#define NT_STATUS_CTX_LICENSE_CLIENT_INVALID              NT_STATUS(0xC00A0012)
     1267#define NT_STATUS_CTX_LICENSE_NOT_AVAILABLE               NT_STATUS(0xC00A0013)
     1268#define NT_STATUS_CTX_LICENSE_EXPIRED                     NT_STATUS(0xC00A0014)
     1269#define NT_STATUS_CTX_WINSTATION_NOT_FOUND                NT_STATUS(0xC00A0015)
     1270#define NT_STATUS_CTX_WINSTATION_NAME_COLLISION           NT_STATUS(0xC00A0016)
     1271#define NT_STATUS_CTX_WINSTATION_BUSY                     NT_STATUS(0xC00A0017)
     1272#define NT_STATUS_CTX_BAD_VIDEO_MODE                      NT_STATUS(0xC00A0018)
     1273#define NT_STATUS_CTX_GRAPHICS_INVALID                    NT_STATUS(0xC00A0022)
     1274#define NT_STATUS_CTX_NOT_CONSOLE                         NT_STATUS(0xC00A0024)
     1275#define NT_STATUS_CTX_CLIENT_QUERY_TIMEOUT                NT_STATUS(0xC00A0026)
     1276#define NT_STATUS_CTX_CONSOLE_DISCONNECT                  NT_STATUS(0xC00A0027)
     1277#define NT_STATUS_CTX_CONSOLE_CONNECT                     NT_STATUS(0xC00A0028)
     1278#define NT_STATUS_CTX_SHADOW_DENIED                       NT_STATUS(0xC00A002A)
     1279#define NT_STATUS_CTX_WINSTATION_ACCESS_DENIED            NT_STATUS(0xC00A002B)
     1280#define NT_STATUS_CTX_INVALID_WD                          NT_STATUS(0xC00A002E)
     1281#define NT_STATUS_CTX_WD_NOT_FOUND                        NT_STATUS(0xC00A002F)
     1282#define NT_STATUS_CTX_SHADOW_INVALID                      NT_STATUS(0xC00A0030)
     1283#define NT_STATUS_CTX_SHADOW_DISABLED                     NT_STATUS(0xC00A0031)
     1284#define NT_STATUS_RDP_PROTOCOL_ERROR                      NT_STATUS(0xC00A0032)
     1285#define NT_STATUS_CTX_CLIENT_LICENSE_NOT_SET              NT_STATUS(0xC00A0033)
     1286#define NT_STATUS_CTX_CLIENT_LICENSE_IN_USE               NT_STATUS(0xC00A0034)
     1287#define NT_STATUS_CTX_SHADOW_ENDED_BY_MODE_CHANGE         NT_STATUS(0xC00A0035)
     1288#define NT_STATUS_CTX_SHADOW_NOT_RUNNING                  NT_STATUS(0xC00A0036)
     1289#define NT_STATUS_CTX_LOGON_DISABLED                      NT_STATUS(0xC00A0037)
     1290#define NT_STATUS_CTX_SECURITY_LAYER_ERROR                NT_STATUS(0xC00A0038)
     1291#define NT_STATUS_TS_INCOMPATIBLE_SESSIONS                NT_STATUS(0xC00A0039)
     1292#define NT_STATUS_MUI_FILE_NOT_FOUND                      NT_STATUS(0xC00B0001)
     1293#define NT_STATUS_MUI_INVALID_FILE                        NT_STATUS(0xC00B0002)
     1294#define NT_STATUS_MUI_INVALID_RC_CONFIG                   NT_STATUS(0xC00B0003)
     1295#define NT_STATUS_MUI_INVALID_LOCALE_NAME                 NT_STATUS(0xC00B0004)
     1296#define NT_STATUS_MUI_INVALID_ULTIMATEFALLBACK_NAME       NT_STATUS(0xC00B0005)
     1297#define NT_STATUS_MUI_FILE_NOT_LOADED                     NT_STATUS(0xC00B0006)
     1298#define NT_STATUS_RESOURCE_ENUM_USER_STOP                 NT_STATUS(0xC00B0007)
     1299#define NT_STATUS_CLUSTER_INVALID_NODE                    NT_STATUS(0xC0130001)
     1300#define NT_STATUS_CLUSTER_NODE_EXISTS                     NT_STATUS(0xC0130002)
     1301#define NT_STATUS_CLUSTER_JOIN_IN_PROGRESS                NT_STATUS(0xC0130003)
     1302#define NT_STATUS_CLUSTER_NODE_NOT_FOUND                  NT_STATUS(0xC0130004)
     1303#define NT_STATUS_CLUSTER_LOCAL_NODE_NOT_FOUND            NT_STATUS(0xC0130005)
     1304#define NT_STATUS_CLUSTER_NETWORK_EXISTS                  NT_STATUS(0xC0130006)
     1305#define NT_STATUS_CLUSTER_NETWORK_NOT_FOUND               NT_STATUS(0xC0130007)
     1306#define NT_STATUS_CLUSTER_NETINTERFACE_EXISTS             NT_STATUS(0xC0130008)
     1307#define NT_STATUS_CLUSTER_NETINTERFACE_NOT_FOUND          NT_STATUS(0xC0130009)
     1308#define NT_STATUS_CLUSTER_INVALID_REQUEST                 NT_STATUS(0xC013000A)
     1309#define NT_STATUS_CLUSTER_INVALID_NETWORK_PROVIDER        NT_STATUS(0xC013000B)
     1310#define NT_STATUS_CLUSTER_NODE_DOWN                       NT_STATUS(0xC013000C)
     1311#define NT_STATUS_CLUSTER_NODE_UNREACHABLE                NT_STATUS(0xC013000D)
     1312#define NT_STATUS_CLUSTER_NODE_NOT_MEMBER                 NT_STATUS(0xC013000E)
     1313#define NT_STATUS_CLUSTER_JOIN_NOT_IN_PROGRESS            NT_STATUS(0xC013000F)
     1314#define NT_STATUS_CLUSTER_INVALID_NETWORK                 NT_STATUS(0xC0130010)
     1315#define NT_STATUS_CLUSTER_NO_NET_ADAPTERS                 NT_STATUS(0xC0130011)
     1316#define NT_STATUS_CLUSTER_NODE_UP                         NT_STATUS(0xC0130012)
     1317#define NT_STATUS_CLUSTER_NODE_PAUSED                     NT_STATUS(0xC0130013)
     1318#define NT_STATUS_CLUSTER_NODE_NOT_PAUSED                 NT_STATUS(0xC0130014)
     1319#define NT_STATUS_CLUSTER_NO_SECURITY_CONTEXT             NT_STATUS(0xC0130015)
     1320#define NT_STATUS_CLUSTER_NETWORK_NOT_INTERNAL            NT_STATUS(0xC0130016)
     1321#define NT_STATUS_CLUSTER_POISONED                        NT_STATUS(0xC0130017)
     1322#define NT_STATUS_ACPI_INVALID_OPCODE                     NT_STATUS(0xC0140001)
     1323#define NT_STATUS_ACPI_STACK_OVERFLOW                     NT_STATUS(0xC0140002)
     1324#define NT_STATUS_ACPI_ASSERT_FAILED                      NT_STATUS(0xC0140003)
     1325#define NT_STATUS_ACPI_INVALID_INDEX                      NT_STATUS(0xC0140004)
     1326#define NT_STATUS_ACPI_INVALID_ARGUMENT                   NT_STATUS(0xC0140005)
     1327#define NT_STATUS_ACPI_FATAL                              NT_STATUS(0xC0140006)
     1328#define NT_STATUS_ACPI_INVALID_SUPERNAME                  NT_STATUS(0xC0140007)
     1329#define NT_STATUS_ACPI_INVALID_ARGTYPE                    NT_STATUS(0xC0140008)
     1330#define NT_STATUS_ACPI_INVALID_OBJTYPE                    NT_STATUS(0xC0140009)
     1331#define NT_STATUS_ACPI_INVALID_TARGETTYPE                 NT_STATUS(0xC014000A)
     1332#define NT_STATUS_ACPI_INCORRECT_ARGUMENT_COUNT           NT_STATUS(0xC014000B)
     1333#define NT_STATUS_ACPI_ADDRESS_NOT_MAPPED                 NT_STATUS(0xC014000C)
     1334#define NT_STATUS_ACPI_INVALID_EVENTTYPE                  NT_STATUS(0xC014000D)
     1335#define NT_STATUS_ACPI_HANDLER_COLLISION                  NT_STATUS(0xC014000E)
     1336#define NT_STATUS_ACPI_INVALID_DATA                       NT_STATUS(0xC014000F)
     1337#define NT_STATUS_ACPI_INVALID_REGION                     NT_STATUS(0xC0140010)
     1338#define NT_STATUS_ACPI_INVALID_ACCESS_SIZE                NT_STATUS(0xC0140011)
     1339#define NT_STATUS_ACPI_ACQUIRE_GLOBAL_LOCK                NT_STATUS(0xC0140012)
     1340#define NT_STATUS_ACPI_ALREADY_INITIALIZED                NT_STATUS(0xC0140013)
     1341#define NT_STATUS_ACPI_NOT_INITIALIZED                    NT_STATUS(0xC0140014)
     1342#define NT_STATUS_ACPI_INVALID_MUTEX_LEVEL                NT_STATUS(0xC0140015)
     1343#define NT_STATUS_ACPI_MUTEX_NOT_OWNED                    NT_STATUS(0xC0140016)
     1344#define NT_STATUS_ACPI_MUTEX_NOT_OWNER                    NT_STATUS(0xC0140017)
     1345#define NT_STATUS_ACPI_RS_ACCESS                          NT_STATUS(0xC0140018)
     1346#define NT_STATUS_ACPI_INVALID_TABLE                      NT_STATUS(0xC0140019)
     1347#define NT_STATUS_ACPI_REG_HANDLER_FAILED                 NT_STATUS(0xC0140020)
     1348#define NT_STATUS_ACPI_POWER_REQUEST_FAILED               NT_STATUS(0xC0140021)
     1349#define NT_STATUS_SXS_SECTION_NOT_FOUND                   NT_STATUS(0xC0150001)
     1350#define NT_STATUS_SXS_CANT_GEN_ACTCTX                     NT_STATUS(0xC0150002)
     1351#define NT_STATUS_SXS_INVALID_ACTCTXDATA_FORMAT           NT_STATUS(0xC0150003)
     1352#define NT_STATUS_SXS_ASSEMBLY_NOT_FOUND                  NT_STATUS(0xC0150004)
     1353#define NT_STATUS_SXS_MANIFEST_FORMAT_ERROR               NT_STATUS(0xC0150005)
     1354#define NT_STATUS_SXS_MANIFEST_PARSE_ERROR                NT_STATUS(0xC0150006)
     1355#define NT_STATUS_SXS_ACTIVATION_CONTEXT_DISABLED         NT_STATUS(0xC0150007)
     1356#define NT_STATUS_SXS_KEY_NOT_FOUND                       NT_STATUS(0xC0150008)
     1357#define NT_STATUS_SXS_VERSION_CONFLICT                    NT_STATUS(0xC0150009)
     1358#define NT_STATUS_SXS_WRONG_SECTION_TYPE                  NT_STATUS(0xC015000A)
     1359#define NT_STATUS_SXS_THREAD_QUERIES_DISABLED             NT_STATUS(0xC015000B)
     1360#define NT_STATUS_SXS_ASSEMBLY_MISSING                    NT_STATUS(0xC015000C)
     1361#define NT_STATUS_SXS_PROCESS_DEFAULT_ALREADY_SET         NT_STATUS(0xC015000E)
     1362#define NT_STATUS_SXS_EARLY_DEACTIVATION                  NT_STATUS(0xC015000F)
     1363#define NT_STATUS_SXS_INVALID_DEACTIVATION                NT_STATUS(0xC0150010)
     1364#define NT_STATUS_SXS_MULTIPLE_DEACTIVATION               NT_STATUS(0xC0150011)
     1365#define NT_STATUS_SXS_SYSTEM_DEFAULT_ACTIVATION_CONTEXT_EMPTY NT_STATUS(0xC0150012)
     1366#define NT_STATUS_SXS_PROCESS_TERMINATION_REQUESTED       NT_STATUS(0xC0150013)
     1367#define NT_STATUS_SXS_CORRUPT_ACTIVATION_STACK            NT_STATUS(0xC0150014)
     1368#define NT_STATUS_SXS_CORRUPTION                          NT_STATUS(0xC0150015)
     1369#define NT_STATUS_SXS_INVALID_IDENTITY_ATTRIBUTE_VALUE    NT_STATUS(0xC0150016)
     1370#define NT_STATUS_SXS_INVALID_IDENTITY_ATTRIBUTE_NAME     NT_STATUS(0xC0150017)
     1371#define NT_STATUS_SXS_IDENTITY_DUPLICATE_ATTRIBUTE        NT_STATUS(0xC0150018)
     1372#define NT_STATUS_SXS_IDENTITY_PARSE_ERROR                NT_STATUS(0xC0150019)
     1373#define NT_STATUS_SXS_COMPONENT_STORE_CORRUPT             NT_STATUS(0xC015001A)
     1374#define NT_STATUS_SXS_FILE_HASH_MISMATCH                  NT_STATUS(0xC015001B)
     1375#define NT_STATUS_SXS_MANIFEST_IDENTITY_SAME_BUT_CONTENTS_DIFFERENT NT_STATUS(0xC015001C)
     1376#define NT_STATUS_SXS_IDENTITIES_DIFFERENT                NT_STATUS(0xC015001D)
     1377#define NT_STATUS_SXS_ASSEMBLY_IS_NOT_A_DEPLOYMENT        NT_STATUS(0xC015001E)
     1378#define NT_STATUS_SXS_FILE_NOT_PART_OF_ASSEMBLY           NT_STATUS(0xC015001F)
     1379#define NT_STATUS_ADVANCED_INSTALLER_FAILED               NT_STATUS(0xC0150020)
     1380#define NT_STATUS_XML_ENCODING_MISMATCH                   NT_STATUS(0xC0150021)
     1381#define NT_STATUS_SXS_MANIFEST_TOO_BIG                    NT_STATUS(0xC0150022)
     1382#define NT_STATUS_SXS_SETTING_NOT_REGISTERED              NT_STATUS(0xC0150023)
     1383#define NT_STATUS_SXS_TRANSACTION_CLOSURE_INCOMPLETE      NT_STATUS(0xC0150024)
     1384#define NT_STATUS_SMI_PRIMITIVE_INSTALLER_FAILED          NT_STATUS(0xC0150025)
     1385#define NT_STATUS_GENERIC_COMMAND_FAILED                  NT_STATUS(0xC0150026)
     1386#define NT_STATUS_SXS_FILE_HASH_MISSING                   NT_STATUS(0xC0150027)
     1387#define NT_STATUS_TRANSACTIONAL_CONFLICT                  NT_STATUS(0xC0190001)
     1388#define NT_STATUS_INVALID_TRANSACTION                     NT_STATUS(0xC0190002)
     1389#define NT_STATUS_TRANSACTION_NOT_ACTIVE                  NT_STATUS(0xC0190003)
     1390#define NT_STATUS_TM_INITIALIZATION_FAILED                NT_STATUS(0xC0190004)
     1391#define NT_STATUS_RM_NOT_ACTIVE                           NT_STATUS(0xC0190005)
     1392#define NT_STATUS_RM_METADATA_CORRUPT                     NT_STATUS(0xC0190006)
     1393#define NT_STATUS_TRANSACTION_NOT_JOINED                  NT_STATUS(0xC0190007)
     1394#define NT_STATUS_DIRECTORY_NOT_RM                        NT_STATUS(0xC0190008)
     1395#define NT_STATUS_TRANSACTIONS_UNSUPPORTED_REMOTE         NT_STATUS(0xC019000A)
     1396#define NT_STATUS_LOG_RESIZE_INVALID_SIZE                 NT_STATUS(0xC019000B)
     1397#define NT_STATUS_REMOTE_FILE_VERSION_MISMATCH            NT_STATUS(0xC019000C)
     1398#define NT_STATUS_CRM_PROTOCOL_ALREADY_EXISTS             NT_STATUS(0xC019000F)
     1399#define NT_STATUS_TRANSACTION_PROPAGATION_FAILED          NT_STATUS(0xC0190010)
     1400#define NT_STATUS_CRM_PROTOCOL_NOT_FOUND                  NT_STATUS(0xC0190011)
     1401#define NT_STATUS_TRANSACTION_SUPERIOR_EXISTS             NT_STATUS(0xC0190012)
     1402#define NT_STATUS_TRANSACTION_REQUEST_NOT_VALID           NT_STATUS(0xC0190013)
     1403#define NT_STATUS_TRANSACTION_NOT_REQUESTED               NT_STATUS(0xC0190014)
     1404#define NT_STATUS_TRANSACTION_ALREADY_ABORTED             NT_STATUS(0xC0190015)
     1405#define NT_STATUS_TRANSACTION_ALREADY_COMMITTED           NT_STATUS(0xC0190016)
     1406#define NT_STATUS_TRANSACTION_INVALID_MARSHALL_BUFFER     NT_STATUS(0xC0190017)
     1407#define NT_STATUS_CURRENT_TRANSACTION_NOT_VALID           NT_STATUS(0xC0190018)
     1408#define NT_STATUS_LOG_GROWTH_FAILED                       NT_STATUS(0xC0190019)
     1409#define NT_STATUS_OBJECT_NO_LONGER_EXISTS                 NT_STATUS(0xC0190021)
     1410#define NT_STATUS_STREAM_MINIVERSION_NOT_FOUND            NT_STATUS(0xC0190022)
     1411#define NT_STATUS_STREAM_MINIVERSION_NOT_VALID            NT_STATUS(0xC0190023)
     1412#define NT_STATUS_MINIVERSION_INACCESSIBLE_FROM_SPECIFIED_TRANSACTION NT_STATUS(0xC0190024)
     1413#define NT_STATUS_CANT_OPEN_MINIVERSION_WITH_MODIFY_INTENT NT_STATUS(0xC0190025)
     1414#define NT_STATUS_CANT_CREATE_MORE_STREAM_MINIVERSIONS    NT_STATUS(0xC0190026)
     1415#define NT_STATUS_HANDLE_NO_LONGER_VALID                  NT_STATUS(0xC0190028)
     1416#define NT_STATUS_LOG_CORRUPTION_DETECTED                 NT_STATUS(0xC0190030)
     1417#define NT_STATUS_RM_DISCONNECTED                         NT_STATUS(0xC0190032)
     1418#define NT_STATUS_ENLISTMENT_NOT_SUPERIOR                 NT_STATUS(0xC0190033)
     1419#define NT_STATUS_FILE_IDENTITY_NOT_PERSISTENT            NT_STATUS(0xC0190036)
     1420#define NT_STATUS_CANT_BREAK_TRANSACTIONAL_DEPENDENCY     NT_STATUS(0xC0190037)
     1421#define NT_STATUS_CANT_CROSS_RM_BOUNDARY                  NT_STATUS(0xC0190038)
     1422#define NT_STATUS_TXF_DIR_NOT_EMPTY                       NT_STATUS(0xC0190039)
     1423#define NT_STATUS_INDOUBT_TRANSACTIONS_EXIST              NT_STATUS(0xC019003A)
     1424#define NT_STATUS_TM_VOLATILE                             NT_STATUS(0xC019003B)
     1425#define NT_STATUS_ROLLBACK_TIMER_EXPIRED                  NT_STATUS(0xC019003C)
     1426#define NT_STATUS_TXF_ATTRIBUTE_CORRUPT                   NT_STATUS(0xC019003D)
     1427#define NT_STATUS_EFS_NOT_ALLOWED_IN_TRANSACTION          NT_STATUS(0xC019003E)
     1428#define NT_STATUS_TRANSACTIONAL_OPEN_NOT_ALLOWED          NT_STATUS(0xC019003F)
     1429#define NT_STATUS_TRANSACTED_MAPPING_UNSUPPORTED_REMOTE   NT_STATUS(0xC0190040)
     1430#define NT_STATUS_TRANSACTION_REQUIRED_PROMOTION          NT_STATUS(0xC0190043)
     1431#define NT_STATUS_CANNOT_EXECUTE_FILE_IN_TRANSACTION      NT_STATUS(0xC0190044)
     1432#define NT_STATUS_TRANSACTIONS_NOT_FROZEN                 NT_STATUS(0xC0190045)
     1433#define NT_STATUS_TRANSACTION_FREEZE_IN_PROGRESS          NT_STATUS(0xC0190046)
     1434#define NT_STATUS_NOT_SNAPSHOT_VOLUME                     NT_STATUS(0xC0190047)
     1435#define NT_STATUS_NO_SAVEPOINT_WITH_OPEN_FILES            NT_STATUS(0xC0190048)
     1436#define NT_STATUS_SPARSE_NOT_ALLOWED_IN_TRANSACTION       NT_STATUS(0xC0190049)
     1437#define NT_STATUS_TM_IDENTITY_MISMATCH                    NT_STATUS(0xC019004A)
     1438#define NT_STATUS_FLOATED_SECTION                         NT_STATUS(0xC019004B)
     1439#define NT_STATUS_CANNOT_ACCEPT_TRANSACTED_WORK           NT_STATUS(0xC019004C)
     1440#define NT_STATUS_CANNOT_ABORT_TRANSACTIONS               NT_STATUS(0xC019004D)
     1441#define NT_STATUS_TRANSACTION_NOT_FOUND                   NT_STATUS(0xC019004E)
     1442#define NT_STATUS_RESOURCEMANAGER_NOT_FOUND               NT_STATUS(0xC019004F)
     1443#define NT_STATUS_ENLISTMENT_NOT_FOUND                    NT_STATUS(0xC0190050)
     1444#define NT_STATUS_TRANSACTIONMANAGER_NOT_FOUND            NT_STATUS(0xC0190051)
     1445#define NT_STATUS_TRANSACTIONMANAGER_NOT_ONLINE           NT_STATUS(0xC0190052)
     1446#define NT_STATUS_TRANSACTIONMANAGER_RECOVERY_NAME_COLLISION NT_STATUS(0xC0190053)
     1447#define NT_STATUS_TRANSACTION_NOT_ROOT                    NT_STATUS(0xC0190054)
     1448#define NT_STATUS_TRANSACTION_OBJECT_EXPIRED              NT_STATUS(0xC0190055)
     1449#define NT_STATUS_COMPRESSION_NOT_ALLOWED_IN_TRANSACTION  NT_STATUS(0xC0190056)
     1450#define NT_STATUS_TRANSACTION_RESPONSE_NOT_ENLISTED       NT_STATUS(0xC0190057)
     1451#define NT_STATUS_TRANSACTION_RECORD_TOO_LONG             NT_STATUS(0xC0190058)
     1452#define NT_STATUS_NO_LINK_TRACKING_IN_TRANSACTION         NT_STATUS(0xC0190059)
     1453#define NT_STATUS_OPERATION_NOT_SUPPORTED_IN_TRANSACTION  NT_STATUS(0xC019005A)
     1454#define NT_STATUS_TRANSACTION_INTEGRITY_VIOLATED          NT_STATUS(0xC019005B)
     1455#define NT_STATUS_EXPIRED_HANDLE                          NT_STATUS(0xC0190060)
     1456#define NT_STATUS_TRANSACTION_NOT_ENLISTED                NT_STATUS(0xC0190061)
     1457#define NT_STATUS_LOG_SECTOR_INVALID                      NT_STATUS(0xC01A0001)
     1458#define NT_STATUS_LOG_SECTOR_PARITY_INVALID               NT_STATUS(0xC01A0002)
     1459#define NT_STATUS_LOG_SECTOR_REMAPPED                     NT_STATUS(0xC01A0003)
     1460#define NT_STATUS_LOG_BLOCK_INCOMPLETE                    NT_STATUS(0xC01A0004)
     1461#define NT_STATUS_LOG_INVALID_RANGE                       NT_STATUS(0xC01A0005)
     1462#define NT_STATUS_LOG_BLOCKS_EXHAUSTED                    NT_STATUS(0xC01A0006)
     1463#define NT_STATUS_LOG_READ_CONTEXT_INVALID                NT_STATUS(0xC01A0007)
     1464#define NT_STATUS_LOG_RESTART_INVALID                     NT_STATUS(0xC01A0008)
     1465#define NT_STATUS_LOG_BLOCK_VERSION                       NT_STATUS(0xC01A0009)
     1466#define NT_STATUS_LOG_BLOCK_INVALID                       NT_STATUS(0xC01A000A)
     1467#define NT_STATUS_LOG_READ_MODE_INVALID                   NT_STATUS(0xC01A000B)
     1468#define NT_STATUS_LOG_METADATA_CORRUPT                    NT_STATUS(0xC01A000D)
     1469#define NT_STATUS_LOG_METADATA_INVALID                    NT_STATUS(0xC01A000E)
     1470#define NT_STATUS_LOG_METADATA_INCONSISTENT               NT_STATUS(0xC01A000F)
     1471#define NT_STATUS_LOG_RESERVATION_INVALID                 NT_STATUS(0xC01A0010)
     1472#define NT_STATUS_LOG_CANT_DELETE                         NT_STATUS(0xC01A0011)
     1473#define NT_STATUS_LOG_CONTAINER_LIMIT_EXCEEDED            NT_STATUS(0xC01A0012)
     1474#define NT_STATUS_LOG_START_OF_LOG                        NT_STATUS(0xC01A0013)
     1475#define NT_STATUS_LOG_POLICY_ALREADY_INSTALLED            NT_STATUS(0xC01A0014)
     1476#define NT_STATUS_LOG_POLICY_NOT_INSTALLED                NT_STATUS(0xC01A0015)
     1477#define NT_STATUS_LOG_POLICY_INVALID                      NT_STATUS(0xC01A0016)
     1478#define NT_STATUS_LOG_POLICY_CONFLICT                     NT_STATUS(0xC01A0017)
     1479#define NT_STATUS_LOG_PINNED_ARCHIVE_TAIL                 NT_STATUS(0xC01A0018)
     1480#define NT_STATUS_LOG_RECORD_NONEXISTENT                  NT_STATUS(0xC01A0019)
     1481#define NT_STATUS_LOG_RECORDS_RESERVED_INVALID            NT_STATUS(0xC01A001A)
     1482#define NT_STATUS_LOG_SPACE_RESERVED_INVALID              NT_STATUS(0xC01A001B)
     1483#define NT_STATUS_LOG_TAIL_INVALID                        NT_STATUS(0xC01A001C)
     1484#define NT_STATUS_LOG_FULL                                NT_STATUS(0xC01A001D)
     1485#define NT_STATUS_LOG_MULTIPLEXED                         NT_STATUS(0xC01A001E)
     1486#define NT_STATUS_LOG_DEDICATED                           NT_STATUS(0xC01A001F)
     1487#define NT_STATUS_LOG_ARCHIVE_NOT_IN_PROGRESS             NT_STATUS(0xC01A0020)
     1488#define NT_STATUS_LOG_ARCHIVE_IN_PROGRESS                 NT_STATUS(0xC01A0021)
     1489#define NT_STATUS_LOG_EPHEMERAL                           NT_STATUS(0xC01A0022)
     1490#define NT_STATUS_LOG_NOT_ENOUGH_CONTAINERS               NT_STATUS(0xC01A0023)
     1491#define NT_STATUS_LOG_CLIENT_ALREADY_REGISTERED           NT_STATUS(0xC01A0024)
     1492#define NT_STATUS_LOG_CLIENT_NOT_REGISTERED               NT_STATUS(0xC01A0025)
     1493#define NT_STATUS_LOG_FULL_HANDLER_IN_PROGRESS            NT_STATUS(0xC01A0026)
     1494#define NT_STATUS_LOG_CONTAINER_READ_FAILED               NT_STATUS(0xC01A0027)
     1495#define NT_STATUS_LOG_CONTAINER_WRITE_FAILED              NT_STATUS(0xC01A0028)
     1496#define NT_STATUS_LOG_CONTAINER_OPEN_FAILED               NT_STATUS(0xC01A0029)
     1497#define NT_STATUS_LOG_CONTAINER_STATE_INVALID             NT_STATUS(0xC01A002A)
     1498#define NT_STATUS_LOG_STATE_INVALID                       NT_STATUS(0xC01A002B)
     1499#define NT_STATUS_LOG_PINNED                              NT_STATUS(0xC01A002C)
     1500#define NT_STATUS_LOG_METADATA_FLUSH_FAILED               NT_STATUS(0xC01A002D)
     1501#define NT_STATUS_LOG_INCONSISTENT_SECURITY               NT_STATUS(0xC01A002E)
     1502#define NT_STATUS_LOG_APPENDED_FLUSH_FAILED               NT_STATUS(0xC01A002F)
     1503#define NT_STATUS_LOG_PINNED_RESERVATION                  NT_STATUS(0xC01A0030)
     1504#define NT_STATUS_VIDEO_HUNG_DISPLAY_DRIVER_THREAD        NT_STATUS(0xC01B00EA)
     1505#define NT_STATUS_FLT_NO_HANDLER_DEFINED                  NT_STATUS(0xC01C0001)
     1506#define NT_STATUS_FLT_CONTEXT_ALREADY_DEFINED             NT_STATUS(0xC01C0002)
     1507#define NT_STATUS_FLT_INVALID_ASYNCHRONOUS_REQUEST        NT_STATUS(0xC01C0003)
     1508#define NT_STATUS_FLT_DISALLOW_FAST_IO                    NT_STATUS(0xC01C0004)
     1509#define NT_STATUS_FLT_INVALID_NAME_REQUEST                NT_STATUS(0xC01C0005)
     1510#define NT_STATUS_FLT_NOT_SAFE_TO_POST_OPERATION          NT_STATUS(0xC01C0006)
     1511#define NT_STATUS_FLT_NOT_INITIALIZED                     NT_STATUS(0xC01C0007)
     1512#define NT_STATUS_FLT_FILTER_NOT_READY                    NT_STATUS(0xC01C0008)
     1513#define NT_STATUS_FLT_POST_OPERATION_CLEANUP              NT_STATUS(0xC01C0009)
     1514#define NT_STATUS_FLT_INTERNAL_ERROR                      NT_STATUS(0xC01C000A)
     1515#define NT_STATUS_FLT_DELETING_OBJECT                     NT_STATUS(0xC01C000B)
     1516#define NT_STATUS_FLT_MUST_BE_NONPAGED_POOL               NT_STATUS(0xC01C000C)
     1517#define NT_STATUS_FLT_DUPLICATE_ENTRY                     NT_STATUS(0xC01C000D)
     1518#define NT_STATUS_FLT_CBDQ_DISABLED                       NT_STATUS(0xC01C000E)
     1519#define NT_STATUS_FLT_DO_NOT_ATTACH                       NT_STATUS(0xC01C000F)
     1520#define NT_STATUS_FLT_DO_NOT_DETACH                       NT_STATUS(0xC01C0010)
     1521#define NT_STATUS_FLT_INSTANCE_ALTITUDE_COLLISION         NT_STATUS(0xC01C0011)
     1522#define NT_STATUS_FLT_INSTANCE_NAME_COLLISION             NT_STATUS(0xC01C0012)
     1523#define NT_STATUS_FLT_FILTER_NOT_FOUND                    NT_STATUS(0xC01C0013)
     1524#define NT_STATUS_FLT_VOLUME_NOT_FOUND                    NT_STATUS(0xC01C0014)
     1525#define NT_STATUS_FLT_INSTANCE_NOT_FOUND                  NT_STATUS(0xC01C0015)
     1526#define NT_STATUS_FLT_CONTEXT_ALLOCATION_NOT_FOUND        NT_STATUS(0xC01C0016)
     1527#define NT_STATUS_FLT_INVALID_CONTEXT_REGISTRATION        NT_STATUS(0xC01C0017)
     1528#define NT_STATUS_FLT_NAME_CACHE_MISS                     NT_STATUS(0xC01C0018)
     1529#define NT_STATUS_FLT_NO_DEVICE_OBJECT                    NT_STATUS(0xC01C0019)
     1530#define NT_STATUS_FLT_VOLUME_ALREADY_MOUNTED              NT_STATUS(0xC01C001A)
     1531#define NT_STATUS_FLT_ALREADY_ENLISTED                    NT_STATUS(0xC01C001B)
     1532#define NT_STATUS_FLT_CONTEXT_ALREADY_LINKED              NT_STATUS(0xC01C001C)
     1533#define NT_STATUS_FLT_NO_WAITER_FOR_REPLY                 NT_STATUS(0xC01C0020)
     1534#define NT_STATUS_MONITOR_NO_DESCRIPTOR                   NT_STATUS(0xC01D0001)
     1535#define NT_STATUS_MONITOR_UNKNOWN_DESCRIPTOR_FORMAT       NT_STATUS(0xC01D0002)
     1536#define NT_STATUS_MONITOR_INVALID_DESCRIPTOR_CHECKSUM     NT_STATUS(0xC01D0003)
     1537#define NT_STATUS_MONITOR_INVALID_STANDARD_TIMING_BLOCK   NT_STATUS(0xC01D0004)
     1538#define NT_STATUS_MONITOR_WMI_DATABLOCK_REGISTRATION_FAILED NT_STATUS(0xC01D0005)
     1539#define NT_STATUS_MONITOR_INVALID_SERIAL_NUMBER_MONDSC_BLOCK NT_STATUS(0xC01D0006)
     1540#define NT_STATUS_MONITOR_INVALID_USER_FRIENDLY_MONDSC_BLOCK NT_STATUS(0xC01D0007)
     1541#define NT_STATUS_MONITOR_NO_MORE_DESCRIPTOR_DATA         NT_STATUS(0xC01D0008)
     1542#define NT_STATUS_MONITOR_INVALID_DETAILED_TIMING_BLOCK   NT_STATUS(0xC01D0009)
     1543#define NT_STATUS_MONITOR_INVALID_MANUFACTURE_DATE        NT_STATUS(0xC01D000A)
     1544#define NT_STATUS_GRAPHICS_NOT_EXCLUSIVE_MODE_OWNER       NT_STATUS(0xC01E0000)
     1545#define NT_STATUS_GRAPHICS_INSUFFICIENT_DMA_BUFFER        NT_STATUS(0xC01E0001)
     1546#define NT_STATUS_GRAPHICS_INVALID_DISPLAY_ADAPTER        NT_STATUS(0xC01E0002)
     1547#define NT_STATUS_GRAPHICS_ADAPTER_WAS_RESET              NT_STATUS(0xC01E0003)
     1548#define NT_STATUS_GRAPHICS_INVALID_DRIVER_MODEL           NT_STATUS(0xC01E0004)
     1549#define NT_STATUS_GRAPHICS_PRESENT_MODE_CHANGED           NT_STATUS(0xC01E0005)
     1550#define NT_STATUS_GRAPHICS_PRESENT_OCCLUDED               NT_STATUS(0xC01E0006)
     1551#define NT_STATUS_GRAPHICS_PRESENT_DENIED                 NT_STATUS(0xC01E0007)
     1552#define NT_STATUS_GRAPHICS_CANNOTCOLORCONVERT             NT_STATUS(0xC01E0008)
     1553#define NT_STATUS_GRAPHICS_PRESENT_REDIRECTION_DISABLED   NT_STATUS(0xC01E000B)
     1554#define NT_STATUS_GRAPHICS_PRESENT_UNOCCLUDED             NT_STATUS(0xC01E000C)
     1555#define NT_STATUS_GRAPHICS_NO_VIDEO_MEMORY                NT_STATUS(0xC01E0100)
     1556#define NT_STATUS_GRAPHICS_CANT_LOCK_MEMORY               NT_STATUS(0xC01E0101)
     1557#define NT_STATUS_GRAPHICS_ALLOCATION_BUSY                NT_STATUS(0xC01E0102)
     1558#define NT_STATUS_GRAPHICS_TOO_MANY_REFERENCES            NT_STATUS(0xC01E0103)
     1559#define NT_STATUS_GRAPHICS_TRY_AGAIN_LATER                NT_STATUS(0xC01E0104)
     1560#define NT_STATUS_GRAPHICS_TRY_AGAIN_NOW                  NT_STATUS(0xC01E0105)
     1561#define NT_STATUS_GRAPHICS_ALLOCATION_INVALID             NT_STATUS(0xC01E0106)
     1562#define NT_STATUS_GRAPHICS_UNSWIZZLING_APERTURE_UNAVAILABLE NT_STATUS(0xC01E0107)
     1563#define NT_STATUS_GRAPHICS_UNSWIZZLING_APERTURE_UNSUPPORTED NT_STATUS(0xC01E0108)
     1564#define NT_STATUS_GRAPHICS_CANT_EVICT_PINNED_ALLOCATION   NT_STATUS(0xC01E0109)
     1565#define NT_STATUS_GRAPHICS_INVALID_ALLOCATION_USAGE       NT_STATUS(0xC01E0110)
     1566#define NT_STATUS_GRAPHICS_CANT_RENDER_LOCKED_ALLOCATION  NT_STATUS(0xC01E0111)
     1567#define NT_STATUS_GRAPHICS_ALLOCATION_CLOSED              NT_STATUS(0xC01E0112)
     1568#define NT_STATUS_GRAPHICS_INVALID_ALLOCATION_INSTANCE    NT_STATUS(0xC01E0113)
     1569#define NT_STATUS_GRAPHICS_INVALID_ALLOCATION_HANDLE      NT_STATUS(0xC01E0114)
     1570#define NT_STATUS_GRAPHICS_WRONG_ALLOCATION_DEVICE        NT_STATUS(0xC01E0115)
     1571#define NT_STATUS_GRAPHICS_ALLOCATION_CONTENT_LOST        NT_STATUS(0xC01E0116)
     1572#define NT_STATUS_GRAPHICS_GPU_EXCEPTION_ON_DEVICE        NT_STATUS(0xC01E0200)
     1573#define NT_STATUS_GRAPHICS_INVALID_VIDPN_TOPOLOGY         NT_STATUS(0xC01E0300)
     1574#define NT_STATUS_GRAPHICS_VIDPN_TOPOLOGY_NOT_SUPPORTED   NT_STATUS(0xC01E0301)
     1575#define NT_STATUS_GRAPHICS_VIDPN_TOPOLOGY_CURRENTLY_NOT_SUPPORTED NT_STATUS(0xC01E0302)
     1576#define NT_STATUS_GRAPHICS_INVALID_VIDPN                  NT_STATUS(0xC01E0303)
     1577#define NT_STATUS_GRAPHICS_INVALID_VIDEO_PRESENT_SOURCE   NT_STATUS(0xC01E0304)
     1578#define NT_STATUS_GRAPHICS_INVALID_VIDEO_PRESENT_TARGET   NT_STATUS(0xC01E0305)
     1579#define NT_STATUS_GRAPHICS_VIDPN_MODALITY_NOT_SUPPORTED   NT_STATUS(0xC01E0306)
     1580#define NT_STATUS_GRAPHICS_INVALID_VIDPN_SOURCEMODESET    NT_STATUS(0xC01E0308)
     1581#define NT_STATUS_GRAPHICS_INVALID_VIDPN_TARGETMODESET    NT_STATUS(0xC01E0309)
     1582#define NT_STATUS_GRAPHICS_INVALID_FREQUENCY              NT_STATUS(0xC01E030A)
     1583#define NT_STATUS_GRAPHICS_INVALID_ACTIVE_REGION          NT_STATUS(0xC01E030B)
     1584#define NT_STATUS_GRAPHICS_INVALID_TOTAL_REGION           NT_STATUS(0xC01E030C)
     1585#define NT_STATUS_GRAPHICS_INVALID_VIDEO_PRESENT_SOURCE_MODE NT_STATUS(0xC01E0310)
     1586#define NT_STATUS_GRAPHICS_INVALID_VIDEO_PRESENT_TARGET_MODE NT_STATUS(0xC01E0311)
     1587#define NT_STATUS_GRAPHICS_PINNED_MODE_MUST_REMAIN_IN_SET NT_STATUS(0xC01E0312)
     1588#define NT_STATUS_GRAPHICS_PATH_ALREADY_IN_TOPOLOGY       NT_STATUS(0xC01E0313)
     1589#define NT_STATUS_GRAPHICS_MODE_ALREADY_IN_MODESET        NT_STATUS(0xC01E0314)
     1590#define NT_STATUS_GRAPHICS_INVALID_VIDEOPRESENTSOURCESET  NT_STATUS(0xC01E0315)
     1591#define NT_STATUS_GRAPHICS_INVALID_VIDEOPRESENTTARGETSET  NT_STATUS(0xC01E0316)
     1592#define NT_STATUS_GRAPHICS_SOURCE_ALREADY_IN_SET          NT_STATUS(0xC01E0317)
     1593#define NT_STATUS_GRAPHICS_TARGET_ALREADY_IN_SET          NT_STATUS(0xC01E0318)
     1594#define NT_STATUS_GRAPHICS_INVALID_VIDPN_PRESENT_PATH     NT_STATUS(0xC01E0319)
     1595#define NT_STATUS_GRAPHICS_NO_RECOMMENDED_VIDPN_TOPOLOGY  NT_STATUS(0xC01E031A)
     1596#define NT_STATUS_GRAPHICS_INVALID_MONITOR_FREQUENCYRANGESET NT_STATUS(0xC01E031B)
     1597#define NT_STATUS_GRAPHICS_INVALID_MONITOR_FREQUENCYRANGE NT_STATUS(0xC01E031C)
     1598#define NT_STATUS_GRAPHICS_FREQUENCYRANGE_NOT_IN_SET      NT_STATUS(0xC01E031D)
     1599#define NT_STATUS_GRAPHICS_FREQUENCYRANGE_ALREADY_IN_SET  NT_STATUS(0xC01E031F)
     1600#define NT_STATUS_GRAPHICS_STALE_MODESET                  NT_STATUS(0xC01E0320)
     1601#define NT_STATUS_GRAPHICS_INVALID_MONITOR_SOURCEMODESET  NT_STATUS(0xC01E0321)
     1602#define NT_STATUS_GRAPHICS_INVALID_MONITOR_SOURCE_MODE    NT_STATUS(0xC01E0322)
     1603#define NT_STATUS_GRAPHICS_NO_RECOMMENDED_FUNCTIONAL_VIDPN NT_STATUS(0xC01E0323)
     1604#define NT_STATUS_GRAPHICS_MODE_ID_MUST_BE_UNIQUE         NT_STATUS(0xC01E0324)
     1605#define NT_STATUS_GRAPHICS_EMPTY_ADAPTER_MONITOR_MODE_SUPPORT_INTERSECTION NT_STATUS(0xC01E0325)
     1606#define NT_STATUS_GRAPHICS_VIDEO_PRESENT_TARGETS_LESS_THAN_SOURCES NT_STATUS(0xC01E0326)
     1607#define NT_STATUS_GRAPHICS_PATH_NOT_IN_TOPOLOGY           NT_STATUS(0xC01E0327)
     1608#define NT_STATUS_GRAPHICS_ADAPTER_MUST_HAVE_AT_LEAST_ONE_SOURCE NT_STATUS(0xC01E0328)
     1609#define NT_STATUS_GRAPHICS_ADAPTER_MUST_HAVE_AT_LEAST_ONE_TARGET NT_STATUS(0xC01E0329)
     1610#define NT_STATUS_GRAPHICS_INVALID_MONITORDESCRIPTORSET   NT_STATUS(0xC01E032A)
     1611#define NT_STATUS_GRAPHICS_INVALID_MONITORDESCRIPTOR      NT_STATUS(0xC01E032B)
     1612#define NT_STATUS_GRAPHICS_MONITORDESCRIPTOR_NOT_IN_SET   NT_STATUS(0xC01E032C)
     1613#define NT_STATUS_GRAPHICS_MONITORDESCRIPTOR_ALREADY_IN_SET NT_STATUS(0xC01E032D)
     1614#define NT_STATUS_GRAPHICS_MONITORDESCRIPTOR_ID_MUST_BE_UNIQUE NT_STATUS(0xC01E032E)
     1615#define NT_STATUS_GRAPHICS_INVALID_VIDPN_TARGET_SUBSET_TYPE NT_STATUS(0xC01E032F)
     1616#define NT_STATUS_GRAPHICS_RESOURCES_NOT_RELATED          NT_STATUS(0xC01E0330)
     1617#define NT_STATUS_GRAPHICS_SOURCE_ID_MUST_BE_UNIQUE       NT_STATUS(0xC01E0331)
     1618#define NT_STATUS_GRAPHICS_TARGET_ID_MUST_BE_UNIQUE       NT_STATUS(0xC01E0332)
     1619#define NT_STATUS_GRAPHICS_NO_AVAILABLE_VIDPN_TARGET      NT_STATUS(0xC01E0333)
     1620#define NT_STATUS_GRAPHICS_MONITOR_COULD_NOT_BE_ASSOCIATED_WITH_ADAPTER NT_STATUS(0xC01E0334)
     1621#define NT_STATUS_GRAPHICS_NO_VIDPNMGR                    NT_STATUS(0xC01E0335)
     1622#define NT_STATUS_GRAPHICS_NO_ACTIVE_VIDPN                NT_STATUS(0xC01E0336)
     1623#define NT_STATUS_GRAPHICS_STALE_VIDPN_TOPOLOGY           NT_STATUS(0xC01E0337)
     1624#define NT_STATUS_GRAPHICS_MONITOR_NOT_CONNECTED          NT_STATUS(0xC01E0338)
     1625#define NT_STATUS_GRAPHICS_SOURCE_NOT_IN_TOPOLOGY         NT_STATUS(0xC01E0339)
     1626#define NT_STATUS_GRAPHICS_INVALID_PRIMARYSURFACE_SIZE    NT_STATUS(0xC01E033A)
     1627#define NT_STATUS_GRAPHICS_INVALID_VISIBLEREGION_SIZE     NT_STATUS(0xC01E033B)
     1628#define NT_STATUS_GRAPHICS_INVALID_STRIDE                 NT_STATUS(0xC01E033C)
     1629#define NT_STATUS_GRAPHICS_INVALID_PIXELFORMAT            NT_STATUS(0xC01E033D)
     1630#define NT_STATUS_GRAPHICS_INVALID_COLORBASIS             NT_STATUS(0xC01E033E)
     1631#define NT_STATUS_GRAPHICS_INVALID_PIXELVALUEACCESSMODE   NT_STATUS(0xC01E033F)
     1632#define NT_STATUS_GRAPHICS_TARGET_NOT_IN_TOPOLOGY         NT_STATUS(0xC01E0340)
     1633#define NT_STATUS_GRAPHICS_NO_DISPLAY_MODE_MANAGEMENT_SUPPORT NT_STATUS(0xC01E0341)
     1634#define NT_STATUS_GRAPHICS_VIDPN_SOURCE_IN_USE            NT_STATUS(0xC01E0342)
     1635#define NT_STATUS_GRAPHICS_CANT_ACCESS_ACTIVE_VIDPN       NT_STATUS(0xC01E0343)
     1636#define NT_STATUS_GRAPHICS_INVALID_PATH_IMPORTANCE_ORDINAL NT_STATUS(0xC01E0344)
     1637#define NT_STATUS_GRAPHICS_INVALID_PATH_CONTENT_GEOMETRY_TRANSFORMATION NT_STATUS(0xC01E0345)
     1638#define NT_STATUS_GRAPHICS_PATH_CONTENT_GEOMETRY_TRANSFORMATION_NOT_SUPPORTED NT_STATUS(0xC01E0346)
     1639#define NT_STATUS_GRAPHICS_INVALID_GAMMA_RAMP             NT_STATUS(0xC01E0347)
     1640#define NT_STATUS_GRAPHICS_GAMMA_RAMP_NOT_SUPPORTED       NT_STATUS(0xC01E0348)
     1641#define NT_STATUS_GRAPHICS_MULTISAMPLING_NOT_SUPPORTED    NT_STATUS(0xC01E0349)
     1642#define NT_STATUS_GRAPHICS_MODE_NOT_IN_MODESET            NT_STATUS(0xC01E034A)
     1643#define NT_STATUS_GRAPHICS_INVALID_VIDPN_TOPOLOGY_RECOMMENDATION_REASON NT_STATUS(0xC01E034D)
     1644#define NT_STATUS_GRAPHICS_INVALID_PATH_CONTENT_TYPE      NT_STATUS(0xC01E034E)
     1645#define NT_STATUS_GRAPHICS_INVALID_COPYPROTECTION_TYPE    NT_STATUS(0xC01E034F)
     1646#define NT_STATUS_GRAPHICS_UNASSIGNED_MODESET_ALREADY_EXISTS NT_STATUS(0xC01E0350)
     1647#define NT_STATUS_GRAPHICS_INVALID_SCANLINE_ORDERING      NT_STATUS(0xC01E0352)
     1648#define NT_STATUS_GRAPHICS_TOPOLOGY_CHANGES_NOT_ALLOWED   NT_STATUS(0xC01E0353)
     1649#define NT_STATUS_GRAPHICS_NO_AVAILABLE_IMPORTANCE_ORDINALS NT_STATUS(0xC01E0354)
     1650#define NT_STATUS_GRAPHICS_INCOMPATIBLE_PRIVATE_FORMAT    NT_STATUS(0xC01E0355)
     1651#define NT_STATUS_GRAPHICS_INVALID_MODE_PRUNING_ALGORITHM NT_STATUS(0xC01E0356)
     1652#define NT_STATUS_GRAPHICS_INVALID_MONITOR_CAPABILITY_ORIGIN NT_STATUS(0xC01E0357)
     1653#define NT_STATUS_GRAPHICS_INVALID_MONITOR_FREQUENCYRANGE_CONSTRAINT NT_STATUS(0xC01E0358)
     1654#define NT_STATUS_GRAPHICS_MAX_NUM_PATHS_REACHED          NT_STATUS(0xC01E0359)
     1655#define NT_STATUS_GRAPHICS_CANCEL_VIDPN_TOPOLOGY_AUGMENTATION NT_STATUS(0xC01E035A)
     1656#define NT_STATUS_GRAPHICS_INVALID_CLIENT_TYPE            NT_STATUS(0xC01E035B)
     1657#define NT_STATUS_GRAPHICS_CLIENTVIDPN_NOT_SET            NT_STATUS(0xC01E035C)
     1658#define NT_STATUS_GRAPHICS_SPECIFIED_CHILD_ALREADY_CONNECTED NT_STATUS(0xC01E0400)
     1659#define NT_STATUS_GRAPHICS_CHILD_DESCRIPTOR_NOT_SUPPORTED NT_STATUS(0xC01E0401)
     1660#define NT_STATUS_GRAPHICS_NOT_A_LINKED_ADAPTER           NT_STATUS(0xC01E0430)
     1661#define NT_STATUS_GRAPHICS_LEADLINK_NOT_ENUMERATED        NT_STATUS(0xC01E0431)
     1662#define NT_STATUS_GRAPHICS_CHAINLINKS_NOT_ENUMERATED      NT_STATUS(0xC01E0432)
     1663#define NT_STATUS_GRAPHICS_ADAPTER_CHAIN_NOT_READY        NT_STATUS(0xC01E0433)
     1664#define NT_STATUS_GRAPHICS_CHAINLINKS_NOT_STARTED         NT_STATUS(0xC01E0434)
     1665#define NT_STATUS_GRAPHICS_CHAINLINKS_NOT_POWERED_ON      NT_STATUS(0xC01E0435)
     1666#define NT_STATUS_GRAPHICS_INCONSISTENT_DEVICE_LINK_STATE NT_STATUS(0xC01E0436)
     1667#define NT_STATUS_GRAPHICS_NOT_POST_DEVICE_DRIVER         NT_STATUS(0xC01E0438)
     1668#define NT_STATUS_GRAPHICS_ADAPTER_ACCESS_NOT_EXCLUDED    NT_STATUS(0xC01E043B)
     1669#define NT_STATUS_GRAPHICS_OPM_NOT_SUPPORTED              NT_STATUS(0xC01E0500)
     1670#define NT_STATUS_GRAPHICS_COPP_NOT_SUPPORTED             NT_STATUS(0xC01E0501)
     1671#define NT_STATUS_GRAPHICS_UAB_NOT_SUPPORTED              NT_STATUS(0xC01E0502)
     1672#define NT_STATUS_GRAPHICS_OPM_INVALID_ENCRYPTED_PARAMETERS NT_STATUS(0xC01E0503)
     1673#define NT_STATUS_GRAPHICS_OPM_PARAMETER_ARRAY_TOO_SMALL  NT_STATUS(0xC01E0504)
     1674#define NT_STATUS_GRAPHICS_OPM_NO_PROTECTED_OUTPUTS_EXIST NT_STATUS(0xC01E0505)
     1675#define NT_STATUS_GRAPHICS_PVP_NO_DISPLAY_DEVICE_CORRESPONDS_TO_NAME NT_STATUS(0xC01E0506)
     1676#define NT_STATUS_GRAPHICS_PVP_DISPLAY_DEVICE_NOT_ATTACHED_TO_DESKTOP NT_STATUS(0xC01E0507)
     1677#define NT_STATUS_GRAPHICS_PVP_MIRRORING_DEVICES_NOT_SUPPORTED NT_STATUS(0xC01E0508)
     1678#define NT_STATUS_GRAPHICS_OPM_INVALID_POINTER            NT_STATUS(0xC01E050A)
     1679#define NT_STATUS_GRAPHICS_OPM_INTERNAL_ERROR             NT_STATUS(0xC01E050B)
     1680#define NT_STATUS_GRAPHICS_OPM_INVALID_HANDLE             NT_STATUS(0xC01E050C)
     1681#define NT_STATUS_GRAPHICS_PVP_NO_MONITORS_CORRESPOND_TO_DISPLAY_DEVICE NT_STATUS(0xC01E050D)
     1682#define NT_STATUS_GRAPHICS_PVP_INVALID_CERTIFICATE_LENGTH NT_STATUS(0xC01E050E)
     1683#define NT_STATUS_GRAPHICS_OPM_SPANNING_MODE_ENABLED      NT_STATUS(0xC01E050F)
     1684#define NT_STATUS_GRAPHICS_OPM_THEATER_MODE_ENABLED       NT_STATUS(0xC01E0510)
     1685#define NT_STATUS_GRAPHICS_PVP_HFS_FAILED                 NT_STATUS(0xC01E0511)
     1686#define NT_STATUS_GRAPHICS_OPM_INVALID_SRM                NT_STATUS(0xC01E0512)
     1687#define NT_STATUS_GRAPHICS_OPM_OUTPUT_DOES_NOT_SUPPORT_HDCP NT_STATUS(0xC01E0513)
     1688#define NT_STATUS_GRAPHICS_OPM_OUTPUT_DOES_NOT_SUPPORT_ACP NT_STATUS(0xC01E0514)
     1689#define NT_STATUS_GRAPHICS_OPM_OUTPUT_DOES_NOT_SUPPORT_CGMSA NT_STATUS(0xC01E0515)
     1690#define NT_STATUS_GRAPHICS_OPM_HDCP_SRM_NEVER_SET         NT_STATUS(0xC01E0516)
     1691#define NT_STATUS_GRAPHICS_OPM_RESOLUTION_TOO_HIGH        NT_STATUS(0xC01E0517)
     1692#define NT_STATUS_GRAPHICS_OPM_ALL_HDCP_HARDWARE_ALREADY_IN_USE NT_STATUS(0xC01E0518)
     1693#define NT_STATUS_GRAPHICS_OPM_PROTECTED_OUTPUT_NO_LONGER_EXISTS NT_STATUS(0xC01E051A)
     1694#define NT_STATUS_GRAPHICS_OPM_SESSION_TYPE_CHANGE_IN_PROGRESS NT_STATUS(0xC01E051B)
     1695#define NT_STATUS_GRAPHICS_OPM_PROTECTED_OUTPUT_DOES_NOT_HAVE_COPP_SEMANTICS NT_STATUS(0xC01E051C)
     1696#define NT_STATUS_GRAPHICS_OPM_INVALID_INFORMATION_REQUEST NT_STATUS(0xC01E051D)
     1697#define NT_STATUS_GRAPHICS_OPM_DRIVER_INTERNAL_ERROR      NT_STATUS(0xC01E051E)
     1698#define NT_STATUS_GRAPHICS_OPM_PROTECTED_OUTPUT_DOES_NOT_HAVE_OPM_SEMANTICS NT_STATUS(0xC01E051F)
     1699#define NT_STATUS_GRAPHICS_OPM_SIGNALING_NOT_SUPPORTED    NT_STATUS(0xC01E0520)
     1700#define NT_STATUS_GRAPHICS_OPM_INVALID_CONFIGURATION_REQUEST NT_STATUS(0xC01E0521)
     1701#define NT_STATUS_GRAPHICS_I2C_NOT_SUPPORTED              NT_STATUS(0xC01E0580)
     1702#define NT_STATUS_GRAPHICS_I2C_DEVICE_DOES_NOT_EXIST      NT_STATUS(0xC01E0581)
     1703#define NT_STATUS_GRAPHICS_I2C_ERROR_TRANSMITTING_DATA    NT_STATUS(0xC01E0582)
     1704#define NT_STATUS_GRAPHICS_I2C_ERROR_RECEIVING_DATA       NT_STATUS(0xC01E0583)
     1705#define NT_STATUS_GRAPHICS_DDCCI_VCP_NOT_SUPPORTED        NT_STATUS(0xC01E0584)
     1706#define NT_STATUS_GRAPHICS_DDCCI_INVALID_DATA             NT_STATUS(0xC01E0585)
     1707#define NT_STATUS_GRAPHICS_DDCCI_MONITOR_RETURNED_INVALID_TIMING_STATUS_BYTE NT_STATUS(0xC01E0586)
     1708#define NT_STATUS_GRAPHICS_DDCCI_INVALID_CAPABILITIES_STRING NT_STATUS(0xC01E0587)
     1709#define NT_STATUS_GRAPHICS_MCA_INTERNAL_ERROR             NT_STATUS(0xC01E0588)
     1710#define NT_STATUS_GRAPHICS_DDCCI_INVALID_MESSAGE_COMMAND  NT_STATUS(0xC01E0589)
     1711#define NT_STATUS_GRAPHICS_DDCCI_INVALID_MESSAGE_LENGTH   NT_STATUS(0xC01E058A)
     1712#define NT_STATUS_GRAPHICS_DDCCI_INVALID_MESSAGE_CHECKSUM NT_STATUS(0xC01E058B)
     1713#define NT_STATUS_GRAPHICS_INVALID_PHYSICAL_MONITOR_HANDLE NT_STATUS(0xC01E058C)
     1714#define NT_STATUS_GRAPHICS_MONITOR_NO_LONGER_EXISTS       NT_STATUS(0xC01E058D)
     1715#define NT_STATUS_GRAPHICS_ONLY_CONSOLE_SESSION_SUPPORTED NT_STATUS(0xC01E05E0)
     1716#define NT_STATUS_GRAPHICS_NO_DISPLAY_DEVICE_CORRESPONDS_TO_NAME NT_STATUS(0xC01E05E1)
     1717#define NT_STATUS_GRAPHICS_DISPLAY_DEVICE_NOT_ATTACHED_TO_DESKTOP NT_STATUS(0xC01E05E2)
     1718#define NT_STATUS_GRAPHICS_MIRRORING_DEVICES_NOT_SUPPORTED NT_STATUS(0xC01E05E3)
     1719#define NT_STATUS_GRAPHICS_INVALID_POINTER                NT_STATUS(0xC01E05E4)
     1720#define NT_STATUS_GRAPHICS_NO_MONITORS_CORRESPOND_TO_DISPLAY_DEVICE NT_STATUS(0xC01E05E5)
     1721#define NT_STATUS_GRAPHICS_PARAMETER_ARRAY_TOO_SMALL      NT_STATUS(0xC01E05E6)
     1722#define NT_STATUS_GRAPHICS_INTERNAL_ERROR                 NT_STATUS(0xC01E05E7)
     1723#define NT_STATUS_GRAPHICS_SESSION_TYPE_CHANGE_IN_PROGRESS NT_STATUS(0xC01E05E8)
     1724#define NT_STATUS_FVE_LOCKED_VOLUME                       NT_STATUS(0xC0210000)
     1725#define NT_STATUS_FVE_NOT_ENCRYPTED                       NT_STATUS(0xC0210001)
     1726#define NT_STATUS_FVE_BAD_INFORMATION                     NT_STATUS(0xC0210002)
     1727#define NT_STATUS_FVE_TOO_SMALL                           NT_STATUS(0xC0210003)
     1728#define NT_STATUS_FVE_FAILED_WRONG_FS                     NT_STATUS(0xC0210004)
     1729#define NT_STATUS_FVE_FAILED_BAD_FS                       NT_STATUS(0xC0210005)
     1730#define NT_STATUS_FVE_FS_NOT_EXTENDED                     NT_STATUS(0xC0210006)
     1731#define NT_STATUS_FVE_FS_MOUNTED                          NT_STATUS(0xC0210007)
     1732#define NT_STATUS_FVE_NO_LICENSE                          NT_STATUS(0xC0210008)
     1733#define NT_STATUS_FVE_ACTION_NOT_ALLOWED                  NT_STATUS(0xC0210009)
     1734#define NT_STATUS_FVE_BAD_DATA                            NT_STATUS(0xC021000A)
     1735#define NT_STATUS_FVE_VOLUME_NOT_BOUND                    NT_STATUS(0xC021000B)
     1736#define NT_STATUS_FVE_NOT_DATA_VOLUME                     NT_STATUS(0xC021000C)
     1737#define NT_STATUS_FVE_CONV_READ_ERROR                     NT_STATUS(0xC021000D)
     1738#define NT_STATUS_FVE_CONV_WRITE_ERROR                    NT_STATUS(0xC021000E)
     1739#define NT_STATUS_FVE_OVERLAPPED_UPDATE                   NT_STATUS(0xC021000F)
     1740#define NT_STATUS_FVE_FAILED_SECTOR_SIZE                  NT_STATUS(0xC0210010)
     1741#define NT_STATUS_FVE_FAILED_AUTHENTICATION               NT_STATUS(0xC0210011)
     1742#define NT_STATUS_FVE_NOT_OS_VOLUME                       NT_STATUS(0xC0210012)
     1743#define NT_STATUS_FVE_KEYFILE_NOT_FOUND                   NT_STATUS(0xC0210013)
     1744#define NT_STATUS_FVE_KEYFILE_INVALID                     NT_STATUS(0xC0210014)
     1745#define NT_STATUS_FVE_KEYFILE_NO_VMK                      NT_STATUS(0xC0210015)
     1746#define NT_STATUS_FVE_TPM_DISABLED                        NT_STATUS(0xC0210016)
     1747#define NT_STATUS_FVE_TPM_SRK_AUTH_NOT_ZERO               NT_STATUS(0xC0210017)
     1748#define NT_STATUS_FVE_TPM_INVALID_PCR                     NT_STATUS(0xC0210018)
     1749#define NT_STATUS_FVE_TPM_NO_VMK                          NT_STATUS(0xC0210019)
     1750#define NT_STATUS_FVE_PIN_INVALID                         NT_STATUS(0xC021001A)
     1751#define NT_STATUS_FVE_AUTH_INVALID_APPLICATION            NT_STATUS(0xC021001B)
     1752#define NT_STATUS_FVE_AUTH_INVALID_CONFIG                 NT_STATUS(0xC021001C)
     1753#define NT_STATUS_FVE_DEBUGGER_ENABLED                    NT_STATUS(0xC021001D)
     1754#define NT_STATUS_FVE_DRY_RUN_FAILED                      NT_STATUS(0xC021001E)
     1755#define NT_STATUS_FVE_BAD_METADATA_POINTER                NT_STATUS(0xC021001F)
     1756#define NT_STATUS_FVE_OLD_METADATA_COPY                   NT_STATUS(0xC0210020)
     1757#define NT_STATUS_FVE_REBOOT_REQUIRED                     NT_STATUS(0xC0210021)
     1758#define NT_STATUS_FVE_RAW_ACCESS                          NT_STATUS(0xC0210022)
     1759#define NT_STATUS_FVE_RAW_BLOCKED                         NT_STATUS(0xC0210023)
     1760#define NT_STATUS_FVE_NO_FEATURE_LICENSE                  NT_STATUS(0xC0210026)
     1761#define NT_STATUS_FVE_POLICY_USER_DISABLE_RDV_NOT_ALLOWED NT_STATUS(0xC0210027)
     1762#define NT_STATUS_FVE_CONV_RECOVERY_FAILED                NT_STATUS(0xC0210028)
     1763#define NT_STATUS_FVE_VIRTUALIZED_SPACE_TOO_BIG           NT_STATUS(0xC0210029)
     1764#define NT_STATUS_FVE_VOLUME_TOO_SMALL                    NT_STATUS(0xC0210030)
     1765#define NT_STATUS_FWP_CALLOUT_NOT_FOUND                   NT_STATUS(0xC0220001)
     1766#define NT_STATUS_FWP_CONDITION_NOT_FOUND                 NT_STATUS(0xC0220002)
     1767#define NT_STATUS_FWP_FILTER_NOT_FOUND                    NT_STATUS(0xC0220003)
     1768#define NT_STATUS_FWP_LAYER_NOT_FOUND                     NT_STATUS(0xC0220004)
     1769#define NT_STATUS_FWP_PROVIDER_NOT_FOUND                  NT_STATUS(0xC0220005)
     1770#define NT_STATUS_FWP_PROVIDER_CONTEXT_NOT_FOUND          NT_STATUS(0xC0220006)
     1771#define NT_STATUS_FWP_SUBLAYER_NOT_FOUND                  NT_STATUS(0xC0220007)
     1772#define NT_STATUS_FWP_NOT_FOUND                           NT_STATUS(0xC0220008)
     1773#define NT_STATUS_FWP_ALREADY_EXISTS                      NT_STATUS(0xC0220009)
     1774#define NT_STATUS_FWP_IN_USE                              NT_STATUS(0xC022000A)
     1775#define NT_STATUS_FWP_DYNAMIC_SESSION_IN_PROGRESS         NT_STATUS(0xC022000B)
     1776#define NT_STATUS_FWP_WRONG_SESSION                       NT_STATUS(0xC022000C)
     1777#define NT_STATUS_FWP_NO_TXN_IN_PROGRESS                  NT_STATUS(0xC022000D)
     1778#define NT_STATUS_FWP_TXN_IN_PROGRESS                     NT_STATUS(0xC022000E)
     1779#define NT_STATUS_FWP_TXN_ABORTED                         NT_STATUS(0xC022000F)
     1780#define NT_STATUS_FWP_SESSION_ABORTED                     NT_STATUS(0xC0220010)
     1781#define NT_STATUS_FWP_INCOMPATIBLE_TXN                    NT_STATUS(0xC0220011)
     1782#define NT_STATUS_FWP_TIMEOUT                             NT_STATUS(0xC0220012)
     1783#define NT_STATUS_FWP_NET_EVENTS_DISABLED                 NT_STATUS(0xC0220013)
     1784#define NT_STATUS_FWP_INCOMPATIBLE_LAYER                  NT_STATUS(0xC0220014)
     1785#define NT_STATUS_FWP_KM_CLIENTS_ONLY                     NT_STATUS(0xC0220015)
     1786#define NT_STATUS_FWP_LIFETIME_MISMATCH                   NT_STATUS(0xC0220016)
     1787#define NT_STATUS_FWP_BUILTIN_OBJECT                      NT_STATUS(0xC0220017)
     1788#define NT_STATUS_FWP_TOO_MANY_BOOTTIME_FILTERS           NT_STATUS(0xC0220018)
     1789#define NT_STATUS_FWP_TOO_MANY_CALLOUTS                   NT_STATUS(0xC0220018)
     1790#define NT_STATUS_FWP_NOTIFICATION_DROPPED                NT_STATUS(0xC0220019)
     1791#define NT_STATUS_FWP_TRAFFIC_MISMATCH                    NT_STATUS(0xC022001A)
     1792#define NT_STATUS_FWP_INCOMPATIBLE_SA_STATE               NT_STATUS(0xC022001B)
     1793#define NT_STATUS_FWP_NULL_POINTER                        NT_STATUS(0xC022001C)
     1794#define NT_STATUS_FWP_INVALID_ENUMERATOR                  NT_STATUS(0xC022001D)
     1795#define NT_STATUS_FWP_INVALID_FLAGS                       NT_STATUS(0xC022001E)
     1796#define NT_STATUS_FWP_INVALID_NET_MASK                    NT_STATUS(0xC022001F)
     1797#define NT_STATUS_FWP_INVALID_RANGE                       NT_STATUS(0xC0220020)
     1798#define NT_STATUS_FWP_INVALID_INTERVAL                    NT_STATUS(0xC0220021)
     1799#define NT_STATUS_FWP_ZERO_LENGTH_ARRAY                   NT_STATUS(0xC0220022)
     1800#define NT_STATUS_FWP_NULL_DISPLAY_NAME                   NT_STATUS(0xC0220023)
     1801#define NT_STATUS_FWP_INVALID_ACTION_TYPE                 NT_STATUS(0xC0220024)
     1802#define NT_STATUS_FWP_INVALID_WEIGHT                      NT_STATUS(0xC0220025)
     1803#define NT_STATUS_FWP_MATCH_TYPE_MISMATCH                 NT_STATUS(0xC0220026)
     1804#define NT_STATUS_FWP_TYPE_MISMATCH                       NT_STATUS(0xC0220027)
     1805#define NT_STATUS_FWP_OUT_OF_BOUNDS                       NT_STATUS(0xC0220028)
     1806#define NT_STATUS_FWP_RESERVED                            NT_STATUS(0xC0220029)
     1807#define NT_STATUS_FWP_DUPLICATE_CONDITION                 NT_STATUS(0xC022002A)
     1808#define NT_STATUS_FWP_DUPLICATE_KEYMOD                    NT_STATUS(0xC022002B)
     1809#define NT_STATUS_FWP_ACTION_INCOMPATIBLE_WITH_LAYER      NT_STATUS(0xC022002C)
     1810#define NT_STATUS_FWP_ACTION_INCOMPATIBLE_WITH_SUBLAYER   NT_STATUS(0xC022002D)
     1811#define NT_STATUS_FWP_CONTEXT_INCOMPATIBLE_WITH_LAYER     NT_STATUS(0xC022002E)
     1812#define NT_STATUS_FWP_CONTEXT_INCOMPATIBLE_WITH_CALLOUT   NT_STATUS(0xC022002F)
     1813#define NT_STATUS_FWP_INCOMPATIBLE_AUTH_METHOD            NT_STATUS(0xC0220030)
     1814#define NT_STATUS_FWP_INCOMPATIBLE_DH_GROUP               NT_STATUS(0xC0220031)
     1815#define NT_STATUS_FWP_EM_NOT_SUPPORTED                    NT_STATUS(0xC0220032)
     1816#define NT_STATUS_FWP_NEVER_MATCH                         NT_STATUS(0xC0220033)
     1817#define NT_STATUS_FWP_PROVIDER_CONTEXT_MISMATCH           NT_STATUS(0xC0220034)
     1818#define NT_STATUS_FWP_INVALID_PARAMETER                   NT_STATUS(0xC0220035)
     1819#define NT_STATUS_FWP_TOO_MANY_SUBLAYERS                  NT_STATUS(0xC0220036)
     1820#define NT_STATUS_FWP_CALLOUT_NOTIFICATION_FAILED         NT_STATUS(0xC0220037)
     1821#define NT_STATUS_FWP_INCOMPATIBLE_AUTH_CONFIG            NT_STATUS(0xC0220038)
     1822#define NT_STATUS_FWP_INCOMPATIBLE_CIPHER_CONFIG          NT_STATUS(0xC0220039)
     1823#define NT_STATUS_FWP_DUPLICATE_AUTH_METHOD               NT_STATUS(0xC022003C)
     1824#define NT_STATUS_FWP_TCPIP_NOT_READY                     NT_STATUS(0xC0220100)
     1825#define NT_STATUS_FWP_INJECT_HANDLE_CLOSING               NT_STATUS(0xC0220101)
     1826#define NT_STATUS_FWP_INJECT_HANDLE_STALE                 NT_STATUS(0xC0220102)
     1827#define NT_STATUS_FWP_CANNOT_PEND                         NT_STATUS(0xC0220103)
     1828#define NT_STATUS_NDIS_CLOSING                            NT_STATUS(0xC0230002)
     1829#define NT_STATUS_NDIS_BAD_VERSION                        NT_STATUS(0xC0230004)
     1830#define NT_STATUS_NDIS_BAD_CHARACTERISTICS                NT_STATUS(0xC0230005)
     1831#define NT_STATUS_NDIS_ADAPTER_NOT_FOUND                  NT_STATUS(0xC0230006)
     1832#define NT_STATUS_NDIS_OPEN_FAILED                        NT_STATUS(0xC0230007)
     1833#define NT_STATUS_NDIS_DEVICE_FAILED                      NT_STATUS(0xC0230008)
     1834#define NT_STATUS_NDIS_MULTICAST_FULL                     NT_STATUS(0xC0230009)
     1835#define NT_STATUS_NDIS_MULTICAST_EXISTS                   NT_STATUS(0xC023000A)
     1836#define NT_STATUS_NDIS_MULTICAST_NOT_FOUND                NT_STATUS(0xC023000B)
     1837#define NT_STATUS_NDIS_REQUEST_ABORTED                    NT_STATUS(0xC023000C)
     1838#define NT_STATUS_NDIS_RESET_IN_PROGRESS                  NT_STATUS(0xC023000D)
     1839#define NT_STATUS_NDIS_INVALID_PACKET                     NT_STATUS(0xC023000F)
     1840#define NT_STATUS_NDIS_INVALID_DEVICE_REQUEST             NT_STATUS(0xC0230010)
     1841#define NT_STATUS_NDIS_ADAPTER_NOT_READY                  NT_STATUS(0xC0230011)
     1842#define NT_STATUS_NDIS_INVALID_LENGTH                     NT_STATUS(0xC0230014)
     1843#define NT_STATUS_NDIS_INVALID_DATA                       NT_STATUS(0xC0230015)
     1844#define NT_STATUS_NDIS_BUFFER_TOO_SHORT                   NT_STATUS(0xC0230016)
     1845#define NT_STATUS_NDIS_INVALID_OID                        NT_STATUS(0xC0230017)
     1846#define NT_STATUS_NDIS_ADAPTER_REMOVED                    NT_STATUS(0xC0230018)
     1847#define NT_STATUS_NDIS_UNSUPPORTED_MEDIA                  NT_STATUS(0xC0230019)
     1848#define NT_STATUS_NDIS_GROUP_ADDRESS_IN_USE               NT_STATUS(0xC023001A)
     1849#define NT_STATUS_NDIS_FILE_NOT_FOUND                     NT_STATUS(0xC023001B)
     1850#define NT_STATUS_NDIS_ERROR_READING_FILE                 NT_STATUS(0xC023001C)
     1851#define NT_STATUS_NDIS_ALREADY_MAPPED                     NT_STATUS(0xC023001D)
     1852#define NT_STATUS_NDIS_RESOURCE_CONFLICT                  NT_STATUS(0xC023001E)
     1853#define NT_STATUS_NDIS_MEDIA_DISCONNECTED                 NT_STATUS(0xC023001F)
     1854#define NT_STATUS_NDIS_INVALID_ADDRESS                    NT_STATUS(0xC0230022)
     1855#define NT_STATUS_NDIS_PAUSED                             NT_STATUS(0xC023002A)
     1856#define NT_STATUS_NDIS_INTERFACE_NOT_FOUND                NT_STATUS(0xC023002B)
     1857#define NT_STATUS_NDIS_UNSUPPORTED_REVISION               NT_STATUS(0xC023002C)
     1858#define NT_STATUS_NDIS_INVALID_PORT                       NT_STATUS(0xC023002D)
     1859#define NT_STATUS_NDIS_INVALID_PORT_STATE                 NT_STATUS(0xC023002E)
     1860#define NT_STATUS_NDIS_LOW_POWER_STATE                    NT_STATUS(0xC023002F)
     1861#define NT_STATUS_NDIS_NOT_SUPPORTED                      NT_STATUS(0xC02300BB)
     1862#define NT_STATUS_NDIS_OFFLOAD_POLICY                     NT_STATUS(0xC023100F)
     1863#define NT_STATUS_NDIS_OFFLOAD_CONNECTION_REJECTED        NT_STATUS(0xC0231012)
     1864#define NT_STATUS_NDIS_OFFLOAD_PATH_REJECTED              NT_STATUS(0xC0231013)
     1865#define NT_STATUS_NDIS_DOT11_AUTO_CONFIG_ENABLED          NT_STATUS(0xC0232000)
     1866#define NT_STATUS_NDIS_DOT11_MEDIA_IN_USE                 NT_STATUS(0xC0232001)
     1867#define NT_STATUS_NDIS_DOT11_POWER_STATE_INVALID          NT_STATUS(0xC0232002)
     1868#define NT_STATUS_NDIS_PM_WOL_PATTERN_LIST_FULL           NT_STATUS(0xC0232003)
     1869#define NT_STATUS_NDIS_PM_PROTOCOL_OFFLOAD_LIST_FULL      NT_STATUS(0xC0232004)
     1870#define NT_STATUS_IPSEC_BAD_SPI                           NT_STATUS(0xC0360001)
     1871#define NT_STATUS_IPSEC_SA_LIFETIME_EXPIRED               NT_STATUS(0xC0360002)
     1872#define NT_STATUS_IPSEC_WRONG_SA                          NT_STATUS(0xC0360003)
     1873#define NT_STATUS_IPSEC_REPLAY_CHECK_FAILED               NT_STATUS(0xC0360004)
     1874#define NT_STATUS_IPSEC_INVALID_PACKET                    NT_STATUS(0xC0360005)
     1875#define NT_STATUS_IPSEC_INTEGRITY_CHECK_FAILED            NT_STATUS(0xC0360006)
     1876#define NT_STATUS_IPSEC_CLEAR_TEXT_DROP                   NT_STATUS(0xC0360007)
     1877#define NT_STATUS_IPSEC_AUTH_FIREWALL_DROP                NT_STATUS(0xC0360008)
     1878#define NT_STATUS_IPSEC_THROTTLE_DROP                     NT_STATUS(0xC0360009)
     1879#define NT_STATUS_IPSEC_DOSP_BLOCK                        NT_STATUS(0xC0368000)
     1880#define NT_STATUS_IPSEC_DOSP_RECEIVED_MULTICAST           NT_STATUS(0xC0368001)
     1881#define NT_STATUS_IPSEC_DOSP_INVALID_PACKET               NT_STATUS(0xC0368002)
     1882#define NT_STATUS_IPSEC_DOSP_STATE_LOOKUP_FAILED          NT_STATUS(0xC0368003)
     1883#define NT_STATUS_IPSEC_DOSP_MAX_ENTRIES                  NT_STATUS(0xC0368004)
     1884#define NT_STATUS_IPSEC_DOSP_KEYMOD_NOT_ALLOWED           NT_STATUS(0xC0368005)
     1885#define NT_STATUS_IPSEC_DOSP_MAX_PER_IP_RATELIMIT_QUEUES  NT_STATUS(0xC0368006)
     1886#define NT_STATUS_VOLMGR_MIRROR_NOT_SUPPORTED             NT_STATUS(0xC038005B)
     1887#define NT_STATUS_VOLMGR_RAID5_NOT_SUPPORTED              NT_STATUS(0xC038005C)
     1888#define NT_STATUS_VIRTDISK_PROVIDER_NOT_FOUND             NT_STATUS(0xC03A0014)
     1889#define NT_STATUS_VIRTDISK_NOT_VIRTUAL_DISK               NT_STATUS(0xC03A0015)
     1890#define NT_STATUS_VHD_PARENT_VHD_ACCESS_DENIED            NT_STATUS(0xC03A0016)
     1891#define NT_STATUS_VHD_CHILD_PARENT_SIZE_MISMATCH          NT_STATUS(0xC03A0017)
     1892#define NT_STATUS_VHD_DIFFERENCING_CHAIN_CYCLE_DETECTED   NT_STATUS(0xC03A0018)
     1893#define NT_STATUS_VHD_DIFFERENCING_CHAIN_ERROR_IN_PARENT  NT_STATUS(0xC03A0019)
     1894#define NT_STATUS_VHD_SHARED                              NT_STATUS(0xC05CFF0A)
     1895#define NT_STATUS_SMB_NO_PREAUTH_INTEGRITY_HASH_OVERLAP   NT_STATUS(0xC05D0000)
     1896#define NT_STATUS_SMB_BAD_CLUSTER_DIALECT                 NT_STATUS(0xC05D0001)
     1897
    6271898/* I use NT_STATUS_FOOBAR when I have no idea what error code to use -
    6281899 * this means we need a torture test */
    6291900#define NT_STATUS_FOOBAR NT_STATUS_UNSUCCESSFUL
     1901
     1902/*****************************************************************************
     1903 Returns an NT error message.  not amazingly helpful, but better than a number.
     1904
     1905 This version is const, and so neither allocates memory nor uses a
     1906 static variable for unknown errors.
     1907 *****************************************************************************/
     1908
     1909const char *nt_errstr_const(NTSTATUS nt_code);
    6301910
    6311911/*****************************************************************************
     
    6421922 returns an NT_STATUS constant as a string for inclusion in autogen C code
    6431923 *****************************************************************************/
    644 const char *get_nt_error_c_code(NTSTATUS nt_code);
     1924const char *get_nt_error_c_code(void *mem_ctx, NTSTATUS nt_code);
    6451925
    6461926/*****************************************************************************
     
    6481928 *****************************************************************************/
    6491929NTSTATUS nt_status_string_to_code(const char *nt_status_str);
    650 
    651 /** Used by ntstatus_dos_equal: */
    652 extern bool ntstatus_check_dos_mapping;
    6531930
    6541931/* we need these here for openchange */
     
    6621939#define NT_STATUS_IS_OK(x) (likely(NT_STATUS_V(x) == 0))
    6631940#define NT_STATUS_IS_ERR(x) (unlikely((NT_STATUS_V(x) & 0xc0000000) == 0xc0000000))
    664 /* checking for DOS error mapping here is ugly, but unfortunately the
    665    alternative is a very intrusive rewrite of the torture code */
    666 #if _SAMBA_BUILD_ == 4
    667 #define NT_STATUS_EQUAL(x,y) (NT_STATUS_IS_DOS(x)||NT_STATUS_IS_DOS(y)?ntstatus_dos_equal(x,y):NT_STATUS_V(x) == NT_STATUS_V(y))
    668 #else
    6691941#define NT_STATUS_EQUAL(x,y) (NT_STATUS_V(x) == NT_STATUS_V(y))
    670 #endif
     1942
     1943/*
     1944 * These macros (with the embedded return) are considered poor coding
     1945 * style per README.Coding
     1946 *
     1947 * Please do not use them in new code, and do not rely on them in
     1948 * projects external to Samba as they will go away at some point.
     1949 */
    6711950
    6721951#define NT_STATUS_HAVE_NO_MEMORY(x) do { \
  • vendor/current/libcli/util/tstream.c

    r860 r988  
    107107        TALLOC_FREE(subreq);
    108108        if (ret == -1) {
    109                 status = map_nt_error_from_unix(sys_errno);
     109                status = map_nt_error_from_unix_common(sys_errno);
    110110                tevent_req_nterror(req, status);
    111111                return;
  • vendor/current/libcli/util/werror.h

    r740 r988  
    3131
    3232#if defined(HAVE_IMMEDIATE_STRUCTURES)
    33 typedef struct {uint32_t v;} WERROR;
     33typedef struct {uint32_t w;} WERROR;
    3434#define W_ERROR(x) ((WERROR) { x })
    35 #define W_ERROR_V(x) ((x).v)
     35#define W_ERROR_V(x) ((x).w)
    3636#else
    3737typedef uint32_t WERROR;
     
    9999#define WERR_NO_SUCH_SHARE W_ERROR(0x00000043)
    100100#define WERR_FILE_EXISTS W_ERROR(0x00000050)
    101 #define WERR_BAD_PASSWORD W_ERROR(0x00000056)
    102101#define WERR_INVALID_PARAM W_ERROR(0x00000057)
    103102#define WERR_CALL_NOT_IMPLEMENTED W_ERROR(0x00000078)
     
    105104#define WERR_INSUFFICIENT_BUFFER W_ERROR(0x0000007A)
    106105#define WERR_INVALID_NAME W_ERROR(0x0000007B)
    107 #define WERR_UNKNOWN_LEVEL W_ERROR(0x0000007C)
    108106#define WERR_OBJECT_PATH_INVALID W_ERROR(0x000000A1)
    109107#define WERR_ALREADY_EXISTS W_ERROR(0x000000B7)
     
    132130#define WERR_MACHINE_LOCKED W_ERROR(0x000004F7)
    133131#define WERR_UNKNOWN_REVISION W_ERROR(0x00000519)
    134 #define WERR_INVALID_OWNER W_ERROR(0x0000051B)
    135132#define WERR_REVISION_MISMATCH W_ERROR(0x0000051A)
    136133#define WERR_INVALID_OWNER W_ERROR(0x0000051B)
     
    262259/* Generic error code aliases */
    263260#define WERR_FOOBAR WERR_GENERAL_FAILURE
     261
     262/* TODO: remove WERR_UNKNOWN_LEVEL in all callers */
     263#define WERR_UNKNOWN_LEVEL WERR_INVALID_LEVEL
    264264
    265265/*****************************************************************************
     
    24022402#define WERR_DNS_ERROR_RCODE_BADKEY     W_ERROR(0x00002339)
    24032403#define WERR_DNS_ERROR_RCODE_BADTIME    W_ERROR(0x0000233A)
     2404#define WERR_DNS_ERROR_KEYMASTER_REQUIRED               W_ERROR(0x0000238D)
     2405#define WERR_DNS_ERROR_NOT_ALLOWED_ON_SIGNED_ZONE       W_ERROR(0x0000238E)
     2406#define WERR_DNS_ERROR_INVALID_NSEC3_PARAMETERS         W_ERROR(0x0000238F)
     2407#define WERR_DNS_ERROR_NOT_ENOUGH_SIGNING_KEY_DESCRIPTORS       W_ERROR(0x00002390)
     2408#define WERR_DNS_ERROR_UNSUPPORTED_ALGORITHM            W_ERROR(0x00002391)
     2409#define WERR_DNS_ERROR_INVALID_KEY_SIZE                 W_ERROR(0x00002392)
     2410#define WERR_DNS_ERROR_SIGNING_KEY_NOT_ACCESSIBLE       W_ERROR(0x00002393)
     2411#define WERR_DNS_ERROR_KSP_DOES_NOT_SUPPORT_PROTECTION  W_ERROR(0x00002394)
     2412#define WERR_DNS_ERROR_UNEXPECTED_DATA_PROTECTION_ERROR W_ERROR(0x00002395)
     2413#define WERR_DNS_ERROR_UNEXPECTED_CNG_ERROR             W_ERROR(0x00002396)
     2414#define WERR_DNS_ERROR_UNKNOWN_SIGNING_PARAMETER_VERSION        W_ERROR(0x00002397)
     2415#define WERR_DNS_ERROR_KSP_NOT_ACCESSIBLE               W_ERROR(0x00002398)
     2416#define WERR_DNS_ERROR_TOO_MANY_SKDS                    W_ERROR(0x00002399)
     2417#define WERR_DNS_ERROR_INVALID_ROLLOVER_PERIOD          W_ERROR(0x0000239A)
     2418#define WERR_DNS_ERROR_INVALID_INITIAL_ROLLOVER_OFFSET  W_ERROR(0x0000239B)
     2419#define WERR_DNS_ERROR_ROLLOVER_IN_PROGRESS             W_ERROR(0x0000239C)
     2420#define WERR_DNS_ERROR_STANDBY_KEY_NOT_PRESENT          W_ERROR(0x0000239D)
     2421#define WERR_DNS_ERROR_NOT_ALLOWED_ON_ZSK               W_ERROR(0x0000239E)
     2422#define WERR_DNS_ERROR_NOT_ALLOWED_ON_ACTIVE_SKD        W_ERROR(0x0000239F)
     2423#define WERR_DNS_ERROR_ROLLOVER_ALREADY_QUEUED          W_ERROR(0x000023A0)
     2424#define WERR_DNS_ERROR_NOT_ALLOWED_ON_UNSIGNED_ZONE     W_ERROR(0x000023A1)
     2425#define WERR_DNS_ERROR_BAD_KEYMASTER                    W_ERROR(0x000023A2)
     2426#define WERR_DNS_ERROR_INVALID_SIGNATURE_VALIDITY_PERIOD        W_ERROR(0x000023A3)
     2427#define WERR_DNS_ERROR_INVALID_NSEC3_ITERATION_COUNT    W_ERROR(0x000023A4)
     2428#define WERR_DNS_ERROR_DNSSEC_IS_DISABLED               W_ERROR(0x000023A5)
     2429#define WERR_DNS_ERROR_INVALID_XML                      W_ERROR(0x000023A6)
     2430#define WERR_DNS_ERROR_NO_VALID_TRUST_ANCHORS           W_ERROR(0x000023A7)
     2431#define WERR_DNS_ERROR_ROLLOVER_NOT_POKEABLE            W_ERROR(0x000023A8)
     2432#define WERR_DNS_ERROR_NSEC3_NAME_COLLISION             W_ERROR(0x000023A9)
    24042433#define WERR_DNS_INFO_NO_RECORDS        W_ERROR(0x0000251D)
    24052434#define WERR_DNS_ERROR_BAD_PACKET       W_ERROR(0x0000251E)
     
    24072436#define WERR_DNS_ERROR_RCODE    W_ERROR(0x00002520)
    24082437#define WERR_DNS_ERROR_UNSECURE_PACKET  W_ERROR(0x00002521)
     2438#define WERR_DNS_REQUEST_PENDING        W_ERROR(0x00002522)
    24092439#define WERR_DNS_ERROR_INVALID_TYPE     W_ERROR(0x0000254F)
    24102440#define WERR_DNS_ERROR_INVALID_IP_ADDRESS       W_ERROR(0x00002550)
     
    24262456#define WERR_DNS_ERROR_BACKGROUND_LOADING       W_ERROR(0x00002560)
    24272457#define WERR_DNS_ERROR_NOT_ALLOWED_ON_RODC      W_ERROR(0x00002561)
     2458#define WERR_DNS_ERROR_NOT_ALLOWED_UNDER_DNAME  W_ERROR(0x00002562)
     2459#define WERR_DNS_ERROR_DELEGATION_REQUIRED      W_ERROR(0x00002563)
     2460#define WERR_DNS_ERROR_INVALID_POLICY_TABLE     W_ERROR(0x00002564)
    24282461#define WERR_DNS_ERROR_ZONE_DOES_NOT_EXIST      W_ERROR(0x00002581)
    24292462#define WERR_DNS_ERROR_NO_ZONE_INFO     W_ERROR(0x00002582)
     
    24712504#define WERR_DNS_ERROR_DS_ZONE_ALREADY_EXISTS   W_ERROR(0x000025F6)
    24722505#define WERR_DNS_ERROR_NO_BOOTFILE_IF_DS_ZONE   W_ERROR(0x000025F7)
     2506#define WERR_DNS_ERROR_NODE_IS_DNMAE    W_ERROR(0x000025F8)
     2507#define WERR_DNS_ERROR_DNAME_COLLISION  W_ERROR(0x000025F9)
     2508#define WERR_DNS_ERROR_ALIAS_LOOP       W_ERROR(0x000025FA)
    24732509#define WERR_DNS_INFO_AXFR_COMPLETE     W_ERROR(0x00002617)
    24742510#define WERR_DNS_ERROR_AXFR     W_ERROR(0x00002618)
Note: See TracChangeset for help on using the changeset viewer.