From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from smtp1.osuosl.org (smtp1.osuosl.org [140.211.166.138]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (prime256v1) server-digest SHA256) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 84F40606A31A for ; Wed, 2 Dec 2026 13:30:53 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=lists.u-boot-project.org header.i=@lists.u-boot-project.org header.a=rsa-sha256 header.s=default header.b=XF6PVooS; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20260707 header.b=DfXu6Kmc Received: from localhost (localhost [127.0.0.1]) by smtp1.osuosl.org (Postfix) with ESMTP id 5D06581011; Wed, 2 Dec 2026 13:30:53 +0000 (UTC) X-Virus-Scanned: amavis at osuosl.org Received: from smtp1.osuosl.org ([127.0.0.1]) by localhost (smtp1.osuosl.org [127.0.0.1]) (amavis, port 10024) with ESMTP id cY8wdBaxiBGU; Wed, 2 Dec 2026 13:30:52 +0000 (UTC) ARC-Filter: OpenARC Filter v1.3.2 smtp1.osuosl.org A3BAC80F34 Authentication-Results: smtp1.osuosl.org; arc=none smtp.remote-ip=140.211.166.142 ARC-Seal: i=1; d=osuosl.org; s=arc; a=rsa-sha256; cv=none; t=1796218252; b=Xa7USyjOUXGF84OpZpAKWSJTZdd2OG/zNj7dE11hwsbgXenx8fIHyaAKchRuQ8TffR4r 6vgLaSInxPxHUd5DITzd0OaOjA0hVdXi+vFViJF5ii6UofEYJzFaVSioYLM0sY5xfwbOt W7aXu5jiUss2vvwM1w0GdKmKaJhbUsSy1wIMCtyKYBnJIMASuaVk7uSy6blS+S/HvbOUx n3q5Uf5YcCnw2vKj9MLlcSdsC5fWfDsnQa/3AMC++7Op11pRMd68BWAKn6IebkY6SA41o EwSbfBkWcUDpPsRaMWJu86MAIXPvz69kGuIoWMdO2vL/p+fnfEzxL2HC2vV2ePHrsSA== ARC-Message-Signature: i=1; d=osuosl.org; s=arc; a=rsa-sha256; c=relaxed/relaxed; t=1796218252; h=X-Comment:DKIM-Signature:X-Original-To:Delivered-To:Received: Received:X-Virus-Scanned:X-Spam-Flag:X-Spam-Score:X-Spam-Level: X-Spam-Status:Received:ARC-Filter:Received-SPF:Received:Received: DKIM-Signature:X-Google-DKIM-Signature:X-Gm-Message-State:X-Gm-Gg: X-Received:Received:From:To:Cc:Subject:Date:Message-Id:X-Mailer: MIME-Version:Content-Transfer-Encoding:X-Mailman-Approved-At: X-BeenThere:X-Mailman-Version:Precedence:List-Id:List-Unsubscribe: List-Archive:List-Post:List-Help:List-Subscribe:Errors-To; bh=uKbCZmHlmHrpbY47PZVh8I0JquUpQpwbCGDgzCft+jY=; b=Sgtd/1t8jz8q9WNBERhS0frOgFhNPZwL9Kk7VWhIYgibdHQ7VOOsU4rCRADTEr+hKPKZ 2SFPtmqXIgZAeHZVfTibj5Hq8qk5Gp+xZQYR4jBGSnSNi8Vdqqy3sRY1nUPczvDn71qA4 5ho6NQaFhp/9tRb/DAFboRcnTc4dV9pCIOy/KT0lnCKDxMiTCAK/z2VWKpNQhV4DBfJMP csuHUh8Nae7bwP8a7t2VTaEZgvbEPa1tiYP1xkm1uBMjwWEtMMg2mk6i7UtJ5xa67muQX 6qycA+/qjCWqIACoOVACl6thCNOEcHMVKL0GUX34ZqafM3colu6x4YCPGU635E7PIKw== ARC-Authentication-Results: i=1; smtp1.osuosl.org; arc=none smtp.remote-ip=140.211.166.142 X-Comment: SPF check N/A for local connections - client-ip=140.211.166.142; helo=lists1.osuosl.org; envelope-from=u-boot-bounces@lists.u-boot-project.org; receiver= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=lists.u-boot-project.org; s=default; t=1796218252; bh=uKbCZmHlmHrpbY47PZVh8I0JquUpQpwbCGDgzCft+jY=; h=From:To:Cc:Subject:Date:List-Id:List-Unsubscribe:List-Archive: List-Post:List-Help:List-Subscribe:From; b=XF6PVooSqhNvjaxOmg2If5fC7sMScj8i7vR7aCC4cCYKorAh1q4J/8btKsLQWdH5z T691sNHyu5hZOSw3B+1wJS2Bo1ZuN+FGDoD9xBRzYlXV9bk1hwpLvoT7gSKcBk7Cwn /gDRe7FwPsYH6zpJB8EbNZfW4iyOHxXcWRpy9tLt8V0vuqbSYVxnEMpHpMMVRlVveb vmuUbKrLSFdkle2yenyxTbjJZq5mR1vgZyScq7sfn+4dETJHdhhkcep0icO4QJkrkK bo3GaueS+vv1FdvWMv/zpO5J2YtxaVecrReEoTUqmydQ1VDHFOXnm1mfSTmLGb5bv9 hNOREegz0yrMA== Received: from lists1.osuosl.org (lists1.osuosl.org [140.211.166.142]) by smtp1.osuosl.org (Postfix) with ESMTP id A3BAC80F34; Wed, 2 Dec 2026 13:30:52 +0000 (UTC) Received: from smtp3.osuosl.org (smtp3.osuosl.org [140.211.166.136]) by lists1.osuosl.org (Postfix) with ESMTP id 4CFA32FF for ; Wed, 2 Dec 2026 07:00:57 +0000 (UTC) Received: from localhost (localhost [127.0.0.1]) by smtp3.osuosl.org (Postfix) with ESMTP id 33BF860781 for ; Wed, 2 Dec 2026 07:00:57 +0000 (UTC) X-Virus-Scanned: amavis at osuosl.org Received: from smtp3.osuosl.org ([127.0.0.1]) by localhost (smtp3.osuosl.org [127.0.0.1]) (amavis, port 10024) with ESMTP id Jktg32L5BuQA for ; Wed, 2 Dec 2026 07:00:56 +0000 (UTC) ARC-Filter: OpenARC Filter v1.3.2 smtp3.osuosl.org 8DB646077F Authentication-Results: smtp3.osuosl.org; arc=none smtp.remote-ip="2607:f8b0:4864:20::122d" Received-SPF: Pass (mailfrom) identity=mailfrom; client-ip=2607:f8b0:4864:20::122d; helo=mail-dl1-x122d.google.com; envelope-from=ragaprasanth@gmail.com; receiver= Authentication-Results: smtp3.osuosl.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp3.osuosl.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20260707 header.b=DfXu6Kmc Received: from mail-dl1-x122d.google.com (mail-dl1-x122d.google.com [IPv6:2607:f8b0:4864:20::122d]) by smtp3.osuosl.org (Postfix) with ESMTPS id 8DB646077F for ; Wed, 2 Dec 2026 07:00:56 +0000 (UTC) Received: by mail-dl1-x122d.google.com with SMTP id a92af1059eb24-1b5b910c838so3069181c88.1 for ; Tue, 01 Dec 2026 23:00:56 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20260707; t=1796194855; x=1796799655; darn=lists.u-boot-project.org; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc:subject:date:message-id:reply-to:content-type; bh=uKbCZmHlmHrpbY47PZVh8I0JquUpQpwbCGDgzCft+jY=; b=DfXu6KmcIyZU9sGhr2IJelAZsN/GwhVSLdvR86ns5JKpVvMyvpDiafr6KQrUeNynlG rawj2WgJakRDItN+Ktj4QbbUa/92IIvsVth4e8WNPn+OowxSfAeZOnF/zaYTst7X9/df 0Fc4doXCSuBi2Qfx30xE8frpLcnBbIxLf5dzAImnZFLEuwSD8gKXveYqFruLzjd4XOrk NLya3+GihsGmdY1GXTrp54uIPp5hh5bFQUBuKP7S7cYM4v2d5qVBP3cspMZ4C7EwuS9N SWoD365+l3zDC8Yof31m2bdDEK2ecnwTe4k+5ZT3MZyD9TJnk7p3mL4r7frsdcX063J2 vvNQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20260707; t=1796194855; x=1796799655; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-gg:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to:content-type; bh=uKbCZmHlmHrpbY47PZVh8I0JquUpQpwbCGDgzCft+jY=; b=RfvNd1pVont9V8gxpFiOEfH6g1j/+f91lzomLuocppZquddCUdf+0Sa8UVMlAojSch RxGIcPJSAFiQmszv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05:7301:240a:b0:386:de41:be4e with SMTP id 5a478bee46e88-386de41bf8fmr19338990eec.27.1796194854749; Tue, 01 Dec 2026 23:00:54 -0800 (PST) Received: from prasanth.alps.lineo.co.jp (vpn1.lineo.co.jp. [203.141.200.204]) by smtp.gmail.com with ESMTPSA id 5a478bee46e88-385677c371esm115074598eec.23.2026.12.01.23.00.53 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 01 Dec 2026 23:00:54 -0800 (PST) From: Prasanth R To: u-boot@lists.u-boot-project.org Cc: Jerome Forissier , Tom Rini , Prasanth R Subject: [PATCH] net: dns: check the A record length before copying the address Date: Wed, 2 Dec 2026 16:00:46 +0900 Message-Id: <20261202070046.3548590-1-ragaprasanth@gmail.com> X-Mailer: git-send-email 2.34.1 X-Archived-By: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Mailman-Approved-At: Wed, 02 Dec 2026 13:30:51 +0000 X-BeenThere: u-boot@lists.u-boot-project.org X-Mailman-Version: 2.1.30 Precedence: list List-Id: U-Boot discussion List-Archive: List-Post: List-Help: List-Subscribe: , X-Spam-Status: No, score=-15.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_FORGED_FROMDOMAIN, FREEMAIL_FROM,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER, INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS, USER_AGENT_GIT autolearn=ham autolearn_force=no version=4.0.1 X-Spam-Checker-Version: SpamAssassin 4.0.1 (2024-03-26) on aws-us-west-2-korg-listserv-alma10-1 dns_handler() copies 4 bytes of the address before it checks the record length, and the check uses the length from the packet. An A record with length 0 at the end of the reply makes it read 3 bytes past the packet and print, and store in the env, a wrong address. Copy the address only if the record length is 4 and the 4 bytes are in the packet. Fixes: 1a32bf41881b ("Add DNS support") Signed-off-by: Prasanth R --- I used an AI assistant (Claude) to find this and to write the test. net/dns.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/net/dns.c b/net/dns.c index 08ad54a0..088a35c8 100644 --- a/net/dns.c +++ b/net/dns.c @@ -188,9 +188,8 @@ static void dns_handler(uchar *pkt, unsigned dest, struct in_addr sip, if (found && &p[12] < e) { dlen = get_unaligned_be16(p+10); p += 12; - memcpy(&ip_addr, p, 4); - - if (p + dlen <= e) { + if (dlen == 4 && p + 4 <= e) { + memcpy(&ip_addr, p, 4); ip_to_string(ip_addr, ip_str); printf("%s\n", ip_str); if (net_dns_env_var) -- 2.34.1