From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail02.groups.io (mail02.groups.io [66.175.222.108]) by spool.mail.gandi.net (Postfix) with ESMTPS id 72398AC1C12 for ; Thu, 8 Feb 2024 23:45:37 +0000 (UTC) DKIM-Signature: a=rsa-sha256; bh=Ggz6AtQ3HNp3AijVKmQedsJbe1t8VwHunu/SRFA7obs=; c=relaxed/simple; d=groups.io; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References:MIME-Version:Precedence:List-Subscribe:List-Help:Sender:List-Id:Mailing-List:Delivered-To:Reply-To:List-Unsubscribe-Post:List-Unsubscribe:Content-Transfer-Encoding; s=20140610; t=1707435936; v=1; b=YCKBcmW+d9bLDcWtsmmGGuaKMGYGgWH/QpKnSQHFtRkok8F1FRhtpo1xwKCRPT2SML7R1Dfg 4UK2OdfjJjrZPWikNzQBcAuUbB5kGbSqxk6hhfDEKGerfK/NOw3zrBtq8vSUGXbcbTdfLL2jxWW PUZ96zDAFpbNTe+/CUhl1uTE= X-Received: by 127.0.0.2 with SMTP id kHceYY7687511xC1CmjpBIBl; Thu, 08 Feb 2024 15:45:36 -0800 X-Received: from mail-pl1-f176.google.com (mail-pl1-f176.google.com [209.85.214.176]) by mx.groups.io with SMTP id smtpd.web10.4854.1707435935593774318 for ; Thu, 08 Feb 2024 15:45:35 -0800 X-Received: by mail-pl1-f176.google.com with SMTP id d9443c01a7336-1d731314e67so2731675ad.1 for ; Thu, 08 Feb 2024 15:45:35 -0800 (PST) X-Gm-Message-State: a61hYqJ1328wKzgNdQkTveMUx7686176AA= X-Google-Smtp-Source: AGHT+IGq932JkCJ3hVHXUEW7dj/OHRVgdjCNFIlneNB0dmMy/9ap2z22sAahv79oJwQp7zinz8igBw== X-Received: by 2002:a17:903:60b:b0:1d9:83c0:a163 with SMTP id kg11-20020a170903060b00b001d983c0a163mr694508plb.7.1707435934821; Thu, 08 Feb 2024 15:45:34 -0800 (PST) X-Forwarded-Encrypted: i=1; AJvYcCUcnfPNBfEHKoNiLZSlo+oLYy+/UOceHnc2V/LL4+x044m3l2bydpzvz8/VElmTC5eSLuJy9aEj92IYasaurTst79Dn3LKuIA4yMvbq/mlQpvq9SIQ0+x/uN5AhtDoS8zPXwNgcqklxfyzvNTLAdVKNxi55n5GcyrpIqy6MSN4DWQ== X-Received: from localhost.localdomain ([24.17.138.83]) by smtp.gmail.com with ESMTPSA id a12-20020a170902ee8c00b001d7492d9890sm319639pld.146.2024.02.08.15.45.33 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 08 Feb 2024 15:45:34 -0800 (PST) From: "Doug Flick via groups.io" To: devel@edk2.groups.io Cc: Doug Flick , Saloni Kasbekar , Zachary Clark-williams , "Doug Flick [MSFT]" Subject: [edk2-devel] [PATCH v1 2/3] NetworkPkg: Dhcp6Dxe: Additional Code Cleanup Date: Thu, 8 Feb 2024 16:24:01 -0800 Message-ID: <20240209002403.11352-3-doug.edk2@gmail.com> In-Reply-To: <20240209002403.11352-1-doug.edk2@gmail.com> References: <20240209002403.11352-1-doug.edk2@gmail.com> MIME-Version: 1.0 Precedence: Bulk List-Subscribe: List-Help: Sender: devel@edk2.groups.io List-Id: Mailing-List: list devel@edk2.groups.io; contact devel+owner@edk2.groups.io Reply-To: devel@edk2.groups.io,dougflick@microsoft.com List-Unsubscribe-Post: List-Unsubscribe=One-Click List-Unsubscribe: Content-Transfer-Encoding: quoted-printable X-GND-Status: LEGIT Authentication-Results: spool.mail.gandi.net; dkim=pass header.d=groups.io header.s=20140610 header.b=YCKBcmW+; dmarc=pass (policy=none) header.from=groups.io; spf=pass (spool.mail.gandi.net: domain of bounce@groups.io designates 66.175.222.108 as permitted sender) smtp.mailfrom=bounce@groups.io From: Doug Flick Removes duplicate check after merge > > // > // Verify the PacketCursor is within the packet > // > if ( (*PacketCursor < Packet->Dhcp6.Option) > || (*PacketCursor >=3D Packet->Dhcp6.Option + (Packet->Size - sizeof (EFI_DHCP6_HEADER)))) > { > return EFI_INVALID_PARAMETER; > } > Additionally Calculates the Packet->Length before appending Cc: Saloni Kasbekar Cc: Zachary Clark-williams Signed-off-by: Doug Flick [MSFT] --- NetworkPkg/Dhcp6Dxe/Dhcp6Utility.c | 20 ++++++-------------- 1 file changed, 6 insertions(+), 14 deletions(-) diff --git a/NetworkPkg/Dhcp6Dxe/Dhcp6Utility.c b/NetworkPkg/Dhcp6Dxe/Dhcp6= Utility.c index 705c665c519d..348602c4e1a8 100644 --- a/NetworkPkg/Dhcp6Dxe/Dhcp6Utility.c +++ b/NetworkPkg/Dhcp6Dxe/Dhcp6Utility.c @@ -657,15 +657,6 @@ Dhcp6AppendOption ( return EFI_BUFFER_TOO_SMALL;=0D }=0D =0D - //=0D - // Verify the PacketCursor is within the packet=0D - //=0D - if ( (*PacketCursor < Packet->Dhcp6.Option)=0D - || (*PacketCursor >=3D Packet->Dhcp6.Option + (Packet->Size - sizeof = (EFI_DHCP6_HEADER))))=0D - {=0D - return EFI_INVALID_PARAMETER;=0D - }=0D -=0D WriteUnaligned16 ((UINT16 *)*PacketCursor, OptType);=0D *PacketCursor +=3D DHCP6_SIZE_OF_OPT_CODE;=0D WriteUnaligned16 ((UINT16 *)*PacketCursor, OptLen);=0D @@ -929,6 +920,11 @@ Dhcp6AppendIaOption ( *PacketCursor +=3D sizeof (T2);=0D }=0D =0D + //=0D + // Update the packet length=0D + //=0D + Packet->Length +=3D BytesNeeded;=0D +=0D //=0D // Fill all the addresses belong to the Ia=0D //=0D @@ -945,11 +941,6 @@ Dhcp6AppendIaOption ( //=0D *Len =3D HTONS ((UINT16)(*PacketCursor - (UINT8 *)Len - 2));=0D =0D - //=0D - // Update the packet length=0D - //=0D - Packet->Length +=3D BytesNeeded;=0D -=0D return EFI_SUCCESS;=0D }=0D =0D @@ -957,6 +948,7 @@ Dhcp6AppendIaOption ( Append the appointed Elapsed time option to Buf, and move Buf to the end= .=0D =0D @param[in, out] Packet A pointer to the packet, on success Packet= ->Length=0D + will be updated.=0D @param[in, out] PacketCursor The pointer in the packet, on success Pack= etCursor=0D will be moved to the end of the option.=0D @param[in] Instance The pointer to the Dhcp6 instance.=0D --=20 2.43.0 -=-=-=-=-=-=-=-=-=-=-=- Groups.io Links: You receive all messages sent to this group. View/Reply Online (#115282): https://edk2.groups.io/g/devel/message/115282 Mute This Topic: https://groups.io/mt/104250124/7686176 Group Owner: devel+owner@edk2.groups.io Unsubscribe: https://edk2.groups.io/g/devel/unsub [rebecca@openfw.io] -=-=-=-=-=-=-=-=-=-=-=-