Ignore:
Timestamp:
May 26, 2009, 9:44:50 AM (16 years ago)
Author:
Herwig Bauernfeind
Message:

Update 3.2 branch to 3.2.6

File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/samba-3.2.x/source/libnet/libnet_samsync.c

    r139 r228  
    3333static NTSTATUS fix_user(TALLOC_CTX *mem_ctx,
    3434                         DATA_BLOB *session_key,
    35                          bool rid_crypt,
    3635                         enum netr_SamDatabaseID database_id,
    3736                         struct netr_DELTA_ENUM *delta)
     
    4241        struct samr_Password lm_hash;
    4342        struct samr_Password nt_hash;
     43        unsigned char zero_buf[16];
    4444
    45         if (rid_crypt) {
    46                 if (user->lm_password_present) {
     45        memset(zero_buf, '\0', sizeof(zero_buf));
     46
     47        /* Note that win2000 may send us all zeros
     48         * for the hashes if it doesn't
     49         * think this channel is secure enough. */
     50        if (user->lm_password_present) {
     51                if (memcmp(user->lmpassword.hash, zero_buf, 16) != 0) {
    4752                        sam_pwd_hash(rid, user->lmpassword.hash, lm_hash.hash, 0);
    48                         user->lmpassword = lm_hash;
     53                } else {
     54                        memset(lm_hash.hash, '\0', sizeof(lm_hash.hash));
    4955                }
     56                user->lmpassword = lm_hash;
     57        }
    5058
    51                 if (user->nt_password_present) {
     59        if (user->nt_password_present) {
     60                if (memcmp(user->ntpassword.hash, zero_buf, 16) != 0) {
    5261                        sam_pwd_hash(rid, user->ntpassword.hash, nt_hash.hash, 0);
    53                         user->ntpassword = nt_hash;
     62                } else {
     63                        memset(nt_hash.hash, '\0', sizeof(nt_hash.hash));
    5464                }
     65                user->ntpassword = nt_hash;
    5566        }
    5667
     
    7283                }
    7384
     85                /* Note that win2000 may send us all zeros
     86                 * for the hashes if it doesn't
     87                 * think this channel is secure enough. */
    7488                if (keys.keys.keys2.lmpassword.length == 16) {
    75                         if (rid_crypt) {
     89                        if (memcmp(keys.keys.keys2.lmpassword.pwd.hash,
     90                                                zero_buf, 16) != 0) {
    7691                                sam_pwd_hash(rid,
    7792                                             keys.keys.keys2.lmpassword.pwd.hash,
    7893                                             lm_hash.hash, 0);
    79                                 user->lmpassword = lm_hash;
    8094                        } else {
    81                                 user->lmpassword = keys.keys.keys2.lmpassword.pwd;
     95                                memset(lm_hash.hash, '\0', sizeof(lm_hash.hash));
    8296                        }
     97                        user->lmpassword = lm_hash;
    8398                        user->lm_password_present = true;
    8499                }
    85100                if (keys.keys.keys2.ntpassword.length == 16) {
    86                         if (rid_crypt) {
     101                        if (memcmp(keys.keys.keys2.ntpassword.pwd.hash,
     102                                                zero_buf, 16) != 0) {
    87103                                sam_pwd_hash(rid,
    88                                              keys.keys.keys2.ntpassword.pwd.hash,
    89                                              nt_hash.hash, 0);
    90                                 user->ntpassword = nt_hash;
     104                                        keys.keys.keys2.ntpassword.pwd.hash,
     105                                        nt_hash.hash, 0);
    91106                        } else {
    92                                 user->ntpassword = keys.keys.keys2.ntpassword.pwd;
     107                                memset(nt_hash.hash, '\0', sizeof(nt_hash.hash));
    93108                        }
     109                        user->ntpassword = nt_hash;
    94110                        user->nt_password_present = true;
    95111                }
     
    129145static NTSTATUS samsync_fix_delta(TALLOC_CTX *mem_ctx,
    130146                                  DATA_BLOB *session_key,
    131                                   bool rid_crypt,
    132147                                  enum netr_SamDatabaseID database_id,
    133148                                  struct netr_DELTA_ENUM *delta)
     
    140155                        status = fix_user(mem_ctx,
    141156                                          session_key,
    142                                           rid_crypt,
    143157                                          database_id,
    144158                                          delta);
     
    165179NTSTATUS samsync_fix_delta_array(TALLOC_CTX *mem_ctx,
    166180                                 DATA_BLOB *session_key,
    167                                  bool rid_crypt,
    168181                                 enum netr_SamDatabaseID database_id,
    169182                                 struct netr_DELTA_ENUM_ARRAY *r)
     
    176189                status = samsync_fix_delta(mem_ctx,
    177190                                           session_key,
    178                                            rid_crypt,
    179191                                           database_id,
    180192                                           &r->delta_enum[i]);
Note: See TracChangeset for help on using the changeset viewer.