Age | Commit message (Collapse) | Author | Files | Lines |
|
Enable -Wextra, sort warning flags in CFLAGS_WARN alphabetically to
avoid adding duplicates.
Signed-off-by: Tobias Klauser <tklauser@distanz.ch>
|
|
gzip and install the manpages for llmnrd and llmnr-query in the
Makefile's 'install' target.
Signed-off-by: Tobias Klauser <tklauser@distanz.ch>
|
|
Add rudimentary manpages for llmnrd and llmnr-query describing their
usage.
Fixes #14
Signed-off-by: Tobias Klauser <tklauser@distanz.ch>
|
|
Signed-off-by: Tobias Klauser <tklauser@distanz.ch>
|
|
Poll "/proc/sys/kernel/hostname" and update the hostname when it was
changed. systemd has a similar mechanism.
Note that the hostname is not polled if it has been provided on the
command line, or if "/proc/sys/kernel/hostname" cannot be opened.
Patch contributed by @tbetker
Fixes #23
Signed-off-by: Tobias Klauser <tklauser@distanz.ch>
|
|
Acknowledge @tbetker for issues #22 and #23 and the patches provided
therein.
Signed-off-by: Tobias Klauser <tklauser@distanz.ch>
|
|
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>
|
|
Signed-off-by: Tobias Klauser <tklauser@distanz.ch>
|
|
Signed-off-by: Tobias Klauser <tklauser@distanz.ch>
|
|
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>
|
|
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>
|
|
There is now an official package in the Debian package repository [1]
which should be used instead of locally built packages. Drop the local
packaging file which anyway no longer match the version in Debian.
[1] https://packages.debian.org/sid/llmnrd
Signed-off-by: Tobias Klauser <tklauser@distanz.ch>
|
|
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>
|
|
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>
|
|
Call iface_recv() from iface_rtnl_enumerate() instead of open-coding it.
Reorder code a bit to avoid duplication.
Signed-off-by: Tobias Klauser <tklauser@distanz.ch>
|
|
Use strncasecmp() from <strings.h> to compare the hostnames.
Signed-off-by: Tobias Klauser <tklauser@distanz.ch>
|
|
Make sure the hostname buffer is not accessed out of bounds.
Signed-off-by: Tobias Klauser <tklauser@distanz.ch>
|
|
When checking whether the hostname matches, llmnrd does not consider the
last character of the hostnames, leading to the following incorrect
behavior:
$ ./llmnrd -H foobar
Starting llmnrd on port 5355, hostname foobar
...
$ ./llmnr-query foobaZ
LLMNR query: foobaZ IN ANY
LLMNR response: foobar IN A 10.42.0.42 (TTL 30)
Fix it by considering the full hostname. Also do only convert alphabetic
characters to lowercase using tolower(3), since its behavior is
undefined for any other characters.
Fixes #21
Signed-off-by: Tobias Klauser <tklauser@distanz.ch>
|
|
If an interface is configured with multiple addresses, llmnrd tries to
join the LLMNR multicast group for each address instead of once per
interface. Ideally llmnrd should track whether the group is already
joined but since the kernel tells us that the group is already joined,
just omit the error message on EADDRINUSE.
This fixes the following error case:
$ ip address add 2001:db8:1::/48 dev eth0
$ ./llmnrd -6
Starting llmnrd on port 5355, hostname foobar
Added IPv4 address 127.0.0.1 on interface lo
Added IPv4 address 10.42.0.42 on interface eth0
Added IPv6 address ::1 on interface lo
Added IPv6 address 2001:db8:1:: on interface eth1
Error: Failed to join IPv6 multicast group on interface eth1: Address already in use
Added IPv6 address fe80::xxxx:xxxx:xxxx:xxxx on interface eth0
Reference: #21
Signed-off-by: Tobias Klauser <tklauser@distanz.ch>
|
|
Signed-off-by: Tobias Klauser <tklauser@distanz.ch>
|
|
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>
|
|
This fixes the following GCC warning:
util.h:55:2: warning: function might be possible candidate for ‘gnu_printf’ format attribute [-Wsuggest-attribute=format]
Signed-off-by: Tobias Klauser <tklauser@distanz.ch>
|
|
Enable some sensible GCC warnings for default build. The list of flags
was based on the flags from the nftables source.
Signed-off-by: Tobias Klauser <tklauser@distanz.ch>
|
|
Implement the check whether IPv6 is enabled properly, checking the bool
variable llmnr_ipv6 < 0 doesn't make sense.
Found by the coverity scanner (CID 159830).
Fixes: e9cd5a6826f1 ("llmnrd: merge rtnl interface event loop into main select() loops")
Signed-off-by: Tobias Klauser <tklauser@distanz.ch>
|
|
Instead of spawming a thread for the sole purpose of watching the rtnl
for (presumably) seldom events, just merge the select() for all sockets
together in one single main loop.
This reduces unnecessary complexity and makes llmnrd no longer require
any locking.
It also allows us to handle signals in a thread-safe manner (as there
aren't any ;) and thus the race condition on exit reported in #20
Closes #20
Signed-off-by: Tobias Klauser <tklauser@distanz.ch>
|
|
Distribution build scripts commonly assume the CPPFLAGS, CFLAGS and
LDFLAGS passed via command line or environment to be appended to the
base set of flags defined in the Makefile. Follow this assumption
instead of overriding the already defined values.
Also treat these three variables entriely independently instead of
appending CPPFLAGS to CFLAGS.
Reported-by: @pali
Really-fixes: #17
Signed-off-by: Tobias Klauser <tklauser@distanz.ch>
|
|
Avoid echoing the CC/LD string in verbose mode, just show the plain
commands:
$ make Q=
gcc -W -Wall -DVERSION_STRING=\"v0.2.1\" -DGIT_VERSION=\""(git id v0.2.1-6-gab7cd2fc9043)"\" -O2 -o llmnr.o -c llmnr.c
gcc -W -Wall -DVERSION_STRING=\"v0.2.1\" -DGIT_VERSION=\""(git id v0.2.1-6-gab7cd2fc9043)"\" -O2 -o iface.o -c iface.c
gcc -W -Wall -DVERSION_STRING=\"v0.2.1\" -DGIT_VERSION=\""(git id v0.2.1-6-gab7cd2fc9043)"\" -O2 -o socket.o -c socket.c
gcc -W -Wall -DVERSION_STRING=\"v0.2.1\" -DGIT_VERSION=\""(git id v0.2.1-6-gab7cd2fc9043)"\" -O2 -o util.o -c util.c
gcc -W -Wall -DVERSION_STRING=\"v0.2.1\" -DGIT_VERSION=\""(git id v0.2.1-6-gab7cd2fc9043)"\" -O2 -o llmnrd.o -c llmnrd.c
gcc -o llmnrd llmnr.o iface.o socket.o util.o llmnrd.o -lpthread
gcc -W -Wall -DVERSION_STRING=\"v0.2.1\" -DGIT_VERSION=\""(git id v0.2.1-6-gab7cd2fc9043)"\" -O2 -o llmnr-query.o -c llmnr-query.c
gcc -o llmnr-query util.o llmnr-query.o
Also consider $(Q) for the clean and install targets.
Signed-off-by: Tobias Klauser <tklauser@distanz.ch>
|
|
Currently Makefile ignores CPPFLAGS and so any defines passed via
environment/command line ignored. E.g. running
make CPPFLAGS="-D_FORTIFY_SOURCE=2"
does not compile llmnrd with buffer overflow checks.
Fix it by considering CPPFLAGS in the Makefile and appending them to
CFLAGS.
Closes #17
Signed-off-by: Tobias Klauser <tklauser@distanz.ch>
|
|
There is no need to have a timeout for select(2) to check llmnr_running
periodically. It can just block until a packet is received and will be
interrupted by any terminating signal.
Closes #19
Signed-off-by: Tobias Klauser <tklauser@distanz.ch>
|
|
FreeBSD defines these in sys/cdefs.h
Signed-off-by: Tobias Klauser <tklauser@distanz.ch>
|
|
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>
|
|
Also change the description slightly and mention the LLMNR RFC number.
Signed-off-by: Tobias Klauser <tklauser@distanz.ch>
|
|
Also add a comment indicating the repurposing of the pkt struct.
Signed-off-by: Tobias Klauser <tklauser@distanz.ch>
|
|
Bugfix release to create source packages without debian packaging
information.
Signed-off-by: Tobias Klauser <tklauser@distanz.ch>
|
|
Add a release target to the Makefile (akin to the one from netsniff-ng)
in order to streamline the release process.
Signed-off-by: Tobias Klauser <tklauser@distanz.ch>
|
|
Add a small section about basic usage of llmnrd/llmnr-query.
Signed-off-by: Tobias Klauser <tklauser@distanz.ch>
|
|
Acknowledge Pali Rohár for feedback and contributions regarding
packaging for Debian.
Signed-off-by: Tobias Klauser <tklauser@distanz.ch>
|
|
Ignore dotfiles and debian packaging in exports. The reason for
excluding the debian/ directory is that Debian preferes upstream source
packages to not contain devian packaging info.
Signed-off-by: Tobias Klauser <tklauser@distanz.ch>
|
|
Signed-off-by: Tobias Klauser <tklauser@distanz.ch>
|
|
Add Elazar Leibovich to the list of contributors for #12, #13 and commit
0c6df1b8 ("debian: add debian packaging files").
Signed-off-by: Tobias Klauser <tklauser@distanz.ch>
|
|
This allows to build a debian package by running debuild, fixes #12.
Signed-off-by: Elazar Leibovich <elazarl@gmail.com>
Signed-off-by: Tobias Klauser <tklauser@distanz.ch>
|
|
Signed-off-by: Tobias Klauser <tklauser@distanz.ch>
|
|
Convert the README file to markdown syntax so we get the nice rendering
on GitHub.
Signed-off-by: Tobias Klauser <tklauser@distanz.ch>
|
|
Mention all people how contributed to the development of llmnrd in one
way or another.
Signed-off-by: Tobias Klauser <tklauser@distanz.ch>
|
|
This changes fixes misaligned memory access. Without the patch I get
several "Misaligend access trap for user program 'llmnrd'" messages on
my platform if the system has odd hostname length.
|
|
Don't send an AAAA response if IPv6 is disabled or if no address of the
requested address family was found for a given interface.
Closes #10
Signed-off-by: Tobias Klauser <tklauser@distanz.ch>
|
|
Add a command line option -i/--interface which allows to bind the llmnrd
sockets to a specific interface. If used, requests are only answered on
the specified interface.
Example: llmnrd -i eth0
Closes #9
Signed-off-by: Tobias Klauser <tklauser@distanz.ch>
|
|
Currently IPv6 addresses are always enumerated via RTNL socket and then
stored internally, even if llmnrd was started without the IPv6 command
line option '-6'. Even though no queries on AF_INET6 sockets will be
answered, this behavior might be confusing. Especially due to messages
like:
Added IPv6 address fe80::f0eb:aaff:feb3:ae58 on interface tap0
being logged.
Explicitely disable IPv6 address enumeration on the RTNL socket to fix
this behavior.
Closes #8
Signed-off-by: Tobias Klauser <tklauser@distanz.ch>
|
|
Signed-off-by: Tobias Klauser <tklauser@distanz.ch>
|
|
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>
|