diff --git a/hw/xfree86/fbdevhw/fbdevhw.c b/hw/xfree86/fbdevhw/fbdevhw.c index 95089515c57805fcd78601b00340adfe5dcad766..f146ff4a4d10f38a397aee41acedec77cdddae90 100644 --- a/hw/xfree86/fbdevhw/fbdevhw.c +++ b/hw/xfree86/fbdevhw/fbdevhw.c @@ -331,12 +331,12 @@ fbdev_open(int scrnIndex, const char *dev, char **namep) /* only touch non-PCI devices on this path */ { - char buf[PATH_MAX]; + char buf[PATH_MAX] = {0}; char *sysfs_path = NULL; char *node = strrchr(dev, '/') + 1; 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")) { free(sysfs_path); close(fd);