Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from phobos.denx.de (phobos.denx.de [85.214.62.61]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id CFB36C021B0 for ; Wed, 19 Feb 2025 10:49:28 +0000 (UTC) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id C2BD580F7B; Wed, 19 Feb 2025 11:49:00 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=pass (p=quarantine dis=none) header.from=ti.com Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de Authentication-Results: phobos.denx.de; dkim=pass (1024-bit key; unprotected) header.d=ti.com header.i=@ti.com header.b="rzyyvwRN"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 0E0BF80EBD; Wed, 19 Feb 2025 11:48:56 +0100 (CET) Received: from fllvem-ot03.ext.ti.com (fllvem-ot03.ext.ti.com [198.47.19.245]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by phobos.denx.de (Postfix) with ESMTPS id 0F1EF80A46 for ; Wed, 19 Feb 2025 11:48:51 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=pass (p=quarantine dis=none) header.from=ti.com Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=c-vankar@ti.com Received: from fllv0035.itg.ti.com ([10.64.41.0]) by fllvem-ot03.ext.ti.com (8.15.2/8.15.2) with ESMTPS id 51JAmacf1786643 (version=TLSv1.2 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 19 Feb 2025 04:48:36 -0600 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ti.com; s=ti-com-17Q1; t=1739962116; bh=3oe6hc1FlJj0pZNvOkxG4ie7mEhDNgtb3xJ4zp53PvQ=; h=From:To:CC:Subject:Date:In-Reply-To:References; b=rzyyvwRN20sDw0mJSPPdrwNV2INWSq0FLB2soD9qZ5jIcKAbVm2bVeeZVVaItAX+j drlt5uBoa251y6zWz4B15XKD2tQvFGVJDaMo7fkNUaFrR3fCKfHJoPLH0epgZw+eGP tun0imP/Cs4Q51PycFcHXPMSESTfepAMyTHRK+Js= Received: from DLEE106.ent.ti.com (dlee106.ent.ti.com [157.170.170.36]) by fllv0035.itg.ti.com (8.15.2/8.15.2) with ESMTPS id 51JAmaXn013293 (version=TLSv1.2 cipher=AES256-GCM-SHA384 bits=256 verify=FAIL); Wed, 19 Feb 2025 04:48:36 -0600 Received: from DLEE107.ent.ti.com (157.170.170.37) by DLEE106.ent.ti.com (157.170.170.36) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256_P256) id 15.1.2507.23; Wed, 19 Feb 2025 04:48:35 -0600 Received: from lelvsmtp6.itg.ti.com (10.180.75.249) by DLEE107.ent.ti.com (157.170.170.37) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256_P256) id 15.1.2507.23 via Frontend Transport; Wed, 19 Feb 2025 04:48:35 -0600 Received: from localhost (chintan-thinkstation-p360-tower.dhcp.ti.com [172.24.227.220]) by lelvsmtp6.itg.ti.com (8.15.2/8.15.2) with ESMTP id 51JAmZNp030167; Wed, 19 Feb 2025 04:48:35 -0600 From: Chintan Vankar To: Christian Marangi , Ilias Apalodimas , Mikhail Kshevetskiy , Sughosh Ganu , Simon Glass , Michael Walle , "Roger Quadros" , Matthias Schiffer , Santhosh Kumar K , "Hari Nagalla" , Nishanth Menon , Jonathan Humphreys , Andreas Dannenberg , "Kishon Vijay Abraham I" , Joao Paulo Goncalves , Siddharth Vadapalli , Alexander Sverdlin , Wadim Egorov , "Udit Kumar" , Neha Malcom Francis , Andrew Davis , Chintan Vankar , Ramon Fried , Joe Hershberger , "Bryan Brattlof" , Vignesh Raghavendra , Manorit Chawdhry , Tom Rini CC: Subject: [PATCH v2 01/13] net: tftp: Increase TFTP pkt string length to include null character Date: Wed, 19 Feb 2025 16:18:19 +0530 Message-ID: <20250219104831.2315464-2-c-vankar@ti.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20250219104831.2315464-1-c-vankar@ti.com> References: <20250219104831.2315464-1-c-vankar@ti.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Content-Type: text/plain X-C2ProcessedOrg: 333ef613-75bf-4e12-a4b1-8e3623f5dcea X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.39 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" X-Virus-Scanned: clamav-milter 0.103.8 at phobos.denx.de X-Virus-Status: Clean To append a string to a tftp pkt, "tftp_send()" API invokes "sprintf()" function which copies a string excluding a null character causing TFTP not-null terminated string error. Increase TFTP pkt string by 1 to avoid this error. Signed-off-by: Chintan Vankar --- Link to v1: https://lore.kernel.org/r/20250107093840.2211381-2-c-vankar@ti.com/ Changes from v1 to v2: -> Updated commit message. net/tftp.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/net/tftp.c b/net/tftp.c index fd9c9492929..420ea9ecf6c 100644 --- a/net/tftp.c +++ b/net/tftp.c @@ -347,11 +347,11 @@ static void tftp_send(void) pkt += strlen((char *)pkt) + 1; #ifdef CONFIG_TFTP_TSIZE pkt += sprintf((char *)pkt, "tsize%c%u%c", - 0, net_boot_file_size, 0); + 0, net_boot_file_size, 0) + 1; #endif /* try for more effic. blk size */ pkt += sprintf((char *)pkt, "blksize%c%d%c", - 0, tftp_block_size_option, 0); + 0, tftp_block_size_option, 0) + 1; /* try for more effic. window size. * Implemented only for tftp get. @@ -359,7 +359,7 @@ static void tftp_send(void) */ if (tftp_state == STATE_SEND_RRQ && tftp_window_size_option > 1) pkt += sprintf((char *)pkt, "windowsize%c%d%c", - 0, tftp_window_size_option, 0); + 0, tftp_window_size_option, 0) + 1; len = pkt - xp; break; -- 2.34.1