Git Product home page Git Product logo

libmicrodns's People

Contributors

3xx0 avatar chouquette avatar flameeyes avatar hadess avatar jbkempf avatar mathieuduponchelle avatar mstorsjo avatar psilokos avatar robux4 avatar rolznz avatar seanmcg avatar sharpe49 avatar sleepybishop avatar tguillem avatar tp-m avatar xclaesse avatar yurivict avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

libmicrodns's Issues

Static link fails for Windows

I'm trying to static link GStreamer and its plugins, including libmicrodns together into a Windows DLL, but the final link gives that error:

/usr/bin/x86_64-w64-mingw32-ld: /usr/lib/gcc/x86_64-w64-mingw32/9.3-posix/../../../../x86_64-w64-mingw32/lib/libws2_32.a(libws2_32s00183.o):(.text+0x0): multiple definition of `inet_pton'; subprojects/libmicrodns/src/libmicrodns.a(inet.c.obj):/home/xclaesse/programmation/gstreamer/builddir/../subprojects/libmicrodns/compat/inet.c:58: first defined here
/usr/bin/x86_64-w64-mingw32-ld: /usr/lib/gcc/x86_64-w64-mingw32/9.3-posix/../../../../x86_64-w64-mingw32/lib/libws2_32.a(libws2_32s00182.o):(.text+0x0): multiple definition of `inet_ntop'; subprojects/libmicrodns/src/libmicrodns.a(inet.c.obj):/home/xclaesse/programmation/gstreamer/builddir/../subprojects/libmicrodns/compat/inet.c:33: first defined here

It looks like libmicrodns redefines a symbol from Windows's libws2_32. Could that symbol be renamed maybe?

IPV6 announcement fails on Linux

To reproduce, change the announce example to init libmicrodns with MDNS_ADDR_IPV6 instead of MDNS_ADDR_IPV4.

Binding the socket will fail with "invalid argument"

if (bind(ctx->conns[i].sock, (const struct sockaddr *) &ctx->addr, ss_len(&ctx->addr)) < 0)
                    return mdns_destroy(ctx), (MDNS_NETERR);

The socket is created for the correct address family (AF_INET6) and ss_len(&ctx->addr) matches sizeof(struct sockaddr_in6)

I'm trying to figure out what's wrong but so far not having any luck. If anyone has any ideas, let me know.

Change name of strrcmp() function

I was looking through the libmicrodns code, and I was really confused by strrcmp(), which seems to be misnamed, hence my confusion.

static int 
strrcmp(const char *s1, const char *s2)

If I understood the code correctly, it checks that the the last strlen(s2) characters of s1 are the same as s2. The function also doesn't ever return -1 which means it's not really a variants of strcmp().

Given all that, could the function be changed to something like:

static bool
str_has_prefix(const char *str, const char *prefix)

I'm happy to make that change myself, I will need to make some more changes for A/AAAA queries support.

Add example of .local name resolution

This would be helpful for applications and libraries that want to add .local name resolution without requiring OS support (NSS configuration, Avahi availability and accessibility).

I'm guessing it involves starting a listen and checking for R_A and R_AAAA type answers in the callback, but I don't know which parameters I'd need to pass to mdns_listen(), and it's been 17 years since I last worked on an mDNS implementation.

Required patches to include inet-related headers on FreeBSD

I had to apply these patches to build on FreeBSD 12.2:

--- include/microdns/rr.h.orig	2020-10-29 02:44:44 UTC
+++ include/microdns/rr.h
@@ -35,6 +35,8 @@
 # include <ws2tcpip.h>
 #endif
 
+#include <netinet/in.h>
+
 # ifdef __cplusplus
 extern "C" {
 # endif
--- include/utils.h.orig	2020-10-29 02:42:44 UTC
+++ include/utils.h
@@ -31,6 +31,8 @@
 #include <stdio.h>
 #include <stdint.h>
 
+#include <netinet/in.h>
+
 #include "compat.h"
 
 #define MDNS_DN_MAXSZ 256 // domain name maximum size
--- src/rr.c.orig	2020-10-29 02:40:53 UTC
+++ src/rr.c
@@ -32,6 +32,8 @@
 #include <stdlib.h>
 #include <stdint.h>
 
+#include <netinet/in.h>
+
 #include "utils.h"
 #include "microdns/microdns.h"
 #include "microdns/rr.h"

Talos Security Advisory for videolabs (TALOS-2020-0994-0996)

Hello,
The Cisco Talos team found security vulnerabilities affecting videolabs. As this is a sensitive security issue, please provide an email address & PGP key or mark this issue as private. Please acknowledge receipt of this message so we can confirm we have the correct method for reporting security issues.

For further information about the Cisco Vendor Vulnerability Reporting and Disclosure Policy please refer to this document which also links to our public PGP key. https://tools.cisco.com/security/center/resources/vendor_vulnerability_policy.html

Please CC [email protected] on all correspondence related to this issue.

MCAST_JOIN_GROUP - ENODEV - No such device

Hello,

I am using libmicrodns on Linux and I have some issues with it:

  • When the board is connected via Ethernet/WiFi: The function mdns_init() succeed.
  • When the board is not connected via Ethernet/WiFi: The function mdns_init() fails.

As I also want it to work in local, it's a problem (I have an openthread border router, so avahi-daemon is running in local)

Here is the strace:

socket(AF_INET, SOCK_DGRAM, IPPROTO_UDP) = 18
setsockopt(18, SOL_SOCKET, SO_REUSEADDR, [1], 4) = 0
bind(18, {sa_family=AF_INET, sin_port=htons(5353), sin_addr=inet_addr("0.0.0.0")}, 16) = 0
setsockopt(18, SOL_IP, MCAST_JOIN_GROUP, {gr_interface=0, gr_group={sa_family=AF_INET, sin_port=htons(5353), sin_addr=inet_addr("224.0.0.251")}}, 132) = -1 ENODEV (No such device)
close(18)      

I tried to add "MULTICAST" to lo interface, but unfortunately it doesn't change the result.

I am using this commit: 8cb6b90

Library compiles with serious warnings under Windows

It appears as though the code, despite not being written to work with Windows wide-character ("Unicode" / UTF16) APIs, is defining UNICODE and thus compiling with serious warnings.
Would the desired solution be not defining UNICODE or converting the code to work with W APIs properly?

$ make
make  all-am
make[1]: Entering directory '/z/Projects/libmicrodns/build'
  CC       compat/compat.lo
../compat/compat.c: In function 'inet_pton':
../compat/compat.c:79:32: warning: passing argument 1 of 'WSAStringToAddressW' from incompatible pointer type
         if (WSAStringToAddress(src_copy, af, NULL, (struct sockaddr *)&ss, &size) == 0) {
                                ^
In file included from ../compat/compat.h:66:0,
                 from ../compat/compat.c:27:
C:/msys64/mingw64/x86_64-w64-mingw32/include/winsock2.h:1058:34: note: expected 'LPWSTR' but argument is of type 'char *'
   WINSOCK_API_LINKAGE INT WSAAPI WSAStringToAddressW(LPWSTR AddressString,INT AddressFamily,LPWSAPROTOCOL_INFOW lpProtocolInfo,LPSOCKADDR lpAddress,LPINT lpAddressLength);
                                  ^
../compat/compat.c: In function 'os_strerror':
../compat/compat.c:107:39: warning: passing argument 5 of 'FormatMessageW' from incompatible pointer type
                             errno, 0, buf, buflen, NULL))
                                       ^
In file included from C:/msys64/mingw64/x86_64-w64-mingw32/include/windows.h:70:0,
                 from C:/msys64/mingw64/x86_64-w64-mingw32/include/winsock2.h:23,
                 from ../compat/compat.h:66,
                 from ../compat/compat.c:27:
C:/msys64/mingw64/x86_64-w64-mingw32/include/winbase.h:1343:27: note: expected 'LPWSTR' but argument is of type 'char *'
   WINBASEAPI DWORD WINAPI FormatMessageW (DWORD dwFlags, LPCVOID lpSource, DWORD dwMessageId, DWORD dwLanguageId, LPWSTR lpBuffer, DWORD nSize, va_list *Arguments);
                           ^
../compat/compat.c:118:27: warning: assignment from incompatible pointer type
                         s = gai_strerror(errno);
                           ^

Failure to initialize using IPv4 when MCAST_JOIN_GROUP is not available

When trying to join the multicast group using IP_ADD_MEMBERSHIP as a fallback for MCAST_JOIN_GROUP, we end up providing an invalid interface to ip_mreq::imr_interface which is an IN_ADDR in this case, as opposed to:

  • the interface index for IPv6 (when using both IP_ADD_MEMBERSHIP or MCAST_JOIN_GROUP)
  • The interface index when using IPv4 with MCAST_JOIN_GROUP

It's possible to quick & dirty fix this by ifdefing the win32 code and copy a different field (in a different loop), but it might be a better idea to provide both interface index & addresses.

Another option is to drop the fallback since MCAST_JOIN_GROUP is available since Vista (AFAICS)

Stackoverflow when network gets disconnected

error: Invalid argument
error: Invalid argument
error: Invalid argument
error: Invalid argument
error: Invalid argument
error: Invalid argument
error: Invalid argument
error: Invalid argument
error: Invalid argument
error: Invalid argument
error: Invalid argument
error: Invalid argument
error: Invalid argument
error: Invalid argument
error: Invalid argument
ASAN:DEADLYSIGNAL
=================================================================
==29500==ERROR: AddressSanitizer: stack-overflow on address 0x7ffcbcde7ff8 (pc 0x7f913da53b4c bp 0x7ffcbcde8590 sp 0x7ffcbcde8000 T0)
    #0 0x7f913da53b4b in _IO_default_xsputn (/lib/x86_64-linux-gnu/libc.so.6+0x74b4b)
    #1 0x7f913da25e05 in vfprintf (/lib/x86_64-linux-gnu/libc.so.6+0x46e05)
    #2 0x7f913da28c22  (/lib/x86_64-linux-gnu/libc.so.6+0x49c22)
    #3 0x7f913da25ef4 in vfprintf (/lib/x86_64-linux-gnu/libc.so.6+0x46ef4)
    #4 0x7f913e014eef in vfprintf (/usr/lib/x86_64-linux-gnu/libasan.so.3+0x8aeef)
    #5 0x7f913e014fc2 in __interceptor_fprintf (/usr/lib/x86_64-linux-gnu/libasan.so.3+0x8afc2)
    #6 0x560afb0d1223 in callback (/home/chouquette/dev/libmicrodns/build-asan/.libs/test+0x1223)
    #7 0x7f913dd838e4 in mdns_listen (/home/chouquette/dev/libmicrodns/build-asan/.libs/libmicrodns.so.0+0x58e4)
    #8 0x560afb0d13ff in main (/home/chouquette/dev/libmicrodns/build-asan/.libs/test+0x13ff)
    #9 0x7f913d9ff2b0 in __libc_start_main (/lib/x86_64-linux-gnu/libc.so.6+0x202b0)
    #10 0x560afb0d0ea9 in _start (/home/chouquette/dev/libmicrodns/build-asan/.libs/test+0xea9)

Steps to reproduce:

  • Launch the test executable with network connected
  • Disconnect your cable/from your wifi network
  • Wait the specified timeout duration
  • Crash

Requires patches on FreeBSD

I had to apply these patches to build on FreeBSD 12.2:

--- include/microdns/rr.h.orig	2020-10-29 02:44:44 UTC
+++ include/microdns/rr.h
@@ -35,6 +35,8 @@
 # include <ws2tcpip.h>
 #endif
 
+#include <netinet/in.h>
+
 # ifdef __cplusplus
 extern "C" {
 # endif
--- include/utils.h.orig	2020-10-29 02:42:44 UTC
+++ include/utils.h
@@ -31,6 +31,8 @@
 #include <stdio.h>
 #include <stdint.h>
 
+#include <netinet/in.h>
+
 #include "compat.h"
 
 #define MDNS_DN_MAXSZ 256 // domain name maximum size
--- src/rr.c.orig	2020-10-29 02:40:53 UTC
+++ src/rr.c
@@ -32,6 +32,8 @@
 #include <stdlib.h>
 #include <stdint.h>
 
+#include <netinet/in.h>
+
 #include "utils.h"
 #include "microdns/microdns.h"
 #include "microdns/rr.h"

meson build is broken

Build with Debian unstable amd64
As you can see static and shared libraries are missing.

Also the soname returned by 0.1.1 build is broken (missing version number)

$ objdump -p  ./debian/tmp/usr/lib/x86_64-linux-gnu/libmicrodns.so | grep SONAME 
  SONAME               libmicrodns.so

when 0.1.0 is

$ objdump -p  ./debian/tmp/usr/lib/x86_64-linux-gnu/libmicrodns.so.0.0.0 | grep SONAME 
  SONAME               libmicrodns.so.0

In 0.1.0

debian/tmp
└── usr
    ├── include
    │   └── microdns
    │       ├── microdns.h
    │       └── rr.h
    ├── lib
    │   └── x86_64-linux-gnu
    │       ├── libmicrodns.a
    │       ├── libmicrodns.la
    │       ├── libmicrodns.so -> libmicrodns.so.0.0.0
    │       ├── libmicrodns.so.0 -> libmicrodns.so.0.0.0
    │       ├── libmicrodns.so.0.0.0
    │       └── pkgconfig
    │           └── microdns.pc
    └── share
        └── doc
            └── microdns
                └── README.md

with 0.1.1

debian/tmp
└── usr
    ├── include
    │   └── microdns
    │       ├── microdns.h
    │       └── rr.h
    └── lib
        └── x86_64-linux-gnu
            ├── libmicrodns.so
            └── pkgconfig
                └── microdns.pc

Mishandling of detected host toolchain under x86_64-pc-mingw64

When compiling under x86_64-pc-mingw64, the LIBSOCKET variable is not set properly.
As far as I understand autotools (which is not much) it looks like it has to do with the following code snippet from configure.ac (note that the string "mingw32" is not contained anywhere within "x86_64-pc-mingw64":

    case "${host_os}" in
      *mingw32*)
        SYS=mingw32
        ;;
      *cygwin*)
        SYS=cygwin
        ;;
    esac

    if test "${SYS}" = "mingw32"; then
    ...
    fi
    ;;

This was done with default toolchain detection. I sidestepped the issue in the meanwhile by lying to it through passing --host=x86_64-w64-mingw32.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.