X-Git-Url: https://wimlib.net/git/?a=blobdiff_plain;f=src%2Fregistry.c;h=5672e707eeb5c84129fc6016888f062ad24a9400;hb=9811a0b1088004bf2b8631d22cc8a2626b15c3b4;hp=8dc702fdbf0a6af815a4dadb6847ce77c508fbee;hpb=a135e7a3fa0ba112dc8da88bbce73618849a4c33;p=wimlib diff --git a/src/registry.c b/src/registry.c index 8dc702fd..5672e707 100644 --- a/src/registry.c +++ b/src/registry.c @@ -18,7 +18,7 @@ * details. * * You should have received a copy of the GNU Lesser General Public License - * along with this file; if not, see http://www.gnu.org/licenses/. + * along with this file; if not, see https://www.gnu.org/licenses/. */ #ifdef HAVE_CONFIG_H @@ -46,7 +46,7 @@ struct regf { le32 total_hbin_size; /* Total size of all hbins */ le32 f3[1013]; u8 hbin_area[0]; /* Start of hbin area */ -} _packed_attribute; +} __attribute__((packed)); /* Cell header */ @@ -56,7 +56,7 @@ struct cell { /* Magic characters which identify the cell type */ le16 magic; -} _packed_attribute; +} __attribute__((packed)); /* NK cell - represents a registry key */ struct nk { @@ -84,7 +84,7 @@ struct nk { le16 name_size; le16 unknown_0x4E; char name[0]; -} _packed_attribute; +} __attribute__((packed)); /* Subkey list cell. There are four types. LF, LH, and LI cells reference * subkey NK cells directly, while RI cells reference other subkey lists. All @@ -99,13 +99,13 @@ struct subkey_list { struct cell base; le16 num_offsets; le32 elements[0]; -} _packed_attribute; +} __attribute__((packed)); /* Value list cell - contains a list of value references */ struct value_list { le32 size; le32 vk_offsets[0]; -} _packed_attribute; +} __attribute__((packed)); /* VK cell - contains a value's data, or a reference to it */ struct vk { @@ -243,7 +243,7 @@ iterate_subkeys_recursive(const struct regf *regf, le32 subkey_list_offset, unsigned num_offsets; size_t extra_size; unsigned increment; - const le32 *p; + size_t i = 0; enum hive_status status; if (stats->levels_remaining == 0 || stats->subkey_lists_remaining == 0) @@ -270,8 +270,6 @@ iterate_subkeys_recursive(const struct regf *regf, le32 subkey_list_offset, sizeof(struct subkey_list) + extra_size)) return HIVE_CORRUPT; - p = list->elements; - switch (list->base.magic) { case LF_MAGIC: case LH_MAGIC: @@ -283,18 +281,20 @@ iterate_subkeys_recursive(const struct regf *regf, le32 subkey_list_offset, while (num_offsets--) { const struct nk *sub_nk; - sub_nk = get_cell_pointer(regf, *p, sizeof(struct nk)); + sub_nk = get_cell_pointer(regf, list->elements[i], + sizeof(struct nk)); if (!sub_nk || sub_nk->base.magic != NK_MAGIC) return HIVE_CORRUPT; - if (!revalidate_cell(regf, *p, sizeof(struct nk) + + if (!revalidate_cell(regf, list->elements[i], + sizeof(struct nk) + le16_to_cpu(sub_nk->name_size))) return HIVE_CORRUPT; status = (*cb)(sub_nk, cb_ctx); if (status != HIVE_OK) return status; - p += increment; + i += increment; } return HIVE_OK; case RI_MAGIC: @@ -302,8 +302,9 @@ iterate_subkeys_recursive(const struct regf *regf, le32 subkey_list_offset, status = HIVE_OK; stats->levels_remaining--; while (num_offsets--) { - status = iterate_subkeys_recursive(regf, *p++, - cb, cb_ctx, stats); + status = iterate_subkeys_recursive(regf, + list->elements[i++], + cb, cb_ctx, stats); if (status != HIVE_OK) break; }