Commit df382b9c authored by Grigorii Demidov's avatar Grigorii Demidov Committed by Petr Špaček

daemon/worker: compare udp src ports as well as addresses; cleanup

parent 7291e803
Pipeline #36049 passed with stages
in 8 minutes and 38 seconds
......@@ -1389,8 +1389,7 @@ static uv_handle_t *retransmit(struct qr_task *task)
}
struct sockaddr *addr = (struct sockaddr *)choice;
struct session *session = ret->data;
assert (session->peer.ip.sa_family == AF_UNSPEC);
session->outgoing = true;
assert (session->peer.ip.sa_family == AF_UNSPEC && session->outgoing);
memcpy(&session->peer, addr, sizeof(session->peer));
if (qr_task_send(task, ret, (struct sockaddr *)choice,
task->pktbuf) == 0) {
......
......@@ -379,6 +379,9 @@ int kr_sockaddr_cmp(const struct sockaddr *left, const struct sockaddr *right)
if (left_in->sin_addr.s_addr != right_in->sin_addr.s_addr) {
return kr_error(EFAULT);
}
if (left_in->sin_port != right_in->sin_port) {
return kr_error(EFAULT);
}
} else if (left->sa_family == AF_INET6) {
struct sockaddr_in6 *left_in6 = (struct sockaddr_in6 *)left;
struct sockaddr_in6 *right_in6 = (struct sockaddr_in6 *)right;
......@@ -386,6 +389,9 @@ int kr_sockaddr_cmp(const struct sockaddr *left, const struct sockaddr *right)
sizeof(struct in6_addr)) != 0) {
return kr_error(EFAULT);
}
if (left_in6->sin6_port != right_in6->sin6_port) {
return kr_error(EFAULT);
}
} else {
return kr_error(ENOENT);
}
......
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