Skip to content

Commit 2d57fa0

Browse files
committed
fix: trim zero bytes in the DHCP host & domain response
Fixes #11826 Signed-off-by: Andrey Smirnov <andrey.smirnov@siderolabs.com>
1 parent 451cb5f commit 2d57fa0

File tree

1 file changed

+8
-4
lines changed
  • internal/app/machined/pkg/controllers/network/operator

1 file changed

+8
-4
lines changed

internal/app/machined/pkg/controllers/network/operator/dhcp4.go

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -402,14 +402,18 @@ func (d *DHCP4) parseNetworkConfigFromAck(ack *dhcpv4.DHCPv4, useHostname bool)
402402
if useHostname {
403403
d.hostname = nil
404404

405-
if ack.HostName() != "" {
405+
hostname := strings.TrimRight(ack.HostName(), "\x00")
406+
407+
if hostname != "" {
406408
spec := network.HostnameSpecSpec{
407409
ConfigLayer: network.ConfigOperator,
408410
}
409411

410-
if err := spec.ParseFQDN(ack.HostName()); err == nil {
411-
if ack.DomainName() != "" {
412-
spec.Domainname = ack.DomainName()
412+
if err := spec.ParseFQDN(hostname); err == nil {
413+
domainName := strings.TrimRight(ack.DomainName(), "\x00")
414+
415+
if domainName != "" {
416+
spec.Domainname = domainName
413417
}
414418

415419
d.hostname = []network.HostnameSpecSpec{

0 commit comments

Comments
 (0)