From patchwork Tue Mar 4 10:57:41 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sughosh Ganu X-Patchwork-Id: 870105 Delivered-To: patch@linaro.org Received: by 2002:a05:6000:178f:b0:38f:210b:807b with SMTP id e15csp188099wrg; Tue, 4 Mar 2025 02:58:33 -0800 (PST) X-Forwarded-Encrypted: i=2; AJvYcCXDoeEGb3E+beRdLMCsX7F8eIVwEyLYRo6KLzBWCMXo0kGixez86I5JzlDXsI1WKpU609Kvuw==@linaro.org X-Google-Smtp-Source: AGHT+IHaGiTxIXk131Q+j0/GX+rF3p7aG0vjsg/3Jue/REY6u3r2DsfSXFlCUC0SHZU/dd2q/1ym X-Received: by 2002:a17:90b:3d4c:b0:2fa:b8e:3d26 with SMTP id 98e67ed59e1d1-2febac08885mr26420891a91.30.1741085912983; Tue, 04 Mar 2025 02:58:32 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1741085912; cv=none; d=google.com; s=arc-20240605; b=ZlKpJWEq3qUN2YOPYnQyqg7WE/WGas/FbZfX/nQuBcmZnIBxl2O6CbBeZyJyv/0f3G 6xfxFOYlVFfKAEI8iw7eDgu1w02/1cS6KktOr2mqDiAVDVHX7l0BEa8rNVFcSlqMLjoi oRkQ7j32ZJJFWZCm2Rql8SkcaMqqxSc7+tmxppAt4k1L1mSYIjvu9cGFuCv0Acy9sZTt aB7rYhzThomCrwlHlIQW8nf/SqISzdCgCjroAF0ZD9E1BynQrwgEriyocRjaXVsuPYxR 7Edya5lCnsLoHA4yb6danSdW5sDn+ielm83UsnQnW+A3665kQqQ/lBINi/kUfPTCE3gg 4H1Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20240605; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:message-id:date:subject:cc:to:from; bh=ooNYFDhBDuATBoCnvNyKevOVbHtDJv0Q3rB0yrtcBpM=; fh=I5RjAo6fuk58zcB0VLu981sKDSSZIKIyWO7LkWnGF8w=; b=Zjxeh7gHLXs4G3lyMMWREzTZvlhInHaDhTuhsHqe2Stq0mTFHuTUDR1mUfO2owPEvl GRUPX+u/BSqe+RfB5A4CsgGdPrMWVTtD4cbqXrisOXTgBYIeYrXyKXGAnAiw+gE3E7Rx p6JWyhynXGfaz2GOkkd3A1paOR7/od9Kz4WyDrKX/ktF/6zgpnFWn7aA3Wl3aKs+b0Dw O4RftJUa4zNcbbmHVC7GSwSn14V+zI+l+KwB8iFAm1X9xGw2bsmJrcGYCG1PQWBDA9vw nFtvYvRwzrdwuun8W8YLIEwqRw+96UkBKkh9QGcszyLMEKzlkx6rZEMr3CxTHxzdPq9z ArPA==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of u-boot-bounces@lists.denx.de designates 85.214.62.61 as permitted sender) smtp.mailfrom=u-boot-bounces@lists.denx.de; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from phobos.denx.de (phobos.denx.de. [85.214.62.61]) by mx.google.com with ESMTPS id 98e67ed59e1d1-2fea698f9b0si16829479a91.125.2025.03.04.02.58.32 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 04 Mar 2025 02:58:32 -0800 (PST) Received-SPF: pass (google.com: domain of u-boot-bounces@lists.denx.de designates 85.214.62.61 as permitted sender) client-ip=85.214.62.61; Authentication-Results: mx.google.com; spf=pass (google.com: domain of u-boot-bounces@lists.denx.de designates 85.214.62.61 as permitted sender) smtp.mailfrom=u-boot-bounces@lists.denx.de; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 8B94981420; Tue, 4 Mar 2025 11:58:28 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=fail (p=none dis=none) header.from=linaro.org Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de Received: by phobos.denx.de (Postfix, from userid 109) id 4D46E81436; Tue, 4 Mar 2025 11:58:27 +0100 (CET) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on phobos.denx.de X-Spam-Level: X-Spam-Status: No, score=-1.2 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_BLOCKED,RCVD_IN_VALIDITY_RPBL_BLOCKED, RCVD_IN_VALIDITY_SAFE_BLOCKED,SPF_HELO_NONE,SPF_SOFTFAIL autolearn=no autolearn_force=no version=3.4.2 Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by phobos.denx.de (Postfix) with ESMTP id 23E0180FB6 for ; Tue, 4 Mar 2025 11:58:25 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=fail (p=none dis=none) header.from=linaro.org Authentication-Results: phobos.denx.de; spf=fail smtp.mailfrom=sughosh.ganu@linaro.org Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 352F1FEC; Tue, 4 Mar 2025 02:58:38 -0800 (PST) Received: from a079122.blr.arm.com (a079122.arm.com [10.162.17.48]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 279663F5A1; Tue, 4 Mar 2025 02:58:21 -0800 (PST) From: Sughosh Ganu To: u-boot@lists.denx.de Cc: Ilias Apalodimas , Simon Glass , Tom Rini , Heinrich Schuchardt , Ramon Fried , Sughosh Ganu Subject: [PATCH] wget: check return value of store_block() Date: Tue, 4 Mar 2025 16:27:41 +0530 Message-Id: <20250304105741.489938-1-sughosh.ganu@linaro.org> X-Mailer: git-send-email 2.34.1 MIME-Version: 1.0 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 The tcp_stream_rx() function calls store_block() to check if the destination memory region is available for the chunk of data to be copied to it. The store_block() function returns a negative value in case the destination memory region is already in use. However this return value is not checked in tcp_stream_rx(). Take the return value of store_block() into consideration. Signed-off-by: Sughosh Ganu --- net/wget.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/net/wget.c b/net/wget.c index 0b082c61947..847097a0e3e 100644 --- a/net/wget.c +++ b/net/wget.c @@ -227,7 +227,8 @@ static int tcp_stream_rx(struct tcp_stream *tcp, u32 rx_offs, void *buf, int len if ((max_rx_pos == (u32)(-1)) || (max_rx_pos < rx_offs + len - 1)) max_rx_pos = rx_offs + len - 1; - store_block(buf, rx_offs - http_hdr_size, len); + if (store_block(buf, rx_offs - http_hdr_size, len) < 0) + return -1; return len; }