[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [PATCH v3] i386: Fix GCC warning with snprintf when HAX is enabled
From: |
Paolo Bonzini |
Subject: |
Re: [PATCH v3] i386: Fix GCC warning with snprintf when HAX is enabled |
Date: |
Mon, 2 Mar 2020 09:03:38 +0100 |
User-agent: |
Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101 Thunderbird/68.4.1 |
On 02/03/20 02:58, Julio Faracco wrote:
> Sorry my ignorance, Paolo.
> But why should I remove MAX_{VM,VCPU}_ID?
>
> Did you mean that check?
> if (vm_id > MAX_VM_ID || vcpu_id > MAX_VCPU_ID) {
> fprintf(stderr, "Too big vm id %x or vcpu id %x\n", vm_id, vcpu_id);
> return NULL;
> }
>
> Wouldn't it be dangerous?
No, the check is only needed to avoid the buffer truncation from
snprintf. If you use g_strdup_printf it's not needed anymore because
there can be no truncation.
Paolo