summaryrefslogtreecommitdiffstats
path: root/src/net/udp/dhcp.c
diff options
context:
space:
mode:
authorMichael Brown2007-07-01 04:22:28 +0200
committerMichael Brown2007-07-01 04:22:28 +0200
commit3bf5eb49d0e4bdee557ceb9ffe98153bb6168902 (patch)
treeb8c5bd5deebb8006eb468efc38d86a22dd28dbe2 /src/net/udp/dhcp.c
parentHack together far enough to support ne2k-pci. (diff)
downloadipxe-3bf5eb49d0e4bdee557ceb9ffe98153bb6168902.tar.gz
ipxe-3bf5eb49d0e4bdee557ceb9ffe98153bb6168902.tar.xz
ipxe-3bf5eb49d0e4bdee557ceb9ffe98153bb6168902.zip
Can't use strncpy() to copy strings that aren't NUL-terminated to
begin with.
Diffstat (limited to 'src/net/udp/dhcp.c')
-rw-r--r--src/net/udp/dhcp.c10
1 files changed, 8 insertions, 2 deletions
diff --git a/src/net/udp/dhcp.c b/src/net/udp/dhcp.c
index 961f66a5..03e6c9d9 100644
--- a/src/net/udp/dhcp.c
+++ b/src/net/udp/dhcp.c
@@ -153,10 +153,16 @@ static int set_dhcp_packet_option ( struct dhcp_packet *dhcppkt,
memcpy ( &dhcphdr->siaddr, data, sizeof ( dhcphdr->siaddr ) );
return 0;
case DHCP_TFTP_SERVER_NAME:
- strncpy ( dhcphdr->sname, data, sizeof ( dhcphdr->sname ) );
+ memset ( dhcphdr->sname, 0, sizeof ( dhcphdr->sname ) );
+ if ( len > sizeof ( dhcphdr->sname ) )
+ len = sizeof ( dhcphdr->sname );
+ memcpy ( dhcphdr->sname, data, len );
return 0;
case DHCP_BOOTFILE_NAME:
- strncpy ( dhcphdr->file, data, sizeof ( dhcphdr->file ) );
+ memset ( dhcphdr->file, 0, sizeof ( dhcphdr->file ) );
+ if ( len > sizeof ( dhcphdr->file ) )
+ len = sizeof ( dhcphdr->file );
+ memcpy ( dhcphdr->file, data, len );
return 0;
default:
/* Continue processing as normal */