diff options
| -rw-r--r-- | PICA_node.c | 45 | ||||
| -rw-r--r-- | PICA_signverify.c | 3 |
2 files changed, 28 insertions, 20 deletions
diff --git a/PICA_node.c b/PICA_node.c index 8b5200f..3f61fd0 100644 --- a/PICA_node.c +++ b/PICA_node.c @@ -62,7 +62,7 @@ typedef u_short uint16_t; time_t skynet_refresh_tmst; -clock_t TMO_CCLINK_WAITACTIVE = 15; //CONF +time_t TMO_CCLINK_WAITACTIVE = 15; //CONF char *my_addr;//TEMP CONF FIXME @@ -768,7 +768,7 @@ unsigned int procmsg_MULTILOGIN_node(unsigned char* buf, unsigned int size, void if (mp) { - memcpy(mp, buf, size); + memcpy(mp->tail, buf + 2, size - 2); } c = c->next_multi; @@ -1059,6 +1059,11 @@ unsigned int procmsg_NODELIST(unsigned char* buf, unsigned int size, void* ptr) inet_ntoa(*(struct in_addr*)&na_ipv4.addr), ntohs(na_ipv4.port) ); } + if (listleft < PICA_PROTO_NODELIST_ITEM_IPV4_SIZE) + { + PICA_warn("Unexpected end of nodelist packet"); + return 0; + } listleft -= PICA_PROTO_NODELIST_ITEM_IPV4_SIZE; break; } @@ -1757,7 +1762,7 @@ int PICA_node_init() fclose(dh_file); } else - PICA_fatal("Unable to open DH parameters file %", nodecfg.dh_param_file); + PICA_fatal("Unable to open DH parameters file %s", nodecfg.dh_param_file); ret = SSL_CTX_set_tmp_dh(anon_ctx, dh); @@ -2044,6 +2049,14 @@ struct client *client_list_addnew(struct newconn *nc) if (!ci) return 0; + ci->r_buf = calloc(1, DEFAULT_BUF_SIZE); + if (!ci->r_buf) + { + free(ci); + return 0; + } + ci->buflen_r = DEFAULT_BUF_SIZE; + ci->ssl_comm = SSL_new (ctx); if (!ci->ssl_comm) @@ -2070,14 +2083,6 @@ struct client *client_list_addnew(struct newconn *nc) SSL_set_fd(ci->ssl_comm, ci->sck_comm); - ci->r_buf = calloc(1, DEFAULT_BUF_SIZE); - if (!ci->r_buf) - { - free(ci); - return 0; - } - ci->buflen_r = DEFAULT_BUF_SIZE; - ci->tmst = time(0); ci->ev_read = event_new(pica_event_base, ci->sck_comm, EV_READ | EV_PERSIST, process_c2n_read, ci); @@ -2249,6 +2254,14 @@ struct nodelink *nodelink_list_addnew(struct newconn *nc) if (!nl) return 0; + nl->r_buf = calloc(1, DEFAULT_BUF_SIZE); + if (!nl->r_buf) + { + free(nl); + return 0; + } + nl->buflen_r = DEFAULT_BUF_SIZE; + if (nodelink_list_end) { nodelink_list_end->next = nl; @@ -2266,14 +2279,6 @@ struct nodelink *nodelink_list_addnew(struct newconn *nc) nl->anonssl = nc->anonssl; nc->anonssl = NULL; - nl->r_buf = calloc(1, DEFAULT_BUF_SIZE); - if (!nl->r_buf) - { - free(nl); - return 0; - } - nl->buflen_r = DEFAULT_BUF_SIZE; - nl->tmst = time(0); nl->ev_read = event_new(pica_event_base, nl->sck, EV_READ | EV_PERSIST, process_n2n_read, nl); @@ -2528,7 +2533,7 @@ void process_timeouts_c2n() if (kill_ptr) { - PICA_info("Disconnecting user %u due to noreply timeout", kill_ptr -> id); + PICA_info("Disconnecting user %s due to noreply timeout", PICA_id_to_base64(kill_ptr ->id, NULL)); client_list_delete(kill_ptr); kill_ptr = 0; } diff --git a/PICA_signverify.c b/PICA_signverify.c index e9d4878..95a5b12 100644 --- a/PICA_signverify.c +++ b/PICA_signverify.c @@ -101,7 +101,10 @@ int PICA_do_signature(EVP_PKEY *privkey, void **datapointers, size_t *datalength if (ret == 1) ret = 1; else + { free(*sig); + *sig = NULL; + } sig_exit: EVP_MD_CTX_destroy(mdctx); |
