From: Petr Špaček Date: Wed, 17 Jan 2018 13:37:16 +0000 (+0100) Subject: policy TLS_FORWARD: fix error reporting from net.tls_client() X-Git-Tag: v2.0.0~32^2~4 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=735c6ec4ab05c41f473c4dda0425bb36715675cb;p=thirdparty%2Fknot-resolver.git policy TLS_FORWARD: fix error reporting from net.tls_client() --- diff --git a/daemon/bindings.c b/daemon/bindings.c index 46aaa8c50..74e9c865f 100644 --- a/daemon/bindings.c +++ b/daemon/bindings.c @@ -391,7 +391,7 @@ static int net_tls(lua_State *L) int r = tls_certificate_set(net, lua_tostring(L, 1), lua_tostring(L, 2)); if (r != 0) { - lua_pushstring(L, strerror(ENOMEM)); + lua_pushstring(L, kr_strerror(r)); lua_error(L); } @@ -511,7 +511,7 @@ static int net_tls_client(lua_State *L) int r = tls_client_params_set(&net->tls_client_params, addr, port, NULL, NULL, NULL); if (r != 0) { - lua_pushstring(L, strerror(ENOMEM)); + lua_pushstring(L, kr_strerror(r)); lua_error(L); } @@ -529,7 +529,7 @@ static int net_tls_client(lua_State *L) int r = tls_client_params_set(&net->tls_client_params, addr, port, NULL, NULL, pin); if (r != 0) { - lua_pushstring(L, strerror(ENOMEM)); + lua_pushstring(L, kr_strerror(r)); lua_error(L); } lua_pop(L, 1); @@ -555,7 +555,7 @@ static int net_tls_client(lua_State *L) int r = tls_client_params_set(&net->tls_client_params, addr, port, ca_file, NULL, NULL); if (r != 0) { - lua_pushstring(L, strerror(ENOMEM)); + lua_pushstring(L, kr_strerror(r)); lua_error(L); } /* removes 'value'; keeps 'key' for next iteration */ @@ -569,7 +569,7 @@ static int net_tls_client(lua_State *L) int r = tls_client_params_set(&net->tls_client_params, addr, port, NULL, hostname, NULL); if (r != 0) { - lua_pushstring(L, strerror(ENOMEM)); + lua_pushstring(L, kr_strerror(r)); lua_error(L); } /* removes 'value'; keeps 'key' for next iteration */ @@ -1393,7 +1393,7 @@ static int wrk_resolve(lua_State *L) /* Create query packet */ knot_pkt_t *pkt = knot_pkt_new(NULL, KNOT_EDNS_MAX_UDP_PAYLOAD, NULL); if (!pkt) { - lua_pushstring(L, strerror(ENOMEM)); + lua_pushstring(L, kr_strerror(ENOMEM)); lua_error(L); } uint8_t dname[KNOT_DNAME_MAXLEN]; diff --git a/daemon/tls.c b/daemon/tls.c index 17e0bf5bb..fc846d3cb 100644 --- a/daemon/tls.c +++ b/daemon/tls.c @@ -621,7 +621,7 @@ int tls_client_params_set(map_t *tls_client_paramlist, int res = gnutls_certificate_set_x509_trust_file(entry->credentials, value, GNUTLS_X509_FMT_PEM); if (res < 0) { - kr_log_error("[tls client], failed to import certificate file '%s' (%s)\n", + kr_log_error("[tls client] failed to import certificate file '%s' (%s)\n", value, gnutls_strerror_name(res)); /* value will be freed at cleanup */ ret = kr_error(EINVAL);