if ( (size_t)file_offset >= sbuf.st_size )
return -1;
- /* if block_size == 0, we are parsnig HBIN records and need
+ /* if block_size == 0, we are parsing HBIN records and need
to read some of the header to get the block_size from there */
if ( block_size == 0 ) {
- uint8 hdr[0x20];
+ char hdr[0x20];
if ( lseek( file->fd, file_offset, SEEK_SET ) == -1 ) {
DEBUG(0,("read_block: lseek() failed! (%s)\n", strerror(errno) ));
prs_debug(ps, depth, desc, "prs_regf_block");
depth++;
- if ( !prs_uint8s( True, "header", ps, depth, file->header, sizeof( file->header )) )
+ if ( !prs_uint8s( True, "header", ps, depth, (uint8*)file->header, sizeof( file->header )) )
return False;
/* yes, these values are always identical so store them only once */
prs_debug(ps, depth, desc, "prs_regf_block");
depth++;
- if ( !prs_uint8s( True, "header", ps, depth, hbin->header, sizeof( hbin->header )) )
+ if ( !prs_uint8s( True, "header", ps, depth, (uint8*)hbin->header, sizeof( hbin->header )) )
return False;
if ( !prs_uint32( "first_hbin_off", ps, depth, &hbin->first_hbin_off ))
if ( !prs_uint32( "rec_size", ps, depth, &nk->rec_size ))
return False;
- if ( !prs_uint8s( True, "header", ps, depth, nk->header, sizeof( nk->header )) )
+ if ( !prs_uint8s( True, "header", ps, depth, (uint8*)nk->header, sizeof( nk->header )) )
return False;
if ( !prs_uint16( "key_type", ps, depth, &nk->key_type ))
return False;
}
- if ( !prs_uint8s( True, "name", ps, depth, nk->keyname, name_length) )
+ if ( !prs_uint8s( True, "name", ps, depth, (uint8*)nk->keyname, name_length) )
return False;
if ( UNMARSHALLING(ps) )
}
/*******************************************************************
- Input a randon offset and receive the correpsonding HBIN
+ Input a random offset and receive the corresponding HBIN
block for it
*******************************************************************/
}
/*******************************************************************
- Input a randon offset and receive the correpsonding HBIN
+ Input a random offset and receive the corresponding HBIN
block for it
*******************************************************************/
/* start with the open list */
for ( hbin=file->block_list; hbin; hbin=hbin->next ) {
- DEBUG(10,("lookup_hbin_block: address = 0x%x [0x%x]\n", hbin->file_off, (uint32)hbin ));
+ DEBUG(10,("lookup_hbin_block: address = 0x%x [0x%lx]\n", hbin->file_off, (unsigned long)hbin ));
if ( hbin_contains_offset( hbin, offset ) )
return hbin;
}
if ( !prs_uint32( "rec_size", &hbin->ps, depth, &lf->rec_size ))
return False;
- if ( !prs_uint8s( True, "header", &hbin->ps, depth, lf->header, sizeof( lf->header )) )
+ if ( !prs_uint8s( True, "header", &hbin->ps, depth, (uint8*)lf->header, sizeof( lf->header )) )
return False;
if ( !prs_uint16( "num_keys", &hbin->ps, depth, &lf->num_keys))
if ( !prs_uint32( "rec_size", &hbin->ps, depth, &sk->rec_size ))
return False;
- if ( !prs_uint8s( True, "header", ps, depth, sk->header, sizeof( sk->header )) )
+ if ( !prs_uint8s( True, "header", ps, depth, (uint8*)sk->header, sizeof( sk->header )) )
return False;
if ( !prs_uint16( "tag", ps, depth, &tag))
return False;
if ( !prs_uint32( "rec_size", &hbin->ps, depth, &vk->rec_size ))
return False;
- if ( !prs_uint8s( True, "header", ps, depth, vk->header, sizeof( vk->header )) )
+ if ( !prs_uint8s( True, "header", ps, depth, (uint8*)vk->header, sizeof( vk->header )) )
return False;
if ( MARSHALLING(&hbin->ps) )
if ( !(vk->valuename = PRS_ALLOC_MEM( ps, char, name_length+1 )))
return False;
}
- if ( !prs_uint8s( True, "name", ps, depth, vk->valuename, name_length ) )
+ if ( !prs_uint8s( True, "name", ps, depth, (uint8*)vk->valuename, name_length ) )
return False;
}
static BOOL next_record( REGF_HBIN *hbin, const char *hdr, BOOL *eob )
{
- char header[REC_HDR_SIZE] = "";
+ uint8 header[REC_HDR_SIZE];
uint32 record_size;
uint32 curr_off, block_size;
BOOL found = False;
if ( curr_off == 0 )
prs_set_offset( ps, HBIN_HEADER_REC_SIZE );
- /* assume that the current offset is at the reacord header
+ /* assume that the current offset is at the record header
and we need to backup to read the record size */
curr_off -= sizeof(uint32);
block_size = prs_data_size( ps );
record_size = 0;
+ memset( header, 0x0, sizeof(uint8)*REC_HDR_SIZE );
while ( !found ) {
curr_off = curr_off+record_size;
static int hashrec_cmp( REGF_HASH_REC *h1, REGF_HASH_REC *h2 )
{
- return StrnCaseCmp( h1->keycheck, h2->keycheck, sizeof(uint32) );
+ return StrCaseCmp( h1->fullname, h2->fullname );
}
/*******************************************************************
hash->nk_off = prs_offset( &nk->hbin->ps ) + nk->hbin->first_hbin_off - HBIN_HDR_SIZE;
memcpy( hash->keycheck, name, sizeof(uint32) );
+ hash->fullname = talloc_strdup( file->mem_ctx, name );
parent->subkey_index++;
/* sort the list by keyname */
DLIST_ADD_END( file->sec_desc_list, nk->sec_desc, tmp );
- /* initialize offsets */
-
- nk->sec_desc->prev_sk_off = nk->sec_desc->sk_off;
- nk->sec_desc->next_sk_off = nk->sec_desc->sk_off;
-
- /* now update the offsets for us and the previous sd in the list */
+ /* 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
+ offsets to ourself. */
if ( nk->sec_desc->prev ) {
REGF_SK_REC *prev = nk->sec_desc->prev;
nk->sec_desc->prev_sk_off = prev->hbin_off + prev->hbin->first_hbin_off - HBIN_HDR_SIZE;
- prev->next_sk_off = nk->sk_off;
+ prev->next_sk_off = nk->sec_desc->sk_off;
+
+ /* the end must loop around to the front */
+ nk->sec_desc->next_sk_off = file->sec_desc_list->sk_off;
+
+ /* and first must loop around to the tail */
+ file->sec_desc_list->prev_sk_off = nk->sec_desc->sk_off;
+ } else {
+ nk->sec_desc->prev_sk_off = nk->sec_desc->sk_off;
+ nk->sec_desc->next_sk_off = nk->sec_desc->sk_off;
}
}
- /* dump the reference count */
+ /* bump the reference count +1 */
nk->sk_off = nk->sec_desc->sk_off;
nk->sec_desc->ref_count++;
nk->max_bytes_valuename = namelen * 2;
datalen = regval_size( r );
- if ( datalen*2 > nk->max_bytes_value )
- nk->max_bytes_value = datalen * 2;
+ if ( datalen > nk->max_bytes_value )
+ nk->max_bytes_value = datalen;
}
}