-
Notifications
You must be signed in to change notification settings - Fork 83
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
api: raise an error if the socket path is too long #158
Conversation
5d3857f
to
1fe8a83
Compare
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); |
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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));
1fe8a83
to
59f860f
Compare
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", |
There was a problem hiding this comment.
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>
59f860f
to
b08917a
Compare
Signed-off-by: Giuseppe Scrivano gscrivan@redhat.com