Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

DAOS-16466 object: Fix obj_ec_singv_split overflow #15045

Merged
merged 1 commit into from
Sep 10, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 5 additions & 3 deletions src/object/cli_ec.c
Original file line number Diff line number Diff line change
Expand Up @@ -1408,13 +1408,15 @@ obj_ec_singv_split(daos_unit_oid_t oid, uint16_t layout_ver, struct daos_oclass_
{
uint64_t c_bytes = obj_ec_singv_cell_bytes(iod_size, oca);
uint32_t tgt_off = obj_ec_shard_off_by_layout_ver(layout_ver, dkey_hash, oca, oid.id_shard);
uint64_t tgt_size = min(c_bytes, iod_size - tgt_off * c_bytes);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

may with D_ASSERT(iod_size > tgt_off * c_bytes).

char *data = sgl->sg_iovs[0].iov_buf;

D_ASSERT(iod_size != DAOS_REC_ANY);
D_ASSERTF(iod_size != DAOS_REC_ANY && iod_size == sgl->sg_iovs[0].iov_len,
DF_U64 " == %zu\n", iod_size, sgl->sg_iovs[0].iov_len);
if (tgt_off > 0)
memmove(data, data + tgt_off * c_bytes, c_bytes);
memmove(data, data + tgt_off * c_bytes, tgt_size);

sgl->sg_iovs[0].iov_len = c_bytes;
sgl->sg_iovs[0].iov_len = tgt_size;
return 0;
}

Expand Down
Loading