Skip to content

fix: reject non-directory mkdirat conflicts#5305

Open
immanuwell wants to merge 1 commit into
aquasecurity:mainfrom
immanuwell:fix-mkdirat-existing-file
Open

fix: reject non-directory mkdirat conflicts#5305
immanuwell wants to merge 1 commit into
aquasecurity:mainfrom
immanuwell:fix-mkdirat-existing-file

Conversation

@immanuwell
Copy link
Copy Markdown

Small fix for fileutil, no drama. MkdirAtExist used to swallow EEXIST even when the existing path was a regular file. That is a bit sus because callers can keep going as if a dir exists.

Repro:

  1. create a regular file at the path MkdirAllAtExist is about to create
  2. run cd common && go test ./fileutil -run TestMkdirAllAtExist/'existing_file_path_-_should_error' -v
  3. before this patch it fails with Expected error when path exists as a regular file

Now EEXIST is ignored only when fstatat says the existing path is a directory. Existing dirs still work as before.

Checked:

  • cd common && go test ./fileutil
  • cd common && go vet ./fileutil
  • make test-common

@immanuwell immanuwell requested review from a team and rscampos May 15, 2026 14:31
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant