On 01/02/2013 09:16 AM, Benoît Canet wrote: > Signed-off-by: Benoit Canet <ben...@irqsave.net> > --- > block/qcow2.c | 38 ++++++++++++++++++++++++++++++++++++++ > 1 file changed, 38 insertions(+) > > diff --git a/block/qcow2.c b/block/qcow2.c > index 410d3c1..9a7177b 100644 > --- a/block/qcow2.c > +++ b/block/qcow2.c > @@ -53,9 +53,16 @@ typedef struct { > uint32_t len; > } QCowExtension; > > +typedef struct { > + uint64_t offset; > + int32_t size; > + uint8_t hash_algo; > +} QCowDedupTableExtension;
This struct has a hole at the end (that is, you only specify 13 bytes, but sizeof(QCowDedupTableExtension) is 16)... > + if (s->has_dedup) { > + dedup_table_extension.offset = cpu_to_be64(s->dedup_table_offset); > + dedup_table_extension.size = cpu_to_be32(s->dedup_table_size); > + dedup_table_extension.hash_algo = s->dedup_hash_algo; > + ret = header_ext_add(buf, > + QCOW2_EXT_MAGIC_DEDUP_TABLE, > + &dedup_table_extension, > + sizeof(dedup_table_extension), > + buflen); ...but here you are writing out that hole. It would be better if you explicitly accounted for all bytes being written, so that the reserved fields are guaranteed to be 0 instead of random data, so that future extensions can make use of those reserved bytes. -- Eric Blake eblake redhat com +1-919-301-3266 Libvirt virtualization library http://libvirt.org
signature.asc
Description: OpenPGP digital signature