Add some missing error checks (#2420)

I found these with the 'errcheck' tool (via 'golangci-lint').

I aimed to apply reasonable judgement when deciding which errors
actually need handling, and how to handle them.
This commit is contained in:
Carlo Teubner 2023-06-24 21:23:12 +01:00 committed by GitHub
parent cef4b041d7
commit b46775ae0c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 16 additions and 5 deletions

View File

@ -861,7 +861,9 @@ func (config *Config) loadSources(proxy *Proxy) error {
}
proxy.registeredServers = append(proxy.registeredServers, RegisteredServer{name: serverName, stamp: stamp})
}
proxy.updateRegisteredServers()
if err := proxy.updateRegisteredServers(); err != nil {
return err
}
rs1 := proxy.registeredServers
rs2 := proxy.serversInfo.registeredServers
rand.Shuffle(len(rs1), func(i, j int) {

View File

@ -27,8 +27,11 @@ type App struct {
}
func main() {
TimezoneSetup()
tzErr := TimezoneSetup()
dlog.Init("dnscrypt-proxy", dlog.SeverityNotice, "DAEMON")
if tzErr != nil {
dlog.Errorf("Timezone setup failed: %v", tzErr)
}
runtime.MemProfileRate = 0
seed := make([]byte, 8)
@ -141,7 +144,9 @@ func (app *App) AppMain() {
}
func (app *App) Stop(service service.Service) error {
PidFileRemove()
if err := PidFileRemove(); err != nil {
dlog.Warnf("Failed to remove the PID file: %v", err)
}
dlog.Notice("Stopped.")
return nil
}

View File

@ -615,7 +615,9 @@ func dohTestPacket(msgID uint16) []byte {
msg.SetEdns0(uint16(MaxDNSPacketSize), false)
ext := new(dns.EDNS0_PADDING)
ext.Padding = make([]byte, 16)
crypto_rand.Read(ext.Padding)
if _, err := crypto_rand.Read(ext.Padding); err != nil {
dlog.Fatal(err)
}
edns0 := msg.IsEdns0()
edns0.Option = append(edns0.Option, ext)
body, err := msg.Pack()
@ -638,7 +640,9 @@ func dohNXTestPacket(msgID uint16) []byte {
msg.SetEdns0(uint16(MaxDNSPacketSize), false)
ext := new(dns.EDNS0_PADDING)
ext.Padding = make([]byte, 16)
crypto_rand.Read(ext.Padding)
if _, err := crypto_rand.Read(ext.Padding); err != nil {
dlog.Fatal(err)
}
edns0 := msg.IsEdns0()
edns0.Option = append(edns0.Option, ext)
body, err := msg.Pack()