qemu-trivial
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [PATCH] target/i386/hax-posix: fix two 'format-truncation' compile w


From: Pan Nengyuan
Subject: Re: [PATCH] target/i386/hax-posix: fix two 'format-truncation' compile warnings
Date: Tue, 3 Mar 2020 18:58:40 +0800
User-agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:68.0) Gecko/20100101 Thunderbird/68.2.2


On 3/3/2020 6:47 PM, Paolo Bonzini wrote:
> On 24/02/20 07:51, address@hidden wrote:
>> diff --git a/target/i386/hax-posix.c b/target/i386/hax-posix.c
>> index a5426a6dac..197d5bc0f9 100644
>> --- a/target/i386/hax-posix.c
>> +++ b/target/i386/hax-posix.c
>> @@ -121,7 +121,8 @@ static char *hax_vm_devfs_string(int vm_id)
>>          return NULL;
>>      }
>>  
>> -    snprintf(name, sizeof HAX_VM_DEVFS, "/dev/hax_vm/vm%02d", vm_id);
>> +    int len = snprintf(name, sizeof HAX_VM_DEVFS, "/dev/hax_vm/vm%02d", 
>> vm_id);
>> +    assert(len < sizeof HAX_VM_DEVFS);
>>      return name;
>>  }
>>  
>> @@ -140,8 +141,9 @@ static char *hax_vcpu_devfs_string(int vm_id, int 
>> vcpu_id)
>>          return NULL;
>>      }
>>  
>> -    snprintf(name, sizeof HAX_VCPU_DEVFS, "/dev/hax_vm%02d/vcpu%02d",
>> -             vm_id, vcpu_id);
>> +    int len = snprintf(name, sizeof HAX_VCPU_DEVFS, 
>> "/dev/hax_vm%02d/vcpu%02d",
>> +                       vm_id, vcpu_id);
>> +    assert(len < sizeof HAX_VCPU_DEVFS);
>>      return name;
>>  }
>>  
>>
> 
> Julio Faracco has posted a fix for the same bug.  The best change is
> actually to switch to g_strdup_printf.

Okay, Thanks.

> 
> Paolo
> 



reply via email to

[Prev in Thread] Current Thread [Next in Thread]