public inbox for passt-dev@passt.top
 help / color / mirror / code / Atom feed
From: David Gibson <david@gibson.dropbear.id.au>
To: Stefano Brivio <sbrivio@redhat.com>
Cc: passt-dev@passt.top, Enrique Llorente <ellorent@redhat.com>
Subject: Re: [PATCH] dhcp: Add option code byte in calculation for OPT_MAX boundary check
Date: Wed, 19 Feb 2025 10:20:07 +1100	[thread overview]
Message-ID: <Z7UVp0Bl3mwmT_ZR@zatzit> (raw)
In-Reply-To: <20250218085231.407699-1-sbrivio@redhat.com>

[-- Attachment #1: Type: text/plain, Size: 1735 bytes --]

On Tue, Feb 18, 2025 at 09:52:31AM +0100, Stefano Brivio wrote:
> Otherwise we'll limit messages to 577 bytes, instead of 576 bytes as
> intended:
> 
>   $ fqdn="thirtytwocharactersforeachlabel.thirtytwocharactersforeachlabel.thirtytwocharactersforeachlabel.thirtytwocharactersforeachlabel.thirtytwocharactersforeachlabel.thirtytwocharactersforeachlabel.thirtytwocharactersforeachlabel.then_make_it_251_with_this"
>   $ hostname="__eighteen_bytes__"
>   $ ./pasta --fqdn ${fqdn} -H ${hostname} -p dhcp.pcap -- /sbin/dhclient -4
>   Saving packet capture to dhcp.pcap
>   $ tshark -r dhcp.pcap -V -Y 'dhcp.option.value == 5' | grep "Total Length"
>       Total Length: 577
> 
> This was hidden by the issue fixed by commit bcc4908c2b4a ("dhcp
> Remove option 255 length byte") until now.
> 
> Fixes: 31e8109a86ee ("dhcp, dhcpv6: Add hostname and client fqdn ops")
> Signed-off-by: Stefano Brivio <sbrivio@redhat.com>

Reviewed-by: David Gibson <david@gibson.dropbear.id.au>

> ---
>  dhcp.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/dhcp.c b/dhcp.c
> index 4a209f1..b7d5ea3 100644
> --- a/dhcp.c
> +++ b/dhcp.c
> @@ -143,7 +143,7 @@ static bool fill_one(struct msg *m, int o, int *offset)
>  	size_t slen = opts[o].slen;
>  
>  	/* If we don't have space to write the option, then just skip */
> -	if (*offset + 1 /* length of option */ + slen > OPT_MAX)
> +	if (*offset + 2 /* code and length of option */ + slen > OPT_MAX)
>  		return true;
>  
>  	m->o[*offset] = o;

-- 
David Gibson (he or they)	| I'll have my music baroque, and my code
david AT gibson.dropbear.id.au	| minimalist, thank you, not the other way
				| around.
http://www.ozlabs.org/~dgibson

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 833 bytes --]

  reply	other threads:[~2025-02-18 23:21 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-02-18  8:52 [PATCH] dhcp: Add option code byte in calculation for OPT_MAX boundary check Stefano Brivio
2025-02-18 23:20 ` David Gibson [this message]
2025-02-19  7:37   ` Enrique Llorente Pastora

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=Z7UVp0Bl3mwmT_ZR@zatzit \
    --to=david@gibson.dropbear.id.au \
    --cc=ellorent@redhat.com \
    --cc=passt-dev@passt.top \
    --cc=sbrivio@redhat.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://passt.top/passt

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for IMAP folder(s).