Skip to content

Commit

Permalink
readlink() does not write a terminating null character. So clear stri…
Browse files Browse the repository at this point in the history
…ng beforehand.
  • Loading branch information
stolk authored and intel-mediadev committed Nov 29, 2022
1 parent 8cb5f4f commit f2604e1
Showing 1 changed file with 2 additions and 0 deletions.
2 changes: 2 additions & 0 deletions cmrtlib/linux/hardware/drm_device.h
Original file line number Diff line number Diff line change
Expand Up @@ -584,6 +584,7 @@ static int parse_separate_sysfs_files(int maj, int min,

snprintf(resourcename, sizeof(resourcename), "%s/resource", pci_path);

memset(drivername, 0, sizeof(drivername));
if (readlink(driverpath, drivername, PATH_MAX) < 0)
{
/* Some devices might not be bound to a driver */
Expand Down Expand Up @@ -950,6 +951,7 @@ static int drmParseSubsystemType(int maj, int min)
snprintf(path, PATH_MAX, "/sys/dev/char/%d:%d/device/subsystem",
maj, min);

memset(link, 0, sizeof(link));
if (readlink(path, link, PATH_MAX) < 0)
return -errno;

Expand Down

0 comments on commit f2604e1

Please sign in to comment.