summaryrefslogtreecommitdiff
path: root/llmnr-query.c
AgeCommit message (Collapse)AuthorFilesLines
2017-02-28llmnr-query: Fix missing NULL byteTobias Klauser1-3/+4
If the domain name in the response is <len> <octets> <00>, the code copies 'len' octets to name[], but does not add a terminating NULL character. The same may happen in the "compression" case. Fix this by adding a NULL byte in both cases. Patch constributed by @tbetker. Fixes #22 Signed-off-by: Tobias Klauser <tklauser@distanz.ch>
2017-02-09llmnr-query: Allocate receive buffer large enoughTobias Klauser1-1/+4
If an LLMNR response exceeds 128 bytes, it will get truncated. This leads to out-of-bounds read access during parsing and causes garbage data to be printed. Fix it by allocating the buffer large enough (according to RFC). Possible future improvment would be to consider the link MTU size to save some memory. Fixes #21 Signed-off-by: Tobias Klauser <tklauser@distanz.ch>
2017-02-09llmnr-query: Fix two cases where misaliged access could occurTobias Klauser1-10/+12
Two places where a misaliged could occur were missed in commit 7f719d2 ("llmnr-query: Extract LLMNR packet data in an alignment-safe way"). Fix them now. Signed-off-by: Tobias Klauser <tklauser@distanz.ch>
2017-02-08llmnr-query: Extract LLMNR packet data in an alignment-safe wayTobias Klauser1-6/+10
Follow commit 9bec6fb9 ("Fix misaligned memory access") for llmnr-query and extract values from the response packets in a way that doesn't cause unaligned memory access on architectures that don't support it. Signed-off-by: Tobias Klauser <tklauser@distanz.ch>
2017-02-08llmnr-query: Account for terminating NULL byte in address string bufferTobias Klauser1-1/+2
If the IPv6 address in the reply is 48 bytes long, inet_ntop() would overflow the addr buffer. Account for the terminating NULL byte. Signed-off-by: Tobias Klauser <tklauser@distanz.ch>
2017-01-13illmnr-query: Add const qualifier to name variableTobias Klauser1-1/+1
This fixes the following GCC warning: llmnr-query.c:345:12: warning: assignment discards ‘const’ qualifier from pointer target type [-Wdiscarded-qualifiers] Signed-off-by: Tobias Klauser <tklauser@distanz.ch>
2017-01-06llmnr-query: Add support for FreeBSD and DarwinTobias Klauser1-2/+34
Make llmnr-query work on FreeBSD and Darwin by using sendmsg() to send UDP packets. Using sendto() doesn't seem to work for IPv6 sockets. Also specify the size of the corresponding sockaddr type, not of sockaddr_storage. Tested on FreeBSD 11.0, Mac OS X 10.11. Signed-off-by: Tobias Klauser <tklauser@distanz.ch>
2017-01-06llmnr-query: Update copyrightTobias Klauser1-3/+3
Also change the description slightly and mention the LLMNR RFC number. Signed-off-by: Tobias Klauser <tklauser@distanz.ch>
2017-01-06llmnr-query: Only calculate query length if send was successfulTobias Klauser1-2/+3
Also add a comment indicating the repurposing of the pkt struct. Signed-off-by: Tobias Klauser <tklauser@distanz.ch>
2016-08-03llmnr-query: Prevent read buffer overflow in response parsingTobias Klauser1-2/+6
When accessing the compressed name in a response, verify that the pointer is within the packet size. Signed-off-by: Tobias Klauser <tklauser@distanz.ch>
2016-08-02llmnr-query: Allow to set LLMNR transaction idTobias Klauser1-3/+8
Allow to override the transaction id in the LLMNR query header. Default value is 0. The id will be incremented for consecutive queries (i.e. count > 1). Signed-off-by: Tobias Klauser <tklauser@distanz.ch>
2016-08-02llmnr-query: Make query type ANY the defaultSchimmelreiter1-2/+2
Signed-off-by: Tobias Klauser <tklauser@distanz.ch>
2016-08-02llmnr-query: Set TTL values as suggested in RFC 4795, section 2.5Tobias Klauser1-2/+27
Follow commit 64644dde ("socket: Set TTL values as suggested in RFC 4795, section 2.5") and set the TTL of the IP header to 255 for UDP unicast and multicast packets, as recommended in RFC 4795, section 2.5. Signed-off-by: Tobias Klauser <tklauser@distanz.ch>
2015-07-28llmnr-query: Consistently name variables containing number of msecsTobias Klauser1-7/+7
Signed-off-by: Tobias Klauser <tklauser@distanz.ch>
2015-07-01llmnr-query: Allow to specifiy query timeout on command lineTobias Klauser1-5/+10
Signed-off-by: Tobias Klauser <tklauser@distanz.ch>
2015-02-19llmnr-query: Inform about empty responsesTobias Klauser1-0/+5
Signed-off-by: Tobias Klauser <tklauser@distanz.ch>
2015-02-18llmnr-query: Add option to send query over different interfaceTobias Klauser1-11/+44
Signed-off-by: Tobias Klauser <tklauser@distanz.ch>
2015-02-18build: Check if called from git repo when generating GIT_VERSIONTobias Klauser1-2/+2
Signed-off-by: Tobias Klauser <tklauser@distanz.ch>
2015-02-18llmnrd, llmnr-query: Add git id to version outputTobias Klauser1-2/+3
Signed-off-by: Tobias Klauser <tklauser@distanz.ch>
2015-02-18llmnr-query: Support sending queries using IPv6Tobias Klauser1-13/+35
Partially resolves #5 (IPv6 support) Signed-off-by: Tobias Klauser <tklauser@distanz.ch>
2015-02-17all: Add version informationTobias Klauser1-2/+14
Signed-off-by: Tobias Klauser <tklauser@distanz.ch>
2015-02-17llmnr-query: Skip length byte when getting previous name in compressed name ↵Tobias Klauser1-1/+1
extraction Signed-off-by: Tobias Klauser <tklauser@distanz.ch>
2015-02-17llmnr-query: Add simple LLMNR query programTobias Klauser1-0/+237
Signed-off-by: Tobias Klauser <tklauser@distanz.ch>