*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
+ * the Free Software Foundation; either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
return False;
if ( UNMARSHALLING(&hbin->ps) ) {
- if ( !(lf->hashes = PRS_ALLOC_MEM( &hbin->ps, REGF_HASH_REC, lf->num_keys )) )
- return False;
+ if (lf->num_keys) {
+ if ( !(lf->hashes = PRS_ALLOC_MEM( &hbin->ps, REGF_HASH_REC, lf->num_keys )) )
+ return False;
+ } else {
+ lf->hashes = NULL;
+ }
}
for ( i=0; i<lf->num_keys; i++ ) {
if ( vk->data_size > sizeof(uint32) ) {
uint32 data_size = ( (vk->data_size+sizeof(uint32)) & 0xfffffff8 ) + 8;
- vk->data = TALLOC_MEMDUP( file->mem_ctx, regval_data_p(value), vk->data_size );
+ vk->data = (uint8 *)TALLOC_MEMDUP( file->mem_ctx,
+ regval_data_p(value),
+ vk->data_size );
+ if (vk->data == NULL) {
+ return False;
+ }
/* go ahead and store the offset....we'll pick this hbin block back up when
we stream the data */
- data_hbin = find_free_space(file, data_size );
+ if ((data_hbin = find_free_space(file, data_size )) == NULL) {
+ return False;
+ }
vk->data_off = prs_offset( &data_hbin->ps ) + data_hbin->first_hbin_off - HBIN_HDR_SIZE;
}
else {
size = nk_record_data_size( nk );
nk->rec_size = ( size - 1 ) ^ 0XFFFFFFFF;
- nk->hbin = find_free_space( file, size );
+ if ((nk->hbin = find_free_space( file, size )) == NULL) {
+ return NULL;
+ }
nk->hbin_off = prs_offset( &nk->hbin->ps );
/* Update the hash record in the parent */
if ( sec_desc ) {
uint32 sk_size = sk_record_data_size( sec_desc );
REGF_HBIN *sk_hbin;
- REGF_SK_REC *tmp = NULL;
/* search for it in the existing list of sd's */
if ( (nk->sec_desc = find_sk_record_by_sec_desc( file, sec_desc )) == NULL ) {
/* not found so add it to the list */
- sk_hbin = find_free_space( file, sk_size );
+ if (!(sk_hbin = find_free_space( file, sk_size ))) {
+ return NULL;
+ }
if ( !(nk->sec_desc = TALLOC_ZERO_P( file->mem_ctx, REGF_SK_REC )) )
return NULL;
/* size value must be self-inclusive */
nk->sec_desc->size = sec_desc_size(sec_desc) + sizeof(uint32);
- DLIST_ADD_END( file->sec_desc_list, nk->sec_desc, tmp );
+ DLIST_ADD_END( file->sec_desc_list, nk->sec_desc, REGF_SK_REC *);
/* update the offsets for us and the previous sd in the list.
if this is the first record, then just set the next and prev
uint32 namelen;
int i;
- nk->subkeys.hbin = find_free_space( file, lf_size );
+ if (!(nk->subkeys.hbin = find_free_space( file, lf_size ))) {
+ return NULL;
+ }
nk->subkeys.hbin_off = prs_offset( &nk->subkeys.hbin->ps );
nk->subkeys.rec_size = (lf_size-1) ^ 0xFFFFFFFF;
nk->subkeys_off = prs_offset( &nk->subkeys.hbin->ps ) + nk->subkeys.hbin->first_hbin_off - HBIN_HDR_SIZE;
memcpy( nk->subkeys.header, "lf", REC_HDR_SIZE );
nk->subkeys.num_keys = nk->num_subkeys;
- if ( !(nk->subkeys.hashes = TALLOC_ZERO_ARRAY( file->mem_ctx, REGF_HASH_REC, nk->subkeys.num_keys )) )
- return NULL;
+ if (nk->subkeys.num_keys) {
+ if ( !(nk->subkeys.hashes = TALLOC_ZERO_ARRAY( file->mem_ctx, REGF_HASH_REC, nk->subkeys.num_keys )) )
+ return NULL;
+ } else {
+ nk->subkeys.hashes = NULL;
+ }
nk->subkey_index = 0;
/* update the max_bytes_subkey{name,classname} fields */
uint32 vlist_size = ( ( nk->num_values * sizeof(uint32) ) & 0xfffffff8 ) + 8;
int i;
- vlist_hbin = find_free_space( file, vlist_size );
+ if (!(vlist_hbin = find_free_space( file, vlist_size ))) {
+ return NULL;
+ }
nk->values_off = prs_offset( &vlist_hbin->ps ) + vlist_hbin->first_hbin_off - HBIN_HDR_SIZE;
- if ( !(nk->values = TALLOC_ARRAY( file->mem_ctx, REGF_VK_REC, nk->num_values )) )
- return NULL;
+ if (nk->num_values) {
+ if ( !(nk->values = TALLOC_ARRAY( file->mem_ctx, REGF_VK_REC, nk->num_values )) )
+ return NULL;
+ } else {
+ nk->values = NULL;
+ }
/* create the vk records */