Skip to content

Commit 2bee8f0

Browse files
committed
check length of 'root' string before writing to ctx->root
Signed-off-by: Rajat Chopra <rajatc@nvidia.com>
1 parent 08cb279 commit 2bee8f0

1 file changed

Lines changed: 4 additions & 0 deletions

File tree

‎src/driver.c‎

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -89,6 +89,10 @@ driver_init(struct error *err, struct dxcore_context *dxcore, const char *root,
8989
.gid = gid,
9090
.nvml_dl = NULL,
9191
};
92+
if (strlen(root) >= sizeof(ctx->root)) {
93+
error_setx(err, "root path too long (max %zu bytes)", sizeof(ctx->root) - 1);
94+
goto fail;
95+
}
9296
strcpy(ctx->root, root);
9397

9498
if (dxcore->initialized) {

0 commit comments

Comments
 (0)