* [PATCH] tap-win32: Ignore keys too long
@ 2024-11-07 9:48 Akihiko Odaki
2024-11-07 9:52 ` Daniel P. Berrangé
0 siblings, 1 reply; 2+ messages in thread
From: Akihiko Odaki @ 2024-11-07 9:48 UTC (permalink / raw)
To: Jason Wang, Stefan Weil; +Cc: qemu-devel, devel, Akihiko Odaki
Registry keys get truncated and trigger -Wformat-truncation. Ignore
such truncated keys as they are invalid.
Signed-off-by: Akihiko Odaki <akihiko.odaki@daynix.com>
---
net/tap-win32.c | 28 ++++++++++++++++++----------
1 file changed, 18 insertions(+), 10 deletions(-)
diff --git a/net/tap-win32.c b/net/tap-win32.c
index 7edbd7163370..4081ba87991f 100644
--- a/net/tap-win32.c
+++ b/net/tap-win32.c
@@ -239,8 +239,12 @@ static int is_tap_win32_dev(const char *guid)
return FALSE;
}
- snprintf (unit_string, sizeof(unit_string), "%s\\%s",
- ADAPTER_KEY, enum_name);
+ len = snprintf(unit_string, sizeof(unit_string), "%s\\%s",
+ ADAPTER_KEY, enum_name);
+ if (len >= sizeof(unit_string)) {
+ ++i;
+ continue;
+ }
status = RegOpenKeyEx(
HKEY_LOCAL_MACHINE,
@@ -338,10 +342,13 @@ static int get_device_guid(
return -1;
}
- snprintf(connection_string,
- sizeof(connection_string),
- "%s\\%s\\Connection",
- NETWORK_CONNECTIONS_KEY, enum_name);
+ len = snprintf(connection_string, sizeof(connection_string),
+ "%s\\%s\\Connection",
+ NETWORK_CONNECTIONS_KEY, enum_name);
+ if (len >= sizeof(connection_string)) {
+ ++i;
+ continue;
+ }
status = RegOpenKeyEx(
HKEY_LOCAL_MACHINE,
@@ -617,10 +624,11 @@ static int tap_win32_open(tap_win32_overlapped_t **phandle,
if (rc)
return -1;
- snprintf (device_path, sizeof(device_path), "%s%s%s",
- USERMODEDEVICEDIR,
- device_guid,
- TAPSUFFIX);
+ rc = snprintf(device_path, sizeof(device_path), "%s%s%s",
+ USERMODEDEVICEDIR, device_guid, TAPSUFFIX);
+ if (rc >= sizeof(device_path)) {
+ return -1;
+ }
handle = CreateFile (
device_path,
---
base-commit: 7e3b6d8063f245d27eecce5aabe624b5785f2a77
change-id: 20241107-win32-b8f0d15c9122
Best regards,
--
Akihiko Odaki <akihiko.odaki@daynix.com>
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH] tap-win32: Ignore keys too long
2024-11-07 9:48 [PATCH] tap-win32: Ignore keys too long Akihiko Odaki
@ 2024-11-07 9:52 ` Daniel P. Berrangé
0 siblings, 0 replies; 2+ messages in thread
From: Daniel P. Berrangé @ 2024-11-07 9:52 UTC (permalink / raw)
To: Akihiko Odaki; +Cc: Jason Wang, Stefan Weil, qemu-devel, devel
On Thu, Nov 07, 2024 at 06:48:44PM +0900, Akihiko Odaki wrote:
> Registry keys get truncated and trigger -Wformat-truncation. Ignore
> such truncated keys as they are invalid.
>
> Signed-off-by: Akihiko Odaki <akihiko.odaki@daynix.com>
> ---
> net/tap-win32.c | 28 ++++++++++++++++++----------
> 1 file changed, 18 insertions(+), 10 deletions(-)
These problems were already fixed by changing to g_strdup_printf
commit 75fe36b4e8a994cdf9fd6eb601f49e96b1bc791d
Author: Bernhard Beschow <shentey@gmail.com>
Date: Tue Oct 8 22:28:42 2024 +0200
net/tap-win32: Fix gcc 14 format truncation errors
>
> diff --git a/net/tap-win32.c b/net/tap-win32.c
> index 7edbd7163370..4081ba87991f 100644
> --- a/net/tap-win32.c
> +++ b/net/tap-win32.c
> @@ -239,8 +239,12 @@ static int is_tap_win32_dev(const char *guid)
> return FALSE;
> }
>
> - snprintf (unit_string, sizeof(unit_string), "%s\\%s",
> - ADAPTER_KEY, enum_name);
> + len = snprintf(unit_string, sizeof(unit_string), "%s\\%s",
> + ADAPTER_KEY, enum_name);
> + if (len >= sizeof(unit_string)) {
> + ++i;
> + continue;
> + }
>
> status = RegOpenKeyEx(
> HKEY_LOCAL_MACHINE,
> @@ -338,10 +342,13 @@ static int get_device_guid(
> return -1;
> }
>
> - snprintf(connection_string,
> - sizeof(connection_string),
> - "%s\\%s\\Connection",
> - NETWORK_CONNECTIONS_KEY, enum_name);
> + len = snprintf(connection_string, sizeof(connection_string),
> + "%s\\%s\\Connection",
> + NETWORK_CONNECTIONS_KEY, enum_name);
> + if (len >= sizeof(connection_string)) {
> + ++i;
> + continue;
> + }
>
> status = RegOpenKeyEx(
> HKEY_LOCAL_MACHINE,
> @@ -617,10 +624,11 @@ static int tap_win32_open(tap_win32_overlapped_t **phandle,
> if (rc)
> return -1;
>
> - snprintf (device_path, sizeof(device_path), "%s%s%s",
> - USERMODEDEVICEDIR,
> - device_guid,
> - TAPSUFFIX);
> + rc = snprintf(device_path, sizeof(device_path), "%s%s%s",
> + USERMODEDEVICEDIR, device_guid, TAPSUFFIX);
> + if (rc >= sizeof(device_path)) {
> + return -1;
> + }
>
> handle = CreateFile (
> device_path,
>
> ---
> base-commit: 7e3b6d8063f245d27eecce5aabe624b5785f2a77
> change-id: 20241107-win32-b8f0d15c9122
>
> Best regards,
> --
> Akihiko Odaki <akihiko.odaki@daynix.com>
>
>
With regards,
Daniel
--
|: https://berrange.com -o- https://www.flickr.com/photos/dberrange :|
|: https://libvirt.org -o- https://fstop138.berrange.com :|
|: https://entangle-photo.org -o- https://www.instagram.com/dberrange :|
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2024-11-07 9:53 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-11-07 9:48 [PATCH] tap-win32: Ignore keys too long Akihiko Odaki
2024-11-07 9:52 ` Daniel P. Berrangé
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).