Skip to content
Draft
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 5 additions & 2 deletions src/driver.c
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
*/

#include <sys/types.h>

#include <bsd/string.h>
#include <inttypes.h>

#include "nvml.h"
Expand Down Expand Up @@ -89,7 +89,10 @@ driver_init(struct error *err, struct dxcore_context *dxcore, const char *root,
.gid = gid,
.nvml_dl = NULL,
};
strcpy(ctx->root, root);
if (strlcpy(ctx->root, root, sizeof(ctx->root)) >= sizeof(ctx->root)) {
error_setx(err, "root path too long (max %zu bytes)", sizeof(ctx->root) - 1);
goto fail;
}

if (dxcore->initialized) {
memset(ctx->nvml_path, 0, strlen(ctx->nvml_path));
Expand Down
Loading