mirror of
https://github.com/dani-garcia/vaultwarden.git
synced 2026-08-27 05:35:03 -05:00
[GH-ISSUE #4081] Don't ignore Errors whose ErrorKind is not DirectoryNotEmpty in util::delete_file #10586
Reference in New Issue
Block a user
Originally created by @zacknewman on GitHub (Nov 17, 2023).
Original GitHub issue: https://github.com/dani-garcia/vaultwarden/issues/4081
One could argue this is a bug; but if not, then move to a discussion. Currently
util::delete_fileignores all errors fromstd::fs::remove_dir; however as the comment states, onlyErrors whoseErrorKindisErrorKind::DirectoryNotEmptyshould be ignored.Fixes:
nightlyand enable theio_error_morefeature, then explicitly check the returnedErrorKindand only ignore when it isDirectoryNotEmpty.if fs::read_dir(path)?.next().is_none() { fs::remove_dir(path) } else { Ok(()) }).Obviously only the
nightlystrategy avoids a TOCTOU race condition/attack, but I understand wanting to remain onstable.