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

Re: [PATCH v3] tools/libs/stat: fix broken build


  • To: Jürgen Groß <jgross@xxxxxxxx>, Bertrand Marquis <Bertrand.Marquis@xxxxxxx>
  • From: Andrew Cooper <andrew.cooper3@xxxxxxxxxx>
  • Date: Fri, 2 Oct 2020 12:05:19 +0100
  • Authentication-results: esa5.hc3370-68.iphmx.com; dkim=none (message not signed) header.i=none
  • Cc: "open list:X86" <xen-devel@xxxxxxxxxxxxxxxxxxxx>, Ian Jackson <iwj@xxxxxxxxxxxxxx>, Wei Liu <wl@xxxxxxx>
  • Delivery-date: Fri, 02 Oct 2020 11:05:29 +0000
  • Ironport-sdr: ZzOvdlpDCPo1BFRgQe3Ch+tkC/gsBLxEDueoj12E3vfP/UWVt7mBYJZsdn+w92KwRnW9eq+7TW NYZTNTkR3H5W1lA1voZwKdTBNVKOEVTfB+zQfw5FCewF5Oul66e6iCZsNBrrCjYAt02jKkHfBJ nGdGgh5pV4Ving88bGNxtSTrfHuKGeGft3jk6j5uh3b20m+kL50bgJIL0aTUzJ9S0wnAOoHADJ Yxo1zRgs9fTaxjZaylrs61LMSu5xq2PxeZgJTgfz3Lms4WPBYBCpj6Kp1aqYExfZN68XhOHbXP 0Ew=
  • List-id: Xen developer discussion <xen-devel.lists.xenproject.org>

On 02/10/2020 05:50, Jürgen Groß wrote:
> On 01.10.20 18:38, Bertrand Marquis wrote:
>> Hi Juergen,
>>
>>> On 14 Sep 2020, at 11:58, Bertrand Marquis
>>> <bertrand.marquis@xxxxxxx> wrote:
>>>
>>>
>>>
>>>> On 12 Sep 2020, at 14:08, Juergen Gross <jgross@xxxxxxxx> wrote:
>>>>
>>>> Making getBridge() static triggered a build error with some gcc
>>>> versions:
>>>>
>>>> error: 'strncpy' output may be truncated copying 15 bytes from a
>>>> string of
>>>> length 255 [-Werror=stringop-truncation]
>>>>
>>>> Fix that by using a buffer with 256 bytes instead.
>>>>
>>>> Fixes: 6d0ec053907794 ("tools: split libxenstat into new
>>>> tools/libs/stat directory")
>>>> Signed-off-by: Juergen Gross <jgross@xxxxxxxx>
>>> Reviewed-by: Bertrand Marquis <bertrand.marquis@xxxxxxx>
>>
>> Sorry i have to come back on this one.
>>
>> I still see an error compiling with Yocto on this one:
>> |     inlined from 'xenstat_collect_networks' at xenstat_linux.c:306:2:
>> | xenstat_linux.c:81:6: error: 'strncpy' output may be truncated
>> copying 255 bytes from a string of length 255
>> [-Werror=stringop-truncation]
>> |    81 |      strncpy(result, de->d_name, resultLen);
>> |       |      ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
>>
>> To solve it, I need to define devBridge[257] as devNoBrideg.
>
> IMHO this is a real compiler error.
>
> de->d_name is an array of 256 bytes, so doing strncpy() from that to
> another array of 256 bytes with a length of 256 won't truncate anything.
>
> Making devBridge one byte longer would be dangerous, as this would do
> a strncpy with length of 257 from a source with a length of 256 bytes
> only.
>
> BTW, I think Andrew? has tested my patch with a recent gcc which threw
> the original error without my patch, and it was fine with the patch.
> Either your compiler (assuming you are using gcc) has gained that error
> or you are missing an update fixing it.

All I was doing was using the gitlab CI, and reporting the failing tests.

~Andrew



 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.