From patchwork Tue Aug 25 06:29:02 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Benjamin Berg X-Patchwork-Id: 1350828 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=none (no SPF record) smtp.mailfrom=lists.infradead.org (client-ip=2001:8b0:10b:1231::1; helo=merlin.infradead.org; envelope-from=hostap-bounces+incoming=patchwork.ozlabs.org@lists.infradead.org; receiver=) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=sipsolutions.net Authentication-Results: ozlabs.org; dkim=pass (2048-bit key; secure) header.d=lists.infradead.org header.i=@lists.infradead.org header.a=rsa-sha256 header.s=merlin.20170209 header.b=u3dB8QPQ; dkim=fail reason="signature verification failed" (2048-bit key; secure) header.d=infradead.org header.i=@infradead.org header.a=rsa-sha256 header.s=casper.20170209 header.b=PKXfe0VX; dkim-atps=neutral Received: from merlin.infradead.org (merlin.infradead.org [IPv6:2001:8b0:10b:1231::1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 4BbJz61wgVz9sTK for ; Tue, 25 Aug 2020 16:30:58 +1000 (AEST) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=merlin.20170209; h=Sender:Content-Transfer-Encoding: Content-Type:Cc:List-Subscribe:List-Help:List-Post:List-Archive: List-Unsubscribe:List-Id:MIME-Version:Message-Id:Date:Subject:To:From: Reply-To:Content-ID:Content-Description:Resent-Date:Resent-From:Resent-Sender :Resent-To:Resent-Cc:Resent-Message-ID:In-Reply-To:References:List-Owner; bh=kNnDkPtJ0Xkgx6+Q/NbZy9pcCfDC34ya5X7+bVr8Ots=; b=u3dB8QPQSw25n2xAd32YLhG2Yx Z8D+u0kY66Zk6YmzFYwepksz+MhAKAb558b1RuOfgFW/6O/+YXfQOWVHfUXxTkum1vcZmEhMvT2dJ p79JVp29aSgHcrGPyBH3c8XL0lSCBp5UlL8cQ5n5OPLD6aKwvYH8bbUBmet3Ue3KJ3/cEJFhhWWmp RIVk3x0u8Shbk2+FVf+GzdDykDGSx7oDkoGqjexuDBxRrb3fyVLeCWvfGvJtAoY8MOmAmpfn36leA JM8d0pKkxqmFTKe1ES4C8LYKUHHxzkkO315Uof0n89CqRu27P4f26pztA9F4rz9OGaw4//G6OoSJn 9fx8FNpw==; Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.92.3 #3 (Red Hat Linux)) id 1kAST9-0004Td-Nr; Tue, 25 Aug 2020 06:30:07 +0000 Received: from casper.infradead.org ([2001:8b0:10b:1236::1]) by merlin.infradead.org with esmtps (Exim 4.92.3 #3 (Red Hat Linux)) id 1kAST7-0004TC-9a for hostap@merlin.infradead.org; Tue, 25 Aug 2020 06:30:05 +0000 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=casper.20170209; h=Content-Transfer-Encoding:MIME-Version: Message-Id:Date:Subject:Cc:To:From:Sender:Reply-To:Content-Type:Content-ID: Content-Description:In-Reply-To:References; bh=zblKWhmzd7MWGLUbfUuXwUwa2iTMnUEwm6CO9GsCmOI=; b=PKXfe0VXfHTBT0fedOs70Qhjon Oiv12ri1ApSugB9t2t6XcCTvVx20/6gin3I6dVsGQ3KHXQtT0uk9W3HG9aJSK5+AUk3jQaNwMM2IA EByCYoHoghbrfJG54iyqjFy5LFtc3558cW2p5l+oslukMgY0euFsbUjcaygvVbNwWF5Jxk/uYEQWQ 3fsB5NYHX5kiJmCZn/7/CxSke42dpN2ZV9Va+U9XHJI+PR8hx25PHI1Fw6CKSA23LcRx/0/DAR5En 2LJhTSw3VofwpItiVn897dHqmfZFg6RvYh6KoRVi3VBzS2uINWeTjllY5gIIwqG7qyvFKIJdZoSom 8oCbWMGg==; Received: from s3.sipsolutions.net ([2a01:4f8:191:4433::2] helo=sipsolutions.net) by casper.infradead.org with esmtps (Exim 4.92.3 #3 (Red Hat Linux)) id 1kAST3-0007hl-U5 for hostap@lists.infradead.org; Tue, 25 Aug 2020 06:30:04 +0000 Received: by sipsolutions.net with esmtpsa (TLS1.3:ECDHE_X25519__RSA_PSS_RSAE_SHA256__AES_256_GCM:256) (Exim 4.94) (envelope-from ) id 1kASSt-00AJz4-LT; Tue, 25 Aug 2020 08:29:51 +0200 From: Benjamin Berg To: hostap@lists.infradead.org Subject: [PATCH RESEND] p2p: Limit P2P_DEVICE name to appropriate ifname size Date: Tue, 25 Aug 2020 08:29:02 +0200 Message-Id: <20200825062902.124600-1-benjamin@sipsolutions.net> X-Mailer: git-send-email 2.26.2 MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20200825_073002_148531_AF0C2E12 X-CRM114-Status: UNSURE ( 8.94 ) X-CRM114-Notice: Please train this message. X-Spam-Score: -1.5 (-) X-Spam-Report: SpamAssassin version 3.4.4 on casper.infradead.org summary: Content analysis details: (-1.5 points, 5.0 required) pts rule name description ---- ---------------------- -------------------------------------------------- -1.9 BAYES_00 BODY: Bayes spam probability is 0 to 1% [score: 0.0000] 0.0 SPF_HELO_NONE SPF: HELO does not publish an SPF Record 0.0 SPF_NONE SPF: sender does not publish an SPF Record 0.4 KHOP_HELO_FCRDNS Relay HELO differs from its IP's reverse DNS X-BeenThere: hostap@lists.infradead.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Benjamin Berg Sender: "Hostap" Errors-To: hostap-bounces+incoming=patchwork.ozlabs.org@lists.infradead.org From: Benjamin Berg Otherwise the WPA_IF_P2P_DEVICE cannot be created. As this is not a netdev device, it is acceptable if the name is not completely unique. As such, simply insert a NUL byte at the appropriate place. Signed-off-by: Benjamin Berg --- wpa_supplicant/p2p_supplicant.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/wpa_supplicant/p2p_supplicant.c b/wpa_supplicant/p2p_supplicant.c index e94bffe52..17c25889c 100644 --- a/wpa_supplicant/p2p_supplicant.c +++ b/wpa_supplicant/p2p_supplicant.c @@ -3929,6 +3929,10 @@ int wpas_p2p_add_p2pdev_interface(struct wpa_supplicant *wpa_s, wpa_s->ifname); if (os_snprintf_error(sizeof(ifname), ret)) return -1; + /* Cut length at the maximum size. Note that we don't need to ensure + * collision free names here as the created interface is not a netdev. + */ + ifname[IFNAMSIZ-1] = '\0'; force_name[0] = '\0'; wpa_s->pending_interface_type = WPA_IF_P2P_DEVICE; ret = wpa_drv_if_add(wpa_s, WPA_IF_P2P_DEVICE, ifname, NULL, NULL,