os.UserHomeDir() error silently ignored - config files written to / #7

Open
opened 2026-05-18 02:18:48 +00:00 by renekv · 0 comments
Contributor

Severity: Medium

cmd/ocgo/main.go:1459:

func configDir() string { home, _ := os.UserHomeDir(); return filepath.Join(home, ".config", "ocgo") }

If os.UserHomeDir() fails (e.g. user not in /etc/passwd), home is "", and files are written to /.config/ocgo/. Same issue in codexConfigFile() and codexModelCatalogFile().

Fix: Return an error on failure instead of ignoring it.

**Severity: Medium** `cmd/ocgo/main.go:1459`: ```go func configDir() string { home, _ := os.UserHomeDir(); return filepath.Join(home, ".config", "ocgo") } ``` If `os.UserHomeDir()` fails (e.g. user not in `/etc/passwd`), `home` is `""`, and files are written to `/.config/ocgo/`. Same issue in `codexConfigFile()` and `codexModelCatalogFile()`. **Fix:** Return an error on failure instead of ignoring it.
Sign in to join this conversation.
No labels
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: opencode/ocgo#7
No description provided.