mirror of
https://github.com/ipxe/ipxe.git
synced 2026-04-20 21:22:18 +02:00
Can't use strncpy() to copy strings that aren't NUL-terminated to
begin with.
This commit is contained in:
parent
31fe5b9415
commit
3bf5eb49d0
@ -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 */
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user