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

api: raise an error if the socket path is too long #158

Merged

Conversation

giuseppe
Copy link
Collaborator

@giuseppe giuseppe commented Nov 4, 2019

Signed-off-by: Giuseppe Scrivano gscrivan@redhat.com

@giuseppe giuseppe force-pushed the detect-too-long-api-socket branch 2 times, most recently from 5d3857f to 1fe8a83 Compare November 4, 2019 16:39
api.c Outdated
fprintf(stderr, "the specified API socket path is too long (> %d)\n", sizeof(addr.sun_path));
return -1;
}
strcpy(addr.sun_path, api_socket);
Copy link
Member

Choose a reason for hiding this comment

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

I think we should use strncpy everytime to avoid potential lint false-positive

Copy link
Member

Choose a reason for hiding this comment

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

also make sure to terminate with NUL

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

moved back to strncpy.

The addr.sun_path string is NUL terminated since we have memset(&addr, 0, sizeof(addr));

api.c Outdated
@@ -21,6 +21,11 @@ int api_bindlisten(const char *api_socket)
}
memset(&addr, 0, sizeof(addr));
addr.sun_family = AF_UNIX;
if (strlen(api_socket) >= sizeof(addr.sun_path)) {
fprintf(stderr, "the specified API socket path is too long (> %lu)\n",
Copy link
Member

Choose a reason for hiding this comment

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

nit: >=

Signed-off-by: Giuseppe Scrivano <gscrivan@redhat.com>
@AkihiroSuda AkihiroSuda merged commit 0186bac into rootless-containers:master Nov 4, 2019
This was referenced Dec 12, 2019
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.

2 participants