diff --git a/lib/connection.c b/lib/connection.c index 50db287..ec515dc 100644 --- a/lib/connection.c +++ b/lib/connection.c @@ -21,6 +21,7 @@ #include #include +#include #include #include @@ -199,6 +200,7 @@ static int __resolvehost(const char *hostname, char *buf, int buf_len, buf, buf_len, &hp, &herr); if (!hp) return NO_ADDRESS; + if(hres) return NO_ADDRESS; *rhp = hp; @@ -273,9 +275,9 @@ static void __wake_up_waiters(conn_t *co, int opcode) static int __default_auth_set_context(void *cctx, sexp_t *sx) { conn_t *co = (conn_t *)cctx; - char *val, *var, *tbuf; + char *val, *var, *tbuf = NULL; sexp_t *lsx, *sx_iter, *sx_in; - int llen, idx, err; + int llen, idx, err = 0; //co->pctx = malloc(sizeof(perm_ctx_t)); @@ -319,9 +321,13 @@ static int __default_auth_set_context(void *cctx, sexp_t *sx) /* ok, now we need to fill security context */ tbuf = malloc(2048); + if(!tbuf) { + err = ENOMEM; + goto __reply; + } if(conn_sys->secure_check) err = conn_sys->secure_check(co); - + __reply: if(err) { snprintf(tbuf, 2048, "(auth-set-error (%d))", err); @@ -338,7 +344,6 @@ __reply: free(tbuf); return err; - } static int __default_auth_set_attr(void *cctx, sexp_t *sx) @@ -1651,7 +1656,7 @@ static char *__generate_uuid(void) */ static int __verify_certcall(int preverify_ok, X509_STORE_CTX *ctx) { - X509 *cert = X509_STORE_CTX_get_current_cert(ctx); + // X509 *cert = X509_STORE_CTX_get_current_cert(ctx); int err = X509_STORE_CTX_get_error(ctx), depth = X509_STORE_CTX_get_error_depth(ctx); SSL *ssl = X509_STORE_CTX_get_ex_data(ctx, SSL_get_ex_data_X509_STORE_CTX_idx()); conn_t *co = SSL_get_ex_data(ssl, conn_sys->ex_ssldata_index); /* this is a custom data we're set before */ @@ -1871,7 +1876,7 @@ int connection_initiate(conn_t *co, const char *host, int port, if(!pctx) return EINVAL; memset(co, 0, sizeof(conn_t)); - + pth_dqtpoll_init(tpoll, __rpc_callback); if(!idx_ch) return ENOMEM; @@ -2041,7 +2046,7 @@ int connection_initiate(conn_t *co, const char *host, int port, int connection_create(conn_t *co, int sck) { - int r = 0, sd; + int r = 0; int bytes = 0; char *uuid; char *buf = NULL; @@ -2307,23 +2312,20 @@ int channel_open(conn_t *co, chnl_t **ch, int type) char *uuid_; sxpayload_t *pl; ulong_t cid; - rpc_typed_list_t *rpclist; - usrtc_node_t *node; + rpc_typed_list_t *rpclist = NULL; + usrtc_node_t *node = NULL; sxmsg_t *sms; - + if(!(co->flags & CXCONN_ESTABL)) { return ESXNOCONNECT; } - + uuid_ = __generate_uuid(); pl = malloc(sizeof(sxpayload_t)); node = usrtc_lookup(co->rpc_list, &type); - /* - if(!node) { - r = EINVAL; printf("fuck\n"); - goto __fini_op; - } else rpclist = (rpc_typed_list_t *)usrtc_node_getdata(node); - */ + + if(node) rpclist = (rpc_typed_list_t *)usrtc_node_getdata(node); + if(!uuid_) { if(pl) free(pl); return ENOMEM;