kanoi 10 years ago
parent
commit
e7b67f8d9d
  1. 4
      src/ckpool.c
  2. 8
      src/libckpool.c

4
src/ckpool.c

@ -1013,6 +1013,10 @@ static void parse_config(ckpool_t *ckp)
} }
json_get_string(&ckp->btcaddress, json_conf, "btcaddress"); json_get_string(&ckp->btcaddress, json_conf, "btcaddress");
json_get_string(&ckp->btcsig, json_conf, "btcsig"); json_get_string(&ckp->btcsig, json_conf, "btcsig");
if (ckp->btcsig && strlen(ckp->btcsig) > 38) {
LOGWARNING("Signature %s too long, truncating to 38 bytes", ckp->btcsig);
ckp->btcsig[38] = '\0';
}
json_get_int(&ckp->blockpoll, json_conf, "blockpoll"); json_get_int(&ckp->blockpoll, json_conf, "blockpoll");
json_get_int(&ckp->update_interval, json_conf, "update_interval"); json_get_int(&ckp->update_interval, json_conf, "update_interval");
json_get_string(&ckp->serverurl, json_conf, "serverurl"); json_get_string(&ckp->serverurl, json_conf, "serverurl");

8
src/libckpool.c

@ -819,6 +819,7 @@ bool _send_fd(int fd, int sockd, const char *file, const char *func, const int l
struct msghdr msg; struct msghdr msg;
char buf[2]; char buf[2];
bool ret; bool ret;
int *cm;
memset(&msg, 0, sizeof(struct msghdr)); memset(&msg, 0, sizeof(struct msghdr));
iov[0].iov_base = buf; iov[0].iov_base = buf;
@ -832,7 +833,8 @@ bool _send_fd(int fd, int sockd, const char *file, const char *func, const int l
cmptr->cmsg_level = SOL_SOCKET; cmptr->cmsg_level = SOL_SOCKET;
cmptr->cmsg_type = SCM_RIGHTS; cmptr->cmsg_type = SCM_RIGHTS;
cmptr->cmsg_len = CONTROLLLEN; cmptr->cmsg_len = CONTROLLLEN;
*(int *)CMSG_DATA(cmptr) = fd; cm = (int *)CMSG_DATA(cmptr);
*cm = fd;
buf[1] = 0; buf[1] = 0;
buf[0] = 0; buf[0] = 0;
ret = send_unix_data(sockd, &msg); ret = send_unix_data(sockd, &msg);
@ -850,6 +852,7 @@ int _get_fd(int sockd, const char *file, const char *func, const int line)
struct iovec iov[1]; struct iovec iov[1];
struct msghdr msg; struct msghdr msg;
struct cmsghdr *cmptr = ckzalloc(CONTROLLLEN); struct cmsghdr *cmptr = ckzalloc(CONTROLLLEN);
int *cm;
memset(&msg, 0, sizeof(struct msghdr)); memset(&msg, 0, sizeof(struct msghdr));
iov[0].iov_base = buf; iov[0].iov_base = buf;
@ -865,7 +868,8 @@ int _get_fd(int sockd, const char *file, const char *func, const int line)
} }
out: out:
close(sockd); close(sockd);
newfd = *(int *)CMSG_DATA(cmptr); cm = (int *)CMSG_DATA(cmptr);
newfd = *cm;
free(cmptr); free(cmptr);
return newfd; return newfd;
} }

Loading…
Cancel
Save