Skip to content

Commit cf91423

Browse files
smirafrezbo
authored andcommitted
fix: trim zero bytes in the DHCP host & domain response
Fixes #11826 Signed-off-by: Andrey Smirnov <andrey.smirnov@siderolabs.com> (cherry picked from commit 2d57fa0)
1 parent b5424e4 commit cf91423

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
@@ -395,14 +395,18 @@ func (d *DHCP4) parseNetworkConfigFromAck(ack *dhcpv4.DHCPv4, useHostname bool)
395395
if useHostname {
396396
d.hostname = nil
397397

398-
if ack.HostName() != "" {
398+
hostname := strings.TrimRight(ack.HostName(), "\x00")
399+
400+
if hostname != "" {
399401
spec := network.HostnameSpecSpec{
400402
ConfigLayer: network.ConfigOperator,
401403
}
402404

403-
if err := spec.ParseFQDN(ack.HostName()); err == nil {
404-
if ack.DomainName() != "" {
405-
spec.Domainname = ack.DomainName()
405+
if err := spec.ParseFQDN(hostname); err == nil {
406+
domainName := strings.TrimRight(ack.DomainName(), "\x00")
407+
408+
if domainName != "" {
409+
spec.Domainname = domainName
406410
}
407411

408412
d.hostname = []network.HostnameSpecSpec{

0 commit comments

Comments
 (0)