v4.0.x - DHCP - incomplete decoding of IPv4 attribute

Chaigneau, Nicolas nicolas.chaigneau at capgemini.com
Wed Feb 21 19:01:05 CET 2018

> > In function fr_dhcpv4_packet_decode:
> > 
> > https://github.com/FreeRADIUS/freeradius-server/blob/ce6c2c641194a49b70d6c6e9335f900d5f0a699c/src/protocols/dhcpv4/packet.c#L162
> > 
> >                               case FR_TYPE_IPV4_ADDR:
> >                                               memcpy(&vp->vp_ipv4addr, p, 4);
> >                                               break;
> > 
> > 
> > I had to add the following two lines after the memcpy:
> > 
> >                                               vp->data.vb_ip.af = AF_INET;
> >                                               vp->data.vb_ip.prefix = 32;
> Nah that's the DHCPv4 code, haven't touched that.  I'm working on v6.  Just swapped out most of that switch statement for a call to fr_value_box_from_network... woo code reuse.

Ooh new shiny code. :)
You've broken something though, now decoding the response fails:

dhcpclient: Failed decoding packet: Found trailing garbage parsing type "ether". Expected length <= 6 bytes, got 16 bytes

Although an ethernet address is indeed on 6 bytes, the DHCP field "chaddr" is padded to 16 characters with zeroes.
I've fixed this by restoring these lines here:


                case FR_TYPE_ETHERNET:
                        memcpy(vp->vp_ether, p, sizeof(vp->vp_ether));


This message contains information that may be privileged or confidential and is the property of the Capgemini Group. It is intended only for the person to whom it is addressed. If you are not the intended recipient, you are not authorized to read, print, retain, copy, disseminate, distribute, or use this message or any part thereof. If you receive this message in error, please notify the sender immediately and delete all copies of this message.

More information about the Freeradius-Devel mailing list