Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[linux] storage: check if devnode is valid pointer #20111

Merged
merged 1 commit into from
Apr 27, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
19 changes: 14 additions & 5 deletions xbmc/platform/linux/storage/UDevProvider.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -117,8 +117,16 @@ void CUDevProvider::GetDisks(VECSOURCES& disks, bool removable)
if (!device)
continue;

// filter out devices without devnode
const char* devnode = udev_device_get_devnode(device);
if (!devnode)
{
udev_device_unref(device);
continue;
}

// filter out devices that are not mounted
const char *mountpoint = get_mountpoint(udev_device_get_devnode(device));
const char* mountpoint = get_mountpoint(devnode);
if (!mountpoint)
{
udev_device_unref(device);
Expand Down Expand Up @@ -225,16 +233,17 @@ bool CUDevProvider::PumpDriveChangeEvents(IStorageEventsCallback *callback)

if (FD_ISSET(udev_monitor_get_fd(m_udevMon), &readfds))
{
struct udev_device *dev = udev_monitor_receive_device(m_udevMon);
struct udev_device* dev = udev_monitor_receive_device(m_udevMon);
if (!dev)
return false;

const char *action = udev_device_get_action(dev);
if (action)
const char* action = udev_device_get_action(dev);
const char* devnode = udev_device_get_devnode(dev);
if (action && devnode)
{
std::string label;
const char *udev_label = udev_device_get_property_value(dev, "ID_FS_LABEL");
const char *mountpoint = get_mountpoint(udev_device_get_devnode(dev));
const char* mountpoint = get_mountpoint(devnode);
if (udev_label)
label = udev_label;
else if (mountpoint)
Expand Down