X-Git-Url: https://wimlib.net/git/?p=wimlib;a=blobdiff_plain;f=src%2Fregistry.c;h=8dc702fdbf0a6af815a4dadb6847ce77c508fbee;hp=f7eca9ab1d26721afb60561e092e1111944086f4;hb=088dff37aa334c218e1cac96cc847f5dd14f7124;hpb=4e32f48feb64932954953a87f064170500f93221 diff --git a/src/registry.c b/src/registry.c index f7eca9ab..8dc702fd 100644 --- a/src/registry.c +++ b/src/registry.c @@ -193,16 +193,16 @@ get_cell_pointer(const struct regf *regf, le32 offset, size_t wanted_size) u32 total = le32_to_cpu(regf->total_hbin_size); u32 offs = le32_to_cpu(offset); const struct cell *cell; - s32 actual_size; + u32 actual_size; if ((offs > total) || (offs & 7) || (wanted_size > total - offs)) return NULL; cell = (const struct cell *)®f->hbin_area[offs]; - actual_size = le32_to_cpu(cell->size); - if (actual_size >= 0) /* Cell not in use? */ + actual_size = -le32_to_cpu(cell->size); + if (actual_size > INT32_MAX) /* Cell unused, or size was INT32_MIN? */ return NULL; - if (wanted_size > -actual_size) /* Cell too small? */ + if (wanted_size > actual_size) /* Cell too small? */ return NULL; return cell; } @@ -353,7 +353,7 @@ lookup_subkey_cb(const struct nk *sub_nk, void *_ctx) if (names_equal(ctx->key_name, ctx->key_name_nchars, sub_nk->name, le16_to_cpu(sub_nk->name_size), - (sub_nk->flags & NK_COMPRESSED_NAME))) + (sub_nk->flags & NK_COMPRESSED_NAME) != 0)) { ctx->result = sub_nk; return HIVE_ITERATION_STOPPED; @@ -489,7 +489,7 @@ lookup_value(const struct regf *regf, const tchar *key_name, if (names_equal(value_uname, value_uname_nchars, vk->name, name_size, - (vk->flags & VK_COMPRESSED_NAME))) + (vk->flags & VK_COMPRESSED_NAME) != 0)) { *vk_ret = vk; status = HIVE_OK;