diff --git a/src/driver.c b/src/driver.c index d4e91c03..ea84d5ab 100644 --- a/src/driver.c +++ b/src/driver.c @@ -3,7 +3,6 @@ */ #include - #include #include "nvml.h" @@ -89,6 +88,10 @@ driver_init(struct error *err, struct dxcore_context *dxcore, const char *root, .gid = gid, .nvml_dl = NULL, }; + if (strlen(root) > sizeof(ctx->root) { + error_setx(err, "root path too long (max %zu bytes)", sizeof(ctx->root) - 1); + goto fail; + } strcpy(ctx->root, root); if (dxcore->initialized) {