On Thu 30 Apr 2015 05:08:05 PM CEST, Eric Blake <ebl...@redhat.com> wrote:

>>  typedef struct Qcow2CachedTable {
>> -    void*   table;
>>      int64_t offset;
>>      bool    dirty;
>>      int     cache_hits;
>> @@ -40,39 +39,34 @@ struct Qcow2Cache {
>>      struct Qcow2Cache*      depends;
>>      int                     size;
>>      bool                    depends_on_flush;
>> +    void                   *table_array;
>> +    int                     table_size;
>
> Should this be size_t? [1]

The maximum supported table size is 2MB (MAX_CLUSTER_BITS == 21).

>>      c->entries = g_try_new0(Qcow2CachedTable, num_tables);
>> -    if (!c->entries) {
>> -        goto fail;
>> -    }
>> +    c->table_array = qemu_try_blockalign(bs->file, num_tables * 
>> c->table_size);
>
> Are we sure this won't overflow?

That's a good catch. I was making some numbers and I doubt that scenario
would happen in practice, but I think it's possible so I'll fix it.

Berto

Reply via email to