diff --git a/src/ckpool.c b/src/ckpool.c index 3c5529a1..b4828e33 100644 --- a/src/ckpool.c +++ b/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->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->update_interval, json_conf, "update_interval"); json_get_string(&ckp->serverurl, json_conf, "serverurl"); diff --git a/src/libckpool.c b/src/libckpool.c index b9d1e4d3..adc46f21 100644 --- a/src/libckpool.c +++ b/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; char buf[2]; bool ret; + int *cm; memset(&msg, 0, sizeof(struct msghdr)); 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_type = SCM_RIGHTS; cmptr->cmsg_len = CONTROLLLEN; - *(int *)CMSG_DATA(cmptr) = fd; + cm = (int *)CMSG_DATA(cmptr); + *cm = fd; buf[1] = 0; buf[0] = 0; 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 msghdr msg; struct cmsghdr *cmptr = ckzalloc(CONTROLLLEN); + int *cm; memset(&msg, 0, sizeof(struct msghdr)); iov[0].iov_base = buf; @@ -865,7 +868,8 @@ int _get_fd(int sockd, const char *file, const char *func, const int line) } out: close(sockd); - newfd = *(int *)CMSG_DATA(cmptr); + cm = (int *)CMSG_DATA(cmptr); + newfd = *cm; free(cmptr); return newfd; }