Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

nsexec.c: fix GCC 8 warning #1779

Merged
merged 1 commit into from
Apr 12, 2018
Merged

Conversation

runcom
Copy link
Member

@runcom runcom commented Apr 12, 2018

$ make BUILDTAGS="seccomp selinux"
go build -buildmode=pie  -ldflags "-X main.gitCommit="0e16bd9b53eb3c57ea6fe59fc6d9385c2edb9fd9" -X main.version=1.0.0-rc5+dev " -tags "seccomp selinux" -o runc .
# github.com/opencontainers/runc/libcontainer/nsenter
nsexec.c: In function ‘join_namespaces’:
nsexec.c:508:3: warning: ‘strncpy’ specified bound 4096 equals destination size [-Wstringop-truncation]
   strncpy(ns->path, path, PATH_MAX);
   ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

Signed-off-by: Antonio Murdaca [email protected]

Signed-off-by: Antonio Murdaca <[email protected]>
@@ -505,7 +505,8 @@ void join_namespaces(char *nslist)

ns->fd = fd;
ns->ns = nsflag(namespace);
strncpy(ns->path, path, PATH_MAX);
strncpy(ns->path, path, PATH_MAX - 1);
ns->path[PATH_MAX - 1] = '\0';
Copy link
Member

Choose a reason for hiding this comment

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

Eugh, why doesn't glibc have strlcpy. 😢

@cyphar
Copy link
Member

cyphar commented Apr 12, 2018

LGTM.

Approved with PullApprove

@rhatdan
Copy link
Contributor

rhatdan commented Apr 12, 2018

LGTM

@crosbymichael
Copy link
Member

crosbymichael commented Apr 12, 2018

LGTM

Approved with PullApprove

@crosbymichael crosbymichael merged commit f753f30 into opencontainers:master Apr 12, 2018
@runcom runcom deleted the gcc8-fix branch April 12, 2018 16:24
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.

4 participants