* src/node_device/node_device_driver.c (update_driver_name): The
previous code would write one byte beyond the end of the 4KiB
stack buffer when presented with a symlink value of exactly that
length (very unlikely). Remove the automatic buffer and use
virFileResolveLink in place of readlink. Suggested by Daniel Veillard.
virNodeDeviceObjPtr dev)
{
char *driver_link = NULL;
- char devpath[PATH_MAX];
+ char *devpath;
char *p;
int ret = -1;
- int n;
VIR_FREE(dev->def->driver);
goto cleanup;
}
- if ((n = readlink(driver_link, devpath, sizeof devpath)) < 0) {
+ if (virFileResolveLink(driver_link, &devpath) < 0) {
virReportSystemError(conn, errno,
_("cannot resolve driver link %s"), driver_link);
goto cleanup;
}
- devpath[n] = '\0';
p = strrchr(devpath, '/');
if (p) {
cleanup:
VIR_FREE(driver_link);
+ free(devpath);
return ret;
}
#else