Commit 3ab77332 authored by Vladimír Čunát's avatar Vladimír Čunát
Browse files

Merge !221: daemon: fixed memory leak and array bounds check fail

Submitted as https://github.com/CZ-NIC/knot-resolver/pull/42
parents f8487fd6 924d9936
Pipeline #2149 passed with stages
in 2 minutes and 2 seconds
......@@ -302,10 +302,9 @@ static int net_interfaces(lua_State *L)
char *p = buf;
memset(buf, 0, sizeof(buf));
for (unsigned k = 0; k < sizeof(iface.phys_addr); ++k) {
sprintf(p, "%.2x:", iface.phys_addr[k] & 0xff);
sprintf(p, "%s%.2x", k > 0 ? ":" : "", iface.phys_addr[k] & 0xff);
p += 3;
}
*(p - 1) = '\0';
lua_pushstring(L, buf);
lua_setfield(L, -2, "mac");
......
......@@ -408,6 +408,7 @@ static int run_worker(uv_loop_t *loop, struct engine *engine, fd_array_t *ipc_se
return kr_ok();
}
#ifdef HAS_SYSTEMD
static void free_sd_socket_names(char **socket_names, int count)
{
for (int i = 0; i < count; i++) {
......@@ -415,6 +416,7 @@ static void free_sd_socket_names(char **socket_names, int count)
}
free(socket_names);
}
#endif
int main(int argc, char **argv)
{
......
......@@ -507,6 +507,7 @@ static int qr_task_send(struct qr_task *task, uv_handle_t *handle, struct sockad
handle->type == UV_UDP ? SOCK_DGRAM : SOCK_STREAM,
pkt);
if (ret != kr_ok()) {
req_release(task->worker, send_req);
return ret;
}
}
......@@ -937,7 +938,6 @@ int worker_process_tcp(struct worker_ctx *worker, uv_stream_t *handle, const uin
}
int submitted = 0;
ssize_t nbytes = 0;
struct qr_task *task = session->buffering;
/* If this is a new query, create a new task that we can use
......@@ -979,7 +979,7 @@ int worker_process_tcp(struct worker_ctx *worker, uv_stream_t *handle, const uin
/* Finish reading DNS/TCP message length. */
if (task->bytes_remaining == 0 && pkt_buf->size == 1) {
pkt_buf->wire[1] = msg[0];
nbytes = msg_size(pkt_buf->wire);
ssize_t nbytes = msg_size(pkt_buf->wire);
len -= 1;
msg += 1;
/* Cut off fragment length and start reading DNS message. */
......
......@@ -75,8 +75,6 @@ static int srvr_sockaddr_cc_check(const struct sockaddr *srvr_sa,
return -2;
}
const struct knot_cc_alg *cc_alg = NULL;
assert(clnt_sett->current.secr);
/* The address must correspond with the client cookie. */
......@@ -87,7 +85,7 @@ static int srvr_sockaddr_cc_check(const struct sockaddr *srvr_sa,
.secret_len = clnt_sett->current.secr->size
};
cc_alg = kr_cc_alg_get(clnt_sett->current.alg_id);
const struct knot_cc_alg *cc_alg = kr_cc_alg_get(clnt_sett->current.alg_id);
if (!cc_alg) {
return -2;
}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment