summaryrefslogtreecommitdiffstats
path: root/lib/receiver.c
diff options
context:
space:
mode:
Diffstat (limited to 'lib/receiver.c')
-rw-r--r--lib/receiver.c11
1 files changed, 5 insertions, 6 deletions
diff --git a/lib/receiver.c b/lib/receiver.c
index 4592916..b58e8be 100644
--- a/lib/receiver.c
+++ b/lib/receiver.c
@@ -107,14 +107,12 @@ icipc_receiver_new (const char *path,
size_t user_size)
{
struct icipc_receiver *self;
- int name_size;
+ int res;
/* check params */
if (path == NULL || buffer_size == 0)
return NULL;
- unlink (path);
-
self = calloc (1, sizeof (struct icipc_receiver) + user_size);
if (self == NULL)
return NULL;
@@ -123,11 +121,12 @@ icipc_receiver_new (const char *path,
/* set address */
self->addr.sun_family = AF_LOCAL;
- name_size = snprintf(self->addr.sun_path, sizeof(self->addr.sun_path), "%s",
- path) + 1;
- if (name_size > (int) sizeof(self->addr.sun_path))
+ res = icipc_construct_socket_path (path, self->addr.sun_path, sizeof(self->addr.sun_path));
+ if (res < 0)
goto error;
+ unlink (self->addr.sun_path);
+
/* create socket */
self->socket_fd =
socket(PF_LOCAL, SOCK_STREAM | SOCK_CLOEXEC | SOCK_NONBLOCK, 0);