Skip to content

Commit 1be5bf8

Browse files
poetteringbluca
authored andcommitted
dns-stream: only read DNS packet data if we identified the peer properly
If we use TCP fastopen to connect to a DNS server via TCP, and it responds really quickly between our connection attempt and our immediate check back, then we have not identified the peer yet, and will not be able to use the peer metadata to fill in our packet info. Let's fix that, and simply not read from the socket until identification is complete. Fixes: #34956 (cherry picked from commit facc943) (cherry picked from commit 11da527) (cherry picked from commit 9bf15a2) (cherry picked from commit e22b61d) (cherry picked from commit 8398ac6) (cherry picked from commit e6e2c36)
1 parent e2abe9b commit 1be5bf8

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

src/resolve/resolved-dns-stream.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -359,7 +359,8 @@ static int on_stream_io(sd_event_source *es, int fd, uint32_t revents, void *use
359359
}
360360
}
361361

362-
while ((revents & (EPOLLIN|EPOLLHUP|EPOLLRDHUP)) &&
362+
while (s->identified && /* Only read data once we identified the peer, because we cannot fill in the DNS packet meta info otherwise */
363+
(revents & (EPOLLIN|EPOLLHUP|EPOLLRDHUP)) &&
363364
(!s->read_packet ||
364365
s->n_read < sizeof(s->read_size) + s->read_packet->size)) {
365366

0 commit comments

Comments
 (0)