Conversation
|
|
||
| oapv_mdp_t *mdp_t = meta_find_mdp(md, type, uuid); | ||
| if(mdp_t == NULL) { // add new one | ||
| oapv_assert_gv(md->mdp_num < OAPV_MAX_NUM_META_PAYLOADS, ret, OAPV_ERR_REACHED_MAX, ERR); |
There was a problem hiding this comment.
OAPV_MAX_NUM_META_PAYLOADS is defined as the maximum number of metadata payloads per access unit, not per metadata group. oapvm_get_all() also checks it against the total over all groups. With a per-group check, up to 16 × 128 payloads can still be accepted by oapvm_set(), and the error only shows up later in oapvm_get_all().
It is suggested that the check count the payloads of all groups instead. Since oapvm_get_all() already has the same loop, a small static helper can be shared by both:
static int meta_get_num_mdp(oapvm_ctx_t *ctx)
{
int num = 0;
for(int i = 0; i < ctx->num; i++) {
num += ctx->md_arr[i].mdp_num;
}
return num;
}and in oapvm_set():
oapv_assert_gv(meta_get_num_mdp(ctx) < OAPV_MAX_NUM_META_PAYLOADS, ret, OAPV_ERR_REACHED_MAX, ERR);…et() Signed-off-by: Fyodor Kyslov <kyslov@google.com>
d6f7ced to
015fd1a
Compare
|
Updated per review feedback: added |
Summary
Enforces the maximum metadata payload count in
oapvm_set()(src/oapv_metadata.c):md->mdp_num < OAPV_MAX_NUM_META_PAYLOADSand returnOAPV_ERR_REACHED_MAXbefore allocating and appending a new metadata payload entry.Testing
ctestunit/conformance tests pass with AddressSanitizer and UndefinedBehaviorSanitizer.