1
0
mirror of git://sourceware.org/git/lvm2.git synced 2025-01-02 01:18:26 +03:00

vdo: reader checks there is enough data

Validate enough of data was read from disk to parse vdo header.
TODO: there should be a loop for buffer reading.
This commit is contained in:
Zdenek Kabelac 2024-10-30 11:44:54 +01:00
parent 8095a6c14c
commit 699696b0a6

View File

@ -226,7 +226,7 @@ bool dm_vdo_parse_logical_size(const char *vdo_path, uint64_t *logical_blocks)
size = st.st_size;
}
if (read(fh, buffer, sizeof(buffer)) < 0) {
if (read(fh, buffer, sizeof(buffer)) < (MAGIC_NUMBER_SIZE + sizeof(h))) {
log_sys_debug("read", vdo_path);
goto err;
}
@ -270,7 +270,7 @@ bool dm_vdo_parse_logical_size(const char *vdo_path, uint64_t *logical_blocks)
goto err;
}
if (read(fh, buffer, sizeof(buffer)) < 0) {
if (read(fh, buffer, sizeof(buffer)) < (sizeof(struct vdo_geometry_block) + sizeof(vn))) {
log_sys_debug("read", vdo_path);
goto err;
}