mirror of
https://gitlab.freedesktop.org/mesa/drm.git
synced 2025-12-25 04:50:11 +01:00
xf86drm: cap number of reported devices by drmGetDevice(2)
Do as the documentation says - when devices non NULL, cap the reported devices to max_devices. Otherwise we risk out-of-bound access for users of the API. v2: - Fix this w/o breaking the API v3: - Drop local variables, flip inverted conditional (Simon) Issue: https://gitlab.freedesktop.org/mesa/drm/-/issues/56 Signed-off-by: Emil Velikov <emil.l.velikov@gmail.com> Reviewed-by: Simon Ser <contact@emersion.fr>
This commit is contained in:
parent
06844b6eae
commit
a9bb32cfe1
1 changed files with 4 additions and 0 deletions
|
|
@ -4272,6 +4272,10 @@ drm_public int drmGetDevices2(uint32_t flags, drmDevicePtr devices[],
|
|||
}
|
||||
|
||||
closedir(sysdir);
|
||||
|
||||
if (devices != NULL)
|
||||
return MIN2(device_count, max_devices);
|
||||
|
||||
return device_count;
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue