commit fa554032f196909df3311fde448bb658d288c4f6
parent bd3e6136568bbc5f88fdcd418ea275c11f3c3c12
Author: Michael Forney <mforney@mforney.org>
Date: Sat, 19 Aug 2017 18:50:04 -0700
Check snprintf result
Diffstat:
1 file changed, 6 insertions(+), 0 deletions(-)
diff --git a/drm.c b/drm.c
@@ -44,6 +44,7 @@ static const struct drm_driver * find_driver(int fd)
struct stat st;
FILE * file;
uint32_t index;
+ int n;
if (fstat(fd, &st) == -1)
return NULL;
@@ -51,6 +52,11 @@ static const struct drm_driver * find_driver(int fd)
if (getenv("WLD_DRM_DUMB"))
goto dumb;
+ n = snprintf(path, sizeof(path), "/sys/dev/char/%u:%u/device/", major(st.st_rdev), minor(st.st_rdev));
+ if (n + 6 >= sizeof(path))
+ return NULL;
+ path_part = path + n;
+
strcpy(path_part, "vendor");
file = fopen(path, "r");
if (!file)