From 6b61ae5034668d118121e14068e867ce9576c4b6 Mon Sep 17 00:00:00 2001 From: Con Kolivas Date: Fri, 8 Aug 2014 21:21:36 +1000 Subject: [PATCH 1/2] Put a sanity check on the length of the btcsig --- src/ckpool.c | 4 ++++ 1 file changed, 4 insertions(+) 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"); From d69c3f07aa0f22e35f0b143387153943d30d6155 Mon Sep 17 00:00:00 2001 From: Con Kolivas Date: Fri, 8 Aug 2014 21:31:32 +1000 Subject: [PATCH 2/2] Fix aliasing warnings --- src/libckpool.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) 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; }