david/ipxe
david
/
ipxe
Archived
1
0
Fork 0

Can't use strncpy() to copy strings that aren't NUL-terminated to

begin with.
This commit is contained in:
Michael Brown 2007-07-01 03:22:28 +01:00
parent 31fe5b9415
commit 3bf5eb49d0
1 changed files with 8 additions and 2 deletions

View File

@ -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 */