command/storage: check if mount point is busy
When mounting something over a directory that is already a mount point, CompositeStorage::Mount() silently overwrites the previously mounted storage, disposing it. After that, SimpleDatabase::Mount() will fail and handle_mount() will roll back the CompositeStorage::Mount() command, effectively unmounting what was there before (and also leaking memory). Closes https://github.com/MusicPlayerDaemon/MPD/issues/918
This commit is contained in:
@@ -198,6 +198,11 @@ handle_mount(Client &client, Request args, Response &r)
|
||||
return CommandResult::ERROR;
|
||||
}
|
||||
|
||||
if (composite.IsMountPoint(local_uri)) {
|
||||
r.Error(ACK_ERROR_ARG, "Mount point busy");
|
||||
return CommandResult::ERROR;
|
||||
}
|
||||
|
||||
auto &event_loop = instance.io_thread.GetEventLoop();
|
||||
auto storage = CreateStorageURI(event_loop, remote_uri);
|
||||
if (storage == nullptr) {
|
||||
|
Reference in New Issue
Block a user