From patchwork Mon Oct 7 10:13:13 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bernhard Beschow X-Patchwork-Id: 1993522 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20230601 header.b=Ooa9pLNd; dkim-atps=neutral Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=nongnu.org (client-ip=209.51.188.17; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=patchwork.ozlabs.org) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-ECDSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4XMZkX2GgJz1xsn for ; Mon, 7 Oct 2024 21:14:12 +1100 (AEDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1sxkk8-0005aB-KU; Mon, 07 Oct 2024 06:13:32 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1sxkk5-0005Z3-8b for qemu-devel@nongnu.org; Mon, 07 Oct 2024 06:13:30 -0400 Received: from mail-ed1-x534.google.com ([2a00:1450:4864:20::534]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1sxkk3-0008QK-7f for qemu-devel@nongnu.org; Mon, 07 Oct 2024 06:13:28 -0400 Received: by mail-ed1-x534.google.com with SMTP id 4fb4d7f45d1cf-5c718bb04a3so5969832a12.3 for ; Mon, 07 Oct 2024 03:13:26 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1728296005; x=1728900805; darn=nongnu.org; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc:subject:date:message-id:reply-to; bh=g3HU7O9Od7pnMPFWdwD6NFGHc9gsSGNK3QGoebqitF0=; b=Ooa9pLNdYz1/nPCPqjv9JHkiWY2rEBhJa3LT3kKgUoF9JzkNFdHpWMIagCLz1QmVpR 73bnHmgdSFUjjMCl1etHBjuj63sq+8qY5SjREQwkGUY2qlZqHp534VyWBOHW+no0vj/k h5P42efR3RGxCWzjT4+3HoZMlHCVOsCfyaVfIH3eRJf7MMLry1uVHthNqfalcCyKba7Q d43Fk0vd6vd94d8gyaGxNWY/1MjnNDhXj9sgPac/op24YEbDD6Rv1MeUZWQeXhMMB259 wWntxFWXbJ7hc0my9yGMoxKQBDNAY/iuMNW8ctsz1DpcwBgyJC32cdQ6Ho+rxNbe9VkS JPKQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1728296005; x=1728900805; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=g3HU7O9Od7pnMPFWdwD6NFGHc9gsSGNK3QGoebqitF0=; b=G50jDuk3YakP3KinzGAKdZBYxOu6QckGR/UiULHBpgGm4aG3tGzFhE4VXIJx9F8GHc X5to6UzsCJtm8jXKf5WDrlqPJCoXgWoPIpGao4z9USZL5xbpaxk/U7E9F+LHI/mafyaB +1n1pQGRgwBsgtkvpxb/0MuPl5oj2Ns6O66Y62VIGlb0IXaW4zvD2Lcdl1nTQ5MZ4ady SzpCstXCQ3+6sBHvliqoBl3EyhmmUbfTVgqoFxm75veTdr+fO25Hfw3QwN1Hi4FSOWt4 EcHxULiw/EDj3oU0LQORqC/EY4Ntol483Vt57PP6wzcgpGTKr0oH6ZIDn3G0AtqYq0yY oNgg== X-Gm-Message-State: AOJu0YysBCLQiE7JFxXjyMUw5dn1LDRn6UPSIcDlKl2p0LSJLkfNenT1 HYTtYpnUVrtp/92loJojT4Lyd/lkCyuvnV2YXkWctqWMjP+GKf5AT/dXmA== X-Google-Smtp-Source: AGHT+IFUX6JEYzvJZCLw6uK8EoUWVQHayMnnqxoyj8nfGlusb+fPf5WtET1FOHnF8jgAQs3TnX5tvg== X-Received: by 2002:a05:6402:35cb:b0:5c9:3fe:c7b9 with SMTP id 4fb4d7f45d1cf-5c903fecb4fmr145284a12.0.1728296004818; Mon, 07 Oct 2024 03:13:24 -0700 (PDT) Received: from archlinux.. ([90.187.110.129]) by smtp.gmail.com with ESMTPSA id 4fb4d7f45d1cf-5c8e05f3f07sm2995550a12.94.2024.10.07.03.13.24 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 07 Oct 2024 03:13:24 -0700 (PDT) From: Bernhard Beschow To: qemu-devel@nongnu.org Cc: Jason Wang , Stefan Weil , Bernhard Beschow Subject: [PATCH] net/tap-win32: Fix gcc 14 format truncation errors Date: Mon, 7 Oct 2024 12:13:13 +0200 Message-ID: <20241007101313.3900-1-shentey@gmail.com> X-Mailer: git-send-email 2.46.2 MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::534; envelope-from=shentey@gmail.com; helo=mail-ed1-x534.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, FREEMAIL_FROM=0.001, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org 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 --- net/tap-win32.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/net/tap-win32.c b/net/tap-win32.c index 7edbd71633..4a4625af2b 100644 --- a/net/tap-win32.c +++ b/net/tap-win32.c @@ -214,7 +214,7 @@ static int is_tap_win32_dev(const char *guid) for (;;) { char enum_name[256]; - char unit_string[256]; + char unit_string[512]; HKEY unit_key; char component_id_string[] = "ComponentId"; char component_id[256]; @@ -315,7 +315,7 @@ static int get_device_guid( while (!stop) { char enum_name[256]; - char connection_string[256]; + char connection_string[512]; HKEY connection_key; char name_data[256]; DWORD name_type; @@ -595,7 +595,7 @@ static void tap_win32_free_buffer(tap_win32_overlapped_t *overlapped, static int tap_win32_open(tap_win32_overlapped_t **phandle, const char *preferred_name) { - char device_path[256]; + char device_path[512]; char device_guid[0x100]; int rc; HANDLE handle;