From patchwork Tue Oct 8 09:46:46 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jerome Forissier X-Patchwork-Id: 833567 Delivered-To: patch@linaro.org Received: by 2002:adf:a1d9:0:b0:367:895a:4699 with SMTP id v25csp200788wrv; Tue, 8 Oct 2024 02:47:14 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCXSEmLTClSCWSJaGy3Mv+RV/nFO2r5XFlXYZnyerhNKyr5sXo8PCfS0CIKW0D9QHm7fF7FSIg==@linaro.org X-Google-Smtp-Source: AGHT+IEIY7cx+DdI8CvO7dWJG36fvri6bcU2IcziRvVpBGfAVlc9mdFDH+pKgxJ0/57361OIPxpg X-Received: by 2002:a05:6602:4810:b0:82a:a998:ebab with SMTP id ca18e2360f4ac-834f7d6353bmr1215987539f.11.1728380834033; Tue, 08 Oct 2024 02:47:14 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1728380834; cv=none; d=google.com; s=arc-20240605; b=Gs/UkxkuZADF6HN+adkhSXIBv8UajMRMEApB38G0L0ahEVjTckD7gxFq5sYjHM5Cct TpiQS8RQD/8SqBtwQlkvpdiZQ3a91Z6MqePHqbw5S79heVZUKfc0gBpQmeZs079yfi96 bci7Hoj7tdcISwTRr7KMjFq1UyPgShYBGxhym38e71L5pKqagrHWdif2/GX0SzbBlLgZ 9O0Cz2nr9/l0/IwyYvu0UR8/nUGINMAod7nhgwMLQqzIdH287JPQekuMWXQM3kKShDn+ EivY4Nvq4Ije54YCOZ99IzlRmbm7xs1dwW+uHyD7VmQYCJ15I01hWr6yhcEzfDn5vMCV gLnw== 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:dkim-signature; bh=NxtKwgin+dTec8jNMnqOB2+d2mCQlec9BZDvKDdZslU=; fh=TtDCFUCj0P5l78+B/3gxFOQeh4pIj7AYz5dFwoWkUz0=; b=D2YEnJAxwvHuKLQkrUgsBpC6w8Q3K4+zY6dE/cmcqqUXyVgPL4lvDGMjwK75SiPzPb QFOr3APDRGB514rZBUk6aLjNaBq43yymTQqiLcwrOS+VGNQDhb3y1TV7B1oSJGuzVtOZ 2jpSOGb3paIkMQWPMhevBU/hMMsp/zSA6BcPPPT6jgNOjqzilM4dLLND6po80jg15ByH CYcr0YI1DzPEn4jMYfZT2vwe9YczCeUCFluzfS72az2hRfcBH224+5TFJ4u3hJnAGfL1 NeScyOet2UEfhk75ohFN4yENmCWSwJ1RAH86tV+riBo3so46yhZviaZJTH2YVC4OCvlI H/Eg==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b="huh3X29/"; 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=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org; dara=neutral header.i=@linaro.org Return-Path: Received: from phobos.denx.de (phobos.denx.de. [85.214.62.61]) by mx.google.com with ESMTPS id 8926c6da1cb9f-4db96f4d6cbsi427807173.38.2024.10.08.02.47.13 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 08 Oct 2024 02:47:14 -0700 (PDT) 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; dkim=pass header.i=@linaro.org header.s=google header.b="huh3X29/"; 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=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org; dara=neutral header.i=@linaro.org Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id DE2A6881C1; Tue, 8 Oct 2024 11:47:11 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=linaro.org Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de Authentication-Results: phobos.denx.de; dkim=pass (2048-bit key; unprotected) header.d=linaro.org header.i=@linaro.org header.b="huh3X29/"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id BF3A287042; Tue, 8 Oct 2024 11:47:10 +0200 (CEST) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on phobos.denx.de X-Spam-Level: X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_BLOCKED, SPF_HELO_NONE,SPF_PASS autolearn=unavailable autolearn_force=no version=3.4.2 Received: from mail-wm1-x332.google.com (mail-wm1-x332.google.com [IPv6:2a00:1450:4864:20::332]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits)) (No client certificate requested) by phobos.denx.de (Postfix) with ESMTPS id 94E2E881E7 for ; Tue, 8 Oct 2024 11:47:08 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=linaro.org Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=jerome.forissier@linaro.org Received: by mail-wm1-x332.google.com with SMTP id 5b1f17b1804b1-42cc8782869so55566995e9.2 for ; Tue, 08 Oct 2024 02:47:08 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1728380828; x=1728985628; darn=lists.denx.de; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc:subject:date:message-id:reply-to; bh=NxtKwgin+dTec8jNMnqOB2+d2mCQlec9BZDvKDdZslU=; b=huh3X29/lek7kQkyNeqyDhWt1fWMRYBF3I48D+HIwFP43PVifXNd1UZpSuSjXS0ypc u6GgV2PDZoUitz3TWvEX4K9Acb16+hPUhXiXheLsYcZDjCDEyXk/jgYTmAh69Eesfq1O PWQ7hSCO4dYUfYQdJL6cyry0x0JLY6tADngZ2wLeSxprrIn0RRMZ5JqAKbDOX0gDVy/q Qdl/bQTooYfTopQ5FG0NdcxuYjP9lMQrpEdirqTth1ZD/DBLSdruz+EjW3C5QfG3QsWp tkBzyzqoDiRNnVE2P+0BISv4keN61oC923BuvD+W6up7P5vmzBap6D0XMHO0RzU54vfS PQeA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1728380828; x=1728985628; 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=NxtKwgin+dTec8jNMnqOB2+d2mCQlec9BZDvKDdZslU=; b=HTsxj3hkn0axmpkjLXvpo2KS8/d4wIrw9L3RLYdRAbYVjtXrtjfqHkRv50V6cg+fjC TPhMVXaRzP9GztlEDP+8uctd88VX3AmnMB6lCVFG9OHLpvlFn8sEu0iCvYdir+dMavhg R9jy5jHEQvFf5b78TjX88H++KOTnL2rc+Ekc3z0DJzLgYLNveJNmwFmUX5HGNEWeOo9C LfWXR1uUxzY1I0ig7NdF4dSQtuxVRibbd3GspMHVrd3yvzMGcxZNk1IkpF6qYh3oFWPh OX4DsuSvvYUC0X2OoTJifC99wmSdtWS2DHHLWHDBjIXYoIIqer8qEKjQrJjOWbCWVZyC gykg== X-Gm-Message-State: AOJu0Yxi2wMx/4CTPDdr2apKzA/im/4yQbHJN7zNOwg0qQC/YOV7hPo6 22pUCs6MrY0pc7IogzN3/Tm5/OMdVjLGoGuzdnUYNvKHsTR+OdEbglGCvOaV4KKMD/ADnJcaFkn PcMSolw== X-Received: by 2002:a05:600c:3b08:b0:42c:b63e:fea6 with SMTP id 5b1f17b1804b1-42f85ae927fmr122652725e9.22.1728380827741; Tue, 08 Oct 2024 02:47:07 -0700 (PDT) Received: from builder.. ([2a01:e0a:3cb:7bb0:d1c8:3266:1994:6cca]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-42f86b44374sm120927805e9.30.2024.10.08.02.47.07 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 08 Oct 2024 02:47:07 -0700 (PDT) From: Jerome Forissier To: u-boot@lists.denx.de Cc: Jerome Forissier , Joe Hershberger , Ramon Fried , Tom Rini , Ilias Apalodimas , Simon Glass , Sughosh Ganu , Masahisa Kojima , Yasuharu Shibata , Marek Vasut Subject: [PATCH] net: wget: check strict_strtoul() return value Date: Tue, 8 Oct 2024 11:46:46 +0200 Message-Id: <20241008094646.4052174-1-jerome.forissier@linaro.org> X-Mailer: git-send-email 2.40.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 Check the return value of strict_strtoul() when processing the Content-Length header as recommended by Coverity [1]. [1] https://lists.denx.de/pipermail/u-boot/2024-October/567050.html Reported-by: Coverity (CID 510464) Signed-off-by: Jerome Forissier Reviewed-by: Simon Glass --- net/wget.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/net/wget.c b/net/wget.c index b4251e0f293..a3821495e03 100644 --- a/net/wget.c +++ b/net/wget.c @@ -256,7 +256,12 @@ static void wget_connected(uchar *pkt, unsigned int tcp_seq_num, content_length = -1; } else { pos += sizeof(content_len) + 2; - strict_strtoul(pos, 10, &content_length); + if (strict_strtoul(pos, 10, &content_length) < 0) { + wget_loop_state = NETLOOP_FAIL; + wget_fail("wget: bad Content-Length\n", tcp_seq_num, tcp_ack_num, action); + net_set_state(NETLOOP_FAIL); + return; + } debug_cond(DEBUG_WGET, "wget: Connected Len %lu\n", content_length);