mirror of
https://git.proxmox.com/git/mirror_corosync-qdevice
synced 2025-04-28 16:33:21 +00:00
unix-socket: Fix snprintf warning
Base N on sizeof sun_path instead of strlen of input path. Signed-off-by: Jan Friesse <jfriesse@redhat.com>
This commit is contained in:
parent
b27e907cbd
commit
466ab62f10
@ -60,7 +60,7 @@ unix_socket_server_create(const char *path, int non_blocking, int backlog)
|
||||
memset(&sun, 0, sizeof(sun));
|
||||
sun.sun_family = AF_UNIX;
|
||||
|
||||
strncpy(sun.sun_path, path, strlen(path));
|
||||
strncpy(sun.sun_path, path, sizeof(sun.sun_path) - 1);
|
||||
unlink(path);
|
||||
if (bind(s, (struct sockaddr *)&sun, SUN_LEN(&sun)) != 0) {
|
||||
close(s);
|
||||
@ -103,7 +103,7 @@ unix_socket_client_create(const char *path, int non_blocking)
|
||||
memset(&sun, 0, sizeof(sun));
|
||||
sun.sun_family = AF_UNIX;
|
||||
|
||||
strncpy(sun.sun_path, path, strlen(path));
|
||||
strncpy(sun.sun_path, path, sizeof(sun.sun_path) - 1);
|
||||
|
||||
if (non_blocking) {
|
||||
if (utils_fd_set_non_blocking(s) != 0) {
|
||||
|
Loading…
Reference in New Issue
Block a user