Ignore:
Timestamp:
Nov 27, 2012, 4:43:17 PM (13 years ago)
Author:
Silvan Scherrer
Message:

Samba Server: updated trunk to 3.6.0

Location:
trunk/server
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/server

  • trunk/server/source3/libsmb/smb_signing.c

    r414 r745  
    2121
    2222#include "includes.h"
     23#include "../lib/crypto/md5.h"
     24#include "smb_signing.h"
    2325
    2426/* Used by the SMB signing functions. */
     
    4446        /* the next expected seqnum */
    4547        uint32_t seqnum;
     48
     49        TALLOC_CTX *mem_ctx;
     50        void *(*alloc_fn)(TALLOC_CTX *mem_ctx, size_t len);
     51        void (*free_fn)(TALLOC_CTX *mem_ctx, void *ptr);
    4652};
    4753
     
    5056        si->active = false;
    5157        si->bsrspyl = false;
    52         data_blob_free(&si->mac_key);
    5358        si->seqnum = 0;
     59
     60        if (si->free_fn) {
     61                si->free_fn(si->mem_ctx, si->mac_key.data);
     62        } else {
     63                talloc_free(si->mac_key.data);
     64        }
     65        si->mac_key.data = NULL;
     66        si->mac_key.length = 0;
     67}
     68
     69struct smb_signing_state *smb_signing_init_ex(TALLOC_CTX *mem_ctx,
     70                                              bool allowed,
     71                                              bool mandatory,
     72                                              void *(*alloc_fn)(TALLOC_CTX *, size_t),
     73                                              void (*free_fn)(TALLOC_CTX *, void *))
     74{
     75        struct smb_signing_state *si;
     76
     77        if (alloc_fn) {
     78                void *p = alloc_fn(mem_ctx, sizeof(struct smb_signing_state));
     79                if (p == NULL) {
     80                        return NULL;
     81                }
     82                memset(p, 0, sizeof(struct smb_signing_state));
     83                si = (struct smb_signing_state *)p;
     84                si->mem_ctx = mem_ctx;
     85                si->alloc_fn = alloc_fn;
     86                si->free_fn = free_fn;
     87        } else {
     88                si = talloc_zero(mem_ctx, struct smb_signing_state);
     89                if (si == NULL) {
     90                        return NULL;
     91                }
     92        }
     93
     94        if (mandatory) {
     95                allowed = true;
     96        }
     97
     98        si->allowed = allowed;
     99        si->mandatory = mandatory;
     100
     101        return si;
    54102}
    55103
     
    58106                                           bool mandatory)
    59107{
    60         struct smb_signing_state *si;
    61 
    62         si = talloc_zero(mem_ctx, struct smb_signing_state);
    63         if (si == NULL) {
    64                 return NULL;
    65         }
    66 
    67         if (mandatory) {
    68                 allowed = true;
    69         }
    70 
    71         si->allowed = allowed;
    72         si->mandatory = mandatory;
    73 
    74         return si;
     108        return smb_signing_init_ex(mem_ctx, allowed, mandatory, NULL, NULL);
    75109}
    76110
     
    313347
    314348        len = response.length + user_session_key.length;
    315         si->mac_key = data_blob_talloc(si, NULL, len);
     349        if (si->alloc_fn) {
     350                si->mac_key.data = (uint8_t *)si->alloc_fn(si->mem_ctx, len);
     351                if (si->mac_key.data == NULL) {
     352                        return false;
     353                }
     354        } else {
     355                si->mac_key.data = (uint8_t *)talloc_size(si, len);
     356                if (si->mac_key.data == NULL) {
     357                        return false;
     358                }
     359        }
     360        si->mac_key.length = len;
    316361
    317362        ofs = 0;
Note: See TracChangeset for help on using the changeset viewer.