search for: is_valid_block

Displaying 20 results from an estimated 26 matches for "is_valid_block".

2014 Aug 07
4
[PATCH 0/2] Fix errors found by Clang static analyzer
Hi, Here is one trivial initialization fix and another patch to convert a huge macro to an inline function. The result of the expansion would show up in an assertion which triggered a -Woverlength-strings warning. Peter Wu (2): Fix garbage return value on error Fix overly long assertion string lib/hivex-internal.h | 28 ++++++++++++++++------------ lib/node.c | 18
2013 Jul 25
19
[PATCH hivex 00/19] Fix read/write handling of li-records.
This is, hopefully, a full fix for handling of li-records. See: https://bugzilla.redhat.com/show_bug.cgi?id=717583 https://bugzilla.redhat.com/show_bug.cgi?id=987463 Rich.
2011 Apr 13
1
[PATCH hivex] maint: split long lines
...n: returning ERANGE because " + "nr_subkeys_in_nk > HIVEX_MAX_SUBKEYS (%zu > %d)\n", nr_subkeys_in_nk, HIVEX_MAX_SUBKEYS); errno = ERANGE; goto error; @@ -751,7 +755,8 @@ get_children (hive_h *h, hive_node_h node, subkey_lf += 0x1000; if (!IS_VALID_BLOCK (h, subkey_lf)) { if (h->msglvl >= 2) - fprintf (stderr, "hivex_node_children: returning EFAULT because subkey_lf is not a valid block (0x%zx)\n", + fprintf (stderr, "hivex_node_children: returning EFAULT" + " because subkey_lf is not a valid blo...
2013 Jun 23
3
[PATCH] Add read support for "big data" blocks to hivex
...= blen - 4; - - /* Return the smaller length to the caller too. */ - if (len_rtn) - *len_rtn = len; + if (len <= blen - 4 /* subtract 4 for block header */) { + char *data = (char *) h->addr + data_offset + 4; + memcpy (ret, data, len); + return ret; + } else { + if (!IS_VALID_BLOCK (h, data_offset) || !BLOCK_ID_EQ (h, data_offset, "db")) { + if (h->msglvl >= 2) + fprintf (stderr, "hivex_value_value: warning: declared data length " + "is longer than the amount of data found in big-data blocks " + &...
2013 Jun 25
2
Re: [PATCH] Add read support for "big data" blocks to hivex
* Richard W.M. Jones: > diff --git a/lib/hivex.c b/lib/hivex.c > index e3c1e05..9351ac5 100644 > --- a/lib/hivex.c > +++ b/lib/hivex.c > @@ -1471,7 +1471,7 @@ hivex_value_value (hive_h *h, hive_value_h value, > if (h->msglvl >= 2) > fprintf (stderr, "hivex_value_value: warning: big data block is not " > "valid
2013 Jun 25
0
Re: [PATCH] Add read support for "big data" blocks to hivex
...length to the caller too. */ > - if (len_rtn) > - *len_rtn = len; > + if (len <= blen - 4 /* subtract 4 for block header */) { > + char *data = (char *) h->addr + data_offset + 4; > + memcpy (ret, data, len); > + return ret; > + } else { > + if (!IS_VALID_BLOCK (h, data_offset) || !BLOCK_ID_EQ (h, data_offset, "db")) { > + if (h->msglvl >= 2) > + fprintf (stderr, "hivex_value_value: warning: declared data length " > + "is longer than the amount of data found in big-data blocks " >...
2013 Jun 25
0
[PATCH] Add read support for "big data" blocks to hivex
...= blen - 4; - - /* Return the smaller length to the caller too. */ - if (len_rtn) - *len_rtn = len; + if (len <= blen - 4 /* subtract 4 for block header */) { + char *data = (char *) h->addr + data_offset + 4; + memcpy (ret, data, len); + return ret; + } else { + if (!IS_VALID_BLOCK (h, data_offset) || !BLOCK_ID_EQ (h, data_offset, "db")) { + if (h->msglvl >= 2) + fprintf (stderr, "hivex_value_value: warning: declared data length " + "is longer than the block and block is not a db block " + "(...
2011 Sep 02
1
[PATCH 4/7] hivex: Add metadata length functions for nodes and values
...ngth, data type and data of a value", "\ diff --git a/lib/hivex.c b/lib/hivex.c index 61177d3..d8ffa63 100644 --- a/lib/hivex.c +++ b/lib/hivex.c @@ -585,6 +585,30 @@ hivex_root (hive_h *h) return ret; } +size_t +hivex_node_struct_length (hive_h *h, hive_node_h node) +{ + if (!IS_VALID_BLOCK (h, node) || !BLOCK_ID_EQ (h, node, "nk")) { + errno = EINVAL; + return 0; + } + + struct ntreg_nk_record *nk = (struct ntreg_nk_record *) (h->addr + node); + size_t name_len = le16toh (nk->name_len); + /* -1 to avoid double-counting the first name character */ + size_t r...
2011 Oct 19
0
[hivex][PATCH 3/8] hivex: Add offset-&-length function for long value data
....c b/lib/hivex.c index bf1a860..df313bf 100644 --- a/lib/hivex.c +++ b/lib/hivex.c @@ -1257,6 +1257,66 @@ hivex_value_type (hive_h *h, hive_value_h value, hive_type *t, size_t *len) return 0; } +hive_value_h +hivex_value_data_cell_offset (hive_h *h, hive_value_h value, size_t *len) +{ + if (!IS_VALID_BLOCK (h, value) || !BLOCK_ID_EQ (h, value, "vk")) { + errno = EINVAL; + return 0; + } + + if (h->msglvl >= 2) + fprintf (stderr, "hivex_value_data_cell_offset: value=0x%zx\n", value); + struct ntreg_vk_record *vk = (struct ntreg_vk_record *) (h->addr + value); +...
2011 Dec 08
0
[hivex] [PATCH 3/8] hivex: Add offset-&-length function for long value data
....c b/lib/hivex.c index bf1a860..df313bf 100644 --- a/lib/hivex.c +++ b/lib/hivex.c @@ -1257,6 +1257,66 @@ hivex_value_type (hive_h *h, hive_value_h value, hive_type *t, size_t *len) return 0; } +hive_value_h +hivex_value_data_cell_offset (hive_h *h, hive_value_h value, size_t *len) +{ + if (!IS_VALID_BLOCK (h, value) || !BLOCK_ID_EQ (h, value, "vk")) { + errno = EINVAL; + return 0; + } + + if (h->msglvl >= 2) + fprintf (stderr, "hivex_value_data_cell_offset: value=0x%zx\n", value); + struct ntreg_vk_record *vk = (struct ntreg_vk_record *) (h->addr + value); +...
2011 Sep 02
1
[PATCH 5/7] hivex: Add offset-&-length function for long value data
....c b/lib/hivex.c index d8ffa63..04ceed3 100644 --- a/lib/hivex.c +++ b/lib/hivex.c @@ -1294,6 +1294,51 @@ hivex_value_type (hive_h *h, hive_value_h value, hive_type *t, size_t *len) return 0; } +hive_value_h +hivex_value_data_cell_offset (hive_h *h, hive_value_h value, size_t *len) +{ + if (!IS_VALID_BLOCK (h, value) || !BLOCK_ID_EQ (h, value, "vk")) { + errno = EINVAL; + return 0; + } + + struct ntreg_vk_record *vk = (struct ntreg_vk_record *) (h->addr + value); + + size_t data_len; + int is_inline; + + data_len = le32toh (vk->data_len); + is_inline = !!(data_len & 0x...
2011 Sep 02
1
[PATCH 2/7] hivex: Split value_key function into value_key and value_key_len
...4b9fcf0..61177d3 100644 --- a/lib/hivex.c +++ b/lib/hivex.c @@ -1189,8 +1189,8 @@ hivex_node_get_value (hive_h *h, hive_node_h node, const char *key) return ret; } -char * -hivex_value_key (hive_h *h, hive_value_h value) +size_t +hivex_value_key_len (hive_h *h, hive_value_h value) { if (!IS_VALID_BLOCK (h, value) || !BLOCK_ID_EQ (h, value, "vk")) { errno = EINVAL; @@ -1199,23 +1199,38 @@ hivex_value_key (hive_h *h, hive_value_h value) struct ntreg_vk_record *vk = (struct ntreg_vk_record *) (h->addr + value); - /* AFAIK the key is always plain ASCII, so no conversion to U...
2011 Aug 10
1
[PATCH] Report last-modified time of hive root and nodes
...ITMAP_SET(bitmap,off) (bitmap[(off)>>5] |= 1 << (((off)>>2)&7)) +#define BITMAP_CLR(bitmap,off) (bitmap[(off)>>5] &= ~ (1 << (((off)>>2)&7))) +#define BITMAP_TST(bitmap,off) (bitmap[(off)>>5] & (1 << (((off)>>2)&7))) +#define IS_VALID_BLOCK(h,off) \ + (((off) & 3) == 0 && \ + (off) >= 0x1000 && \ + (off) < (h)->size && \ + BITMAP_TST((h)->bitmap,(off))) + + /* Fields from the header, extracted from little-endian...
2010 Feb 05
13
[PATCH 01/14] hivexsh: Document some peculiarities of the "cd" command.
--- hivex/hivexsh.pod | 9 ++++++++- 1 files changed, 8 insertions(+), 1 deletions(-) diff --git a/hivex/hivexsh.pod b/hivex/hivexsh.pod index 277e3ae..9336798 100644 --- a/hivex/hivexsh.pod +++ b/hivex/hivexsh.pod @@ -100,7 +100,14 @@ or even: Path elements (node names) are matched case insensitively, and characters like space, C<*>, and C<?> have I<no> special
2016 Feb 14
2
hivex lib: Add function hivex_node_num_children
...t of node", "\ diff --git a/lib/node.c b/lib/node.c index 1fb48cf..fc3ca71 100644 --- a/lib/node.c +++ b/lib/node.c @@ -513,6 +513,22 @@ hivex_node_children (hive_h *h, hive_node_h node) return children; } +size_t +hivex_node_num_children (hive_h *h, hive_node_h node) +{ + if (!IS_VALID_BLOCK (h, node) || !block_id_eq(h, node, "nk")) { + SET_ERRNO( EINVAL, "invalid block or not an 'nk' block"); + return 0; + } + + struct ntreg_nk_record *nk = + (struct ntreg_nk_record *) ((char *) h->addr + node); + + size_t nr_subkeys_in_nk = le32toh(nk->nr...
2011 Aug 31
1
[PATCH] hivex: Add byte runs for nodes and values
...b_intern (\"len\")), INT2NUM (len));\n"; diff --git a/lib/hivex.c b/lib/hivex.c index 4b9fcf0..04ceed3 100644 --- a/lib/hivex.c +++ b/lib/hivex.c @@ -585,6 +585,30 @@ hivex_root (hive_h *h) return ret; } +size_t +hivex_node_struct_length (hive_h *h, hive_node_h node) +{ + if (!IS_VALID_BLOCK (h, node) || !BLOCK_ID_EQ (h, node, "nk")) { + errno = EINVAL; + return 0; + } + + struct ntreg_nk_record *nk = (struct ntreg_nk_record *) (h->addr + node); + size_t name_len = le16toh (nk->name_len); + /* -1 to avoid double-counting the first name character */ + size_t r...
2016 Feb 15
1
New API: node_nr_values
...'s key", "\ diff --git a/lib/value.c b/lib/value.c index 43e89f9..2dfe006 100644 --- a/lib/value.c +++ b/lib/value.c @@ -159,6 +159,22 @@ hivex_node_get_value (hive_h *h, hive_node_h node, const char *key) } size_t +hivex_node_nr_values (hive_h *h, hive_node_h node) +{ + if (!IS_VALID_BLOCK (h, node) || !block_id_eq (h, node, "nk")) { + SET_ERRNO (EINVAL, "invalid block or not an 'nk' block"); + return 0; + } + + struct ntreg_nk_record *nk = + (struct ntreg_nk_record *) ((char *) h->addr + node); + + size_t nr_values = le32toh (nk->nr_valu...
2011 May 11
3
[PATCH 1/3] hivex: Use OCaml bytecode compiler for caml_raise_with_args check
From: Hilko Bengen <bengen at hilluzination.de> On installations where no native OCaml compiler is available, the test program can't be compiled and so we get this message: ,---- | checking for function caml_raise_with_args... not found `---- This breaks building of the OCaml bindings. ,---- | gcc -std=gnu99 -I.. -I/usr/lib/ocaml -I../ocaml -I../lib -g -O2 -fPIC -Wall -c hivex_c.c
2010 Jul 07
1
[PATCH] hivex: add hivex_set_value api call and ocaml/perl bindings, tests
...+++ b/lib/hivex.c @@ -2606,3 +2606,93 @@ hivex_node_set_values (hive_h *h, hive_node_h node, return 0; } + + +int +hivex_node_set_value (hive_h *h, hive_node_h node, + const hive_set_value *val, int flags) +{ + if (!h->writable) { + errno = EROFS; + return -1; + } + + if (!IS_VALID_BLOCK (h, node) || !BLOCK_ID_EQ (h, node, "nk")) { + errno = EINVAL; + return -1; + } + + hive_value_h *prev_values = hivex_node_values (h, node); + if (prev_values == NULL) + return -1; + + int retval = -1; + + size_t nr_values = 0; + for (hive_value_h *itr = prev_values; *itr !...
2010 Jul 22
0
Fwd: [PATCH hivex] non-ASCII characters in node names
...ows_latin1_to_utf8(nk->name, len); + } else { + ret = windows_utf16_to_utf8(nk->name, len); + } return ret; } @@ -1113,6 +1111,7 @@ hivex_node_get_value (hive_h *h, hive_node_h node, const char *key) char * hivex_value_key (hive_h *h, hive_value_h value) { + iconv_t ic; if (!IS_VALID_BLOCK (h, value) || !BLOCK_ID_EQ (h, value, "vk")) { errno = EINVAL; return 0; @@ -1120,10 +1119,6 @@ hivex_value_key (hive_h *h, hive_value_h value) struct ntreg_vk_record *vk = (struct ntreg_vk_record *) (h->addr + value); - /* AFAIK the key is always plain ASCII, so no c...