mirror of
https://gitlab.freedesktop.org/xorg/xserver.git
synced 2026-05-06 17:28:04 +02:00
xfree86: ensure the readlink buffer is null-terminated
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net> Reviewed-by: Dave Airlie <airlied@redhat.com>
This commit is contained in:
parent
ff91c696ff
commit
71703e4e8b
1 changed files with 2 additions and 2 deletions
|
|
@ -331,12 +331,12 @@ fbdev_open(int scrnIndex, const char *dev, char **namep)
|
||||||
|
|
||||||
/* only touch non-PCI devices on this path */
|
/* only touch non-PCI devices on this path */
|
||||||
{
|
{
|
||||||
char buf[PATH_MAX];
|
char buf[PATH_MAX] = {0};
|
||||||
char *sysfs_path = NULL;
|
char *sysfs_path = NULL;
|
||||||
char *node = strrchr(dev, '/') + 1;
|
char *node = strrchr(dev, '/') + 1;
|
||||||
|
|
||||||
if (asprintf(&sysfs_path, "/sys/class/graphics/%s", node) < 0 ||
|
if (asprintf(&sysfs_path, "/sys/class/graphics/%s", node) < 0 ||
|
||||||
readlink(sysfs_path, buf, sizeof(buf)) < 0 ||
|
readlink(sysfs_path, buf, sizeof(buf) - 1) < 0 ||
|
||||||
strstr(buf, "devices/pci")) {
|
strstr(buf, "devices/pci")) {
|
||||||
free(sysfs_path);
|
free(sysfs_path);
|
||||||
close(fd);
|
close(fd);
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue