AdGuardHome icon indicating copy to clipboard operation
AdGuardHome copied to clipboard

Crashed at internal/dhcpd/v4.go:298

Open TechCiel opened this issue 3 years ago • 2 comments

Issue Details

The goroutine processing requests trying to add a static DHCP lease crashed.

  • Version of AdGuard Home server:
    • v0.107.7
  • How did you install AdGuard Home:
    • curl | sh
  • How did you setup DNS configuration:
    • In a Proxmox VE container
  • If it's a router or IoT, please write device model:
    • NUC8i5BEK
  • CPU architecture:
    • Intel i5-8259U
  • Operating system and version:
    • Debian 11

Expected Behavior

After filling MAC, IP and hostname in the New static lease modal and hit save, the record should be shown in table DHCP static leases.

Actual Behavior

Error: control/dhcp/add_static_lease | Network Error in red at the bottom-right corner. Nothing else happend.

Additional Information

Crashed request in cURL:
curl 'https://example.com/control/dhcp/add_static_lease' \
  -H 'content-type: application/json' \
  -H 'cookie: agh_session=[redacted]' \
  --data-raw '{"mac":"1C:69:00:00:00:00","ip":"172.23.3.2","hostname":"pve"}'
`dhcp` section in config:
dhcp:
  enabled: false
  interface_name: eth0
  local_domain_name: lan
  dhcpv4:
    gateway_ip: 172.23.3.1
    subnet_mask: 255.255.255.192
    range_start: 172.23.3.10
    range_end: 172.23.3.59
    lease_duration: 86400
    icmp_timeout_msec: 1000
    options: []
  dhcpv6:
    range_start: ""
    lease_duration: 86400
    ra_slaac_only: false
    ra_allow_slaac: false
Stack trace:
2022/07/08 17:08:56.601993 8207#310 [debug] POST /control/dhcp/add_static_lease
2022/07/08 17:08:56.602425 8207#310 [debug] web: plain: http: panic serving [redacted]: runtime error: invalid memory address or nil pointer dereference
goroutine 310 [running]:
net/http.(*conn).serve.func1()
        net/http/server.go:1802 +0xb9
panic({0xbe1ea0, 0x2644620})
        runtime/panic.go:1047 +0x266
net.networkNumberAndMask(0xc0011233e0)
        net/ip.go:498
net.(*IPNet).Contains(0xba85e0, {0xc00067ab3c, 0x4, 0x1})
        net/ip.go:522 +0x27
github.com/AdguardTeam/AdGuardHome/internal/dhcpd.(*v4Server).addLease(0xc0003fc500, 0xc00257fce0)
        github.com/AdguardTeam/AdGuardHome/internal/dhcpd/v4.go:298 +0x16c
github.com/AdguardTeam/AdGuardHome/internal/dhcpd.(*v4Server).AddStaticLease.func2(0xc0003fc500, 0xc00257fce0, 0xc0011234e0)
        github.com/AdguardTeam/AdGuardHome/internal/dhcpd/v4.go:388 +0x205
github.com/AdguardTeam/AdGuardHome/internal/dhcpd.(*v4Server).AddStaticLease(0xc0003fc500, 0xc00257fce0)
        github.com/AdguardTeam/AdGuardHome/internal/dhcpd/v4.go:394 +0x1fe
github.com/AdguardTeam/AdGuardHome/internal/dhcpd.(*Server).handleDHCPAddStaticLease(0xc0003c7f00, {0x20ca250, 0xc0040dc4d0}, 0xc0026ae300)
        github.com/AdguardTeam/AdGuardHome/internal/dhcpd/http.go:513 +0x1fc
github.com/AdguardTeam/AdGuardHome/internal/home.ensure.func1({0x20ca250, 0xc0040dc4d0}, 0xc0026ae300)
        github.com/AdguardTeam/AdGuardHome/internal/home/control.go:219 +0x204
github.com/AdguardTeam/AdGuardHome/internal/home.(*httpHandler).ServeHTTP(0xba85e0, {0x20ca250, 0xc0040dc4d0}, 0x4)
        github.com/AdguardTeam/AdGuardHome/internal/home/control.go:237 +0x2f
github.com/NYTimes/gziphandler.GzipHandlerWithOpts.func1.1({0x20ca070, 0xc000164000}, 0xc001109818)
        github.com/NYTimes/[email protected]/gzip.go:336 +0x23c
net/http.HandlerFunc.ServeHTTP(0x40d094, {0x20ca070, 0xc000164000}, 0xc001109830)
        net/http/server.go:2047 +0x2f
github.com/AdguardTeam/AdGuardHome/internal/home.optionalAuth.func1({0x20ca070, 0xc000164000}, 0xc0026ae300)
        github.com/AdguardTeam/AdGuardHome/internal/home/auth.go:598 +0x374
github.com/AdguardTeam/AdGuardHome/internal/home.(*authHandler).ServeHTTP(0x7fc9601d5108, {0x20ca070, 0xc000164000}, 0xc000c79490)
        github.com/AdguardTeam/AdGuardHome/internal/home/auth.go:607 +0x9f
github.com/AdguardTeam/AdGuardHome/internal/home.postInstall.func1({0x20ca070, 0xc000164000}, 0xc0026ae300)
        github.com/AdguardTeam/AdGuardHome/internal/home/control.go:336 +0x115
github.com/AdguardTeam/AdGuardHome/internal/home.(*postInstallHandlerStruct).ServeHTTP(0xc0011099b0, {0x20ca070, 0xc000164000}, 0xc000c79480)
        github.com/AdguardTeam/AdGuardHome/internal/home/control.go:345 +0x9f
net/http.(*ServeMux).ServeHTTP(0x20c83c8, {0x20ca070, 0xc000164000}, 0xc0026ae300)
        net/http/server.go:2425 +0x149
github.com/AdguardTeam/AdGuardHome/internal/home.limitRequestBody.func1({0x20ca070, 0xc000164000}, 0xc0026ae200)
        github.com/AdguardTeam/AdGuardHome/internal/home/middlewares.go:75 +0x352
net/http.HandlerFunc.ServeHTTP(0x0, {0x20ca070, 0xc000164000}, 0x6af720)
        net/http/server.go:2047 +0x2f
net/http.serverHandler.ServeHTTP({0x20c76f8}, {0x20ca070, 0xc000164000}, 0xc0026ae200)
        net/http/server.go:2879 +0x43b
net/http.(*conn).serve(0xc00012f860, {0x20d28b0, 0xc0003106f0})
        net/http/server.go:1930 +0xb08
created by net/http.(*Server).Serve
        net/http/server.go:3034 +0x4e8

TechCiel avatar Jul 08 '22 17:07 TechCiel

Apologies for the long wait and thank you for the thorough bug report. We'll fix that in the next patch release.

ainar-g avatar Jul 22 '22 16:07 ainar-g

@TechCiel, hello. This should be fixed in the latest edge build. AGH should now respond with error on adding a static lease to the unconfigured DHCP server. Could you please check if the problem gone?

EugeneOne1 avatar Sep 14 '22 10:09 EugeneOne1