diff options
author | Tobias Klauser <tklauser@distanz.ch> | 2017-01-06 11:45:08 +0100 |
---|---|---|
committer | Tobias Klauser <tklauser@distanz.ch> | 2017-01-06 11:45:08 +0100 |
commit | 25985d60c2f5f2dec658a714b6db5170f113de50 (patch) | |
tree | 33ded838bb591758cde95185fba3dd89aae796ed | |
parent | 4239154f94c81781d14dee818c66805cb4054d08 (diff) |
llmnr-query: Only calculate query length if send was successful
Also add a comment indicating the repurposing of the pkt struct.
Signed-off-by: Tobias Klauser <tklauser@distanz.ch>
-rw-r--r-- | llmnr-query.c | 5 |
1 files changed, 3 insertions, 2 deletions
diff --git a/llmnr-query.c b/llmnr-query.c index 27a2034..cb2a65e 100644 --- a/llmnr-query.c +++ b/llmnr-query.c @@ -257,8 +257,6 @@ int main(int argc, char **argv) } } - query_pkt_len = pkt_len(p) - sizeof(*hdr); - if (sendto(sock, p->data, pkt_len(p), 0, (struct sockaddr *)&sst, sizeof(sst)) < 0) { log_err("Failed to send UDP packet: %s\n", strerror(errno)); break; @@ -278,7 +276,10 @@ int main(int argc, char **argv) } else if (ret) { uint16_t j, ancount; + /* save query length and re-use packet for RX */ + query_pkt_len = pkt_len(p) - sizeof(*hdr); pkt_reset(p); + if (recv(sock, p->data, p->size, 0) < 0) { log_err("Failed to receive from socket: %s\n", strerror(errno)); break; |