[Libguestfs] [PATCH hivex 11/19] lib: get_children: Use offset_list limits to limit length of returned lists.

Richard W.M. Jones rjones at redhat.com
Thu Jul 25 10:38:53 UTC 2013


From: "Richard W.M. Jones" <rjones at redhat.com>

This will allow us to change the function to work recursively, and
still enforce these limits.
---
 lib/node.c | 10 ++++++++++
 1 file changed, 10 insertions(+)

diff --git a/lib/node.c b/lib/node.c
index 326b913..1255a84 100644
--- a/lib/node.c
+++ b/lib/node.c
@@ -229,6 +229,16 @@ _hivex_get_children (hive_h *h, hive_node_h node,
     goto error;
   }
 
+  /* Don't read mode child nodes than the declared number of subkeys. */
+  _hivex_set_offset_list_limit (&children, nr_subkeys_in_nk);
+
+  /* Pre-1.3.8 hivex did not limit the number of intermediate blocks
+   * it would return, and there is no obvious limit to use.  However
+   * if we ever exceeded HIVEX_MAX_SUBKEYS then there's something
+   * fishy going on.
+   */
+  _hivex_set_offset_list_limit (&blocks, HIVEX_MAX_SUBKEYS);
+
   /* Preallocate space for the children. */
   if (_hivex_grow_offset_list (&children, nr_subkeys_in_nk) == -1)
     goto error;
-- 
1.8.3.1




More information about the Libguestfs mailing list