summaryrefslogtreecommitdiff
path: root/main.c
diff options
context:
space:
mode:
authorGravatar Alexey Yakovenko <wakeroid@gmail.com>2010-01-24 19:13:57 +0100
committerGravatar Alexey Yakovenko <wakeroid@gmail.com>2010-01-24 19:21:19 +0100
commit305bd8b2e51b844cdc68932670580b2c75716b52 (patch)
treeb6983ccaade18b21903255341f9e8cdf08d65221 /main.c
parent3c1bc4c9e8764d2301765943fcb4f0d17364c00a (diff)
proper sockaddr_un len calculation
Diffstat (limited to 'main.c')
-rw-r--r--main.c7
1 files changed, 5 insertions, 2 deletions
diff --git a/main.c b/main.c
index a0e22a4e..ea52aaa5 100644
--- a/main.c
+++ b/main.c
@@ -19,6 +19,7 @@
#include <stdint.h>
#include <string.h>
#include <stdlib.h>
+#include <stddef.h>
#include <time.h>
#ifdef __linux__
#include <sys/prctl.h>
@@ -251,7 +252,8 @@ server_start (void) {
// snprintf (srv_local.sun_path, sizeof (srv_local.sun_path), "%s/socket", dbconfdir);
// unlink(srv_local.sun_path);
memcpy (srv_local.sun_path, server_id, sizeof (server_id));
- int len = sizeof (srv_local);
+ //int len = sizeof (srv_local);
+ int len = offsetof(struct sockaddr_un, sun_path) + sizeof (server_id);
if (bind(srv_socket, (struct sockaddr *)&srv_local, len) < 0) {
perror ("bind");
return -1;
@@ -504,7 +506,8 @@ main (int argc, char *argv[]) {
memcpy (remote.sun_path, server_id, sizeof (server_id));
// snprintf (remote.sun_path, 108, "%s/socket", dbconfdir);
// len = strlen(remote.sun_path) + sizeof(remote.sun_family);
- len = sizeof (remote);
+ //len = sizeof (remote);
+ len = offsetof(struct sockaddr_un, sun_path) + sizeof (server_id);
if (connect(s, (struct sockaddr *)&remote, len) == 0) {
if (argc <= 1) {
cmdline[0] = 0;