cnList double-closes file handle, masking close errors #32

Open
opened 2026-05-17 23:13:51 +02:00 by heiko · 1 comment
Owner

Summary

cmd/cert-proxy-server/cnlist.go closes the file twice:

defer cc.Close()  //nolint:errcheck   ← deferred close, error suppressed

cns := list.UniqStrings{}
if err = list.AddItemsFromReader(&cns, cc); err != nil {
    return nil, err
}

return cns, cc.Close()   // explicit close, error propagated

The explicit cc.Close() at the return propagates errors correctly, but the defer then closes the already-closed handle a second time. The deferred close's error is suppressed by //nolint:errcheck, hiding any issue.

Fix

Remove the defer and keep only the explicit cc.Close() in the return, or vice versa.

## Summary `cmd/cert-proxy-server/cnlist.go` closes the file twice: ```go defer cc.Close() //nolint:errcheck ← deferred close, error suppressed cns := list.UniqStrings{} if err = list.AddItemsFromReader(&cns, cc); err != nil { return nil, err } return cns, cc.Close() // explicit close, error propagated ``` The explicit `cc.Close()` at the return propagates errors correctly, but the `defer` then closes the already-closed handle a second time. The deferred close's error is suppressed by `//nolint:errcheck`, hiding any issue. ## Fix Remove the `defer` and keep only the explicit `cc.Close()` in the return, or vice versa.
Author
Owner

AI attribution comment added per repository instruction for this open issue.\n\n(co)authored by ai:gpt-5-codex

AI attribution comment added per repository instruction for this open issue.\n\n(co)authored by ai:gpt-5-codex
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
heiko/cert-proxy#32
No description provided.