Skip to content

check length of 'root' string before writing to ctx->root - #386

Merged
rajatchopra merged 1 commit into
NVIDIA:mainfrom
rajatchopra:rajatchopra-patch-1
Sep 8, 2026
Merged

check length of 'root' string before writing to ctx->root#386
rajatchopra merged 1 commit into
NVIDIA:mainfrom
rajatchopra:rajatchopra-patch-1

Conversation

@rajatchopra

Copy link
Copy Markdown
Contributor

No description provided.

Comment thread src/driver.c Outdated
.gid = gid,
.nvml_dl = NULL,
};
if (strlen(root) > sizeof(ctx->root)) {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
if (strlen(root) > sizeof(ctx->root)) {
if (strlen(root) >= sizeof(ctx->root)) {

strcpy() writes a terminating NUL byte as well. We should allow one space for that.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@rajatchopra can we update this and then have it merged?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done. Thanks.

@rahulait

rahulait commented Sep 8, 2026

Copy link
Copy Markdown
Contributor

Thanks @rajatchopra , the change LGTM. Can we squash the commits and sign them before we merge it?

Signed-off-by: Rajat Chopra <rajatc@nvidia.com>
@rajatchopra
rajatchopra merged commit 24a848d into NVIDIA:main Sep 8, 2026
4 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants