Changeset 745 for trunk/server/source3/libsmb/smb_signing.c
- Timestamp:
- Nov 27, 2012, 4:43:17 PM (13 years ago)
- Location:
- trunk/server
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/server
- Property svn:mergeinfo changed
/vendor/current merged: 581,587,591,594,597,600,615,618,740
- Property svn:mergeinfo changed
-
trunk/server/source3/libsmb/smb_signing.c
r414 r745 21 21 22 22 #include "includes.h" 23 #include "../lib/crypto/md5.h" 24 #include "smb_signing.h" 23 25 24 26 /* Used by the SMB signing functions. */ … … 44 46 /* the next expected seqnum */ 45 47 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); 46 52 }; 47 53 … … 50 56 si->active = false; 51 57 si->bsrspyl = false; 52 data_blob_free(&si->mac_key);53 58 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 69 struct 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; 54 102 } 55 103 … … 58 106 bool mandatory) 59 107 { 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); 75 109 } 76 110 … … 313 347 314 348 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; 316 361 317 362 ofs = 0;
Note:
See TracChangeset
for help on using the changeset viewer.