From patchwork Tue Oct 19 14:04:54 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: [U-Boot] Fix potential empty DHCP Parameter Request List X-Patchwork-Submitter: Gray Remlin X-Patchwork-Id: 71887 Message-Id: <4CBDA586.6040008@rocketmail.com> To: u-boot@lists.denx.de Cc: biggerbadderben@gmail.com Date: Tue, 19 Oct 2010 15:04:54 +0100 From: Gray Remlin List-Id: U-Boot discussion Signed-off-by: Gray Remlin --- net/bootp.c | 16 +++++++++++++++- 1 files changed, 15 insertions(+), 1 deletions(-) *e++ = 1; /* Subnet Mask */ @@ -456,6 +469,7 @@ static int DhcpExtended (u8 * e, int message_type, IPaddr_t ServerID, IPaddr_t R *e++ = 42; *cnt += 1; #endif +#endif *e++ = 255; /* End of the list */ /* Pad to minimal length */ -- diff --git a/net/bootp.c b/net/bootp.c index e679f8b..1289e3b 100644 --- a/net/bootp.c +++ b/net/bootp.c @@ -417,8 +417,21 @@ static int DhcpExtended (u8 * e, int message_type, IPaddr_t ServerID, IPaddr_t R return x - start; #endif +/* + * RFC2132: An empty Parameter Request List is not legitimate, + * it must have at minimum one request. + */ +#if defined(CONFIG_BOOTP_SUBNETMASK) || \ + defined(CONFIG_BOOTP_TIMEOFFSET) || \ + defined(CONFIG_BOOTP_GATEWAY) || \ + defined(CONFIG_BOOTP_DNS) || \ + defined(CONFIG_BOOTP_HOSTNAME) || \ + defined(CONFIG_BOOTP_BOOTFILESIZE) || \ + defined(CONFIG_BOOTP_BOOTPATH) || \ + defined(CONFIG_BOOTP_NISDOMAIN) || \ + defined(CONFIG_BOOTP_NTPSERVER) *e++ = 55; /* Parameter Request List */ - cnt = e++; /* Pointer to count of requested items */ + cnt = e++; /* Pointer to count of requested items */ *cnt = 0; #if defined(CONFIG_BOOTP_SUBNETMASK)