qemu-devel
[Top][All Lists]
Advanced

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

Re: [PATCH v2] net/tap-win32: Fix gcc 14 format truncation errors


From: Philippe Mathieu-Daudé
Subject: Re: [PATCH v2] net/tap-win32: Fix gcc 14 format truncation errors
Date: Wed, 9 Oct 2024 00:40:43 -0300
User-agent: Mozilla Thunderbird

On 8/10/24 17:28, Bernhard Beschow wrote:
The patch fixes the following errors generated by GCC 14.2:

../src/net/tap-win32.c:343:19: error: '%s' directive output may be truncated 
writing up to 255 bytes into a region of size 176 [-Werror=format-truncation=]
   343 |              "%s\\%s\\Connection",
       |                   ^~
   344 |              NETWORK_CONNECTIONS_KEY, enum_name);
       |                                       ~~~~~~~~~

../src/net/tap-win32.c:341:9: note: 'snprintf' output between 92 and 347 bytes 
into a destination of size 256
   341 |         snprintf(connection_string,
       |         ^~~~~~~~~~~~~~~~~~~~~~~~~~~
   342 |              sizeof(connection_string),
       |              ~~~~~~~~~~~~~~~~~~~~~~~~~~
   343 |              "%s\\%s\\Connection",
       |              ~~~~~~~~~~~~~~~~~~~~~
   344 |              NETWORK_CONNECTIONS_KEY, enum_name);
       |              ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

../src/net/tap-win32.c:242:58: error: '%s' directive output may be truncated 
writing up to 255 bytes into a region of size 178 [-Werror=format-truncation=]
   242 |         snprintf (unit_string, sizeof(unit_string), "%s\\%s",
       |                                                          ^~
   243 |                   ADAPTER_KEY, enum_name);
       |                                ~~~~~~~~~

../src/net/tap-win32.c:242:9: note: 'snprintf' output between 79 and 334 bytes 
into a destination of size 256
   242 |         snprintf (unit_string, sizeof(unit_string), "%s\\%s",
       |         ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
   243 |                   ADAPTER_KEY, enum_name);
       |                   ~~~~~~~~~~~~~~~~~~~~~~~

../src/net/tap-win32.c:620:52: error: '%s' directive output may be truncated 
writing up to 255 bytes into a region of size 245 [-Werror=format-truncation=]
   620 |     snprintf (device_path, sizeof(device_path), "%s%s%s",
       |                                                    ^~
   621 |               USERMODEDEVICEDIR,
   622 |               device_guid,
       |               ~~~~~~~~~~~
../src/net/tap-win32.c:620:5: note: 'snprintf' output between 16 and 271 bytes 
into a destination of size 256
   620 |     snprintf (device_path, sizeof(device_path), "%s%s%s",
       |     ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
   621 |               USERMODEDEVICEDIR,
       |               ~~~~~~~~~~~~~~~~~~
   622 |               device_guid,
       |               ~~~~~~~~~~~~
   623 |               TAPSUFFIX);
       |               ~~~~~~~~~~

Signed-off-by: Bernhard Beschow <shentey@gmail.com>
Resolves: https://gitlab.com/qemu-project/qemu/-/issues/2607
Cc: qemu-stable@nongnu.org

--

---

Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org>


This patch was just compile-tested (which fixes my issue). Testing TAP
networking under Windows apparently requires extra drivers which I don't want to
install (not my computer). So it would be nice if someone could give this patch
a test ride. Thanks!

Changes since v1:
* Use g_autofree and g_strdup_printf() rather than fixed size arrays (Peter)
---
  net/tap-win32.c | 15 ++++++---------
  1 file changed, 6 insertions(+), 9 deletions(-)




reply via email to

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