Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

adsuck: can't udp bind: Can't assign requested address #3

Open
higgsd opened this issue Nov 17, 2014 · 1 comment
Open

adsuck: can't udp bind: Can't assign requested address #3

higgsd opened this issue Nov 17, 2014 · 1 comment

Comments

@higgsd
Copy link

higgsd commented Nov 17, 2014

There are a several of problems in udp_bind() that are triggered by using the -l (ell) flag.

  • The 'addr' field only has space for IPv4 addresses but you attempt to call inet_pton(AF_INET6...). This corrupts the stack and coredumps the process on my machine.

  • Even if an INET6 address could be parsed, you are hardcoding AF_INET everywhere else.

  • The sin_len and sin_zero fields of sockaddr_in are not being set. One (or both) of these are now causing bind to consistently return errno 49 (can't assign requested address) in OpenBSD 5.6. This worked in 5.5, though I haven't figured out what changed.

    3804 adsuck CALL socket(PF_INET,0x2<SOCK_DGRAM>,IPPROTO_IP)
    3804 adsuck RET socket 3
    3804 adsuck CALL bind(0x3,0xcfbc8594,0x10)
    3804 adsuck STRU struct sockaddr { AF_INET, 127.0.0.1:53 }
    3804 adsuck RET bind -1 errno 49 Can't assign requested address

@renaudallard
Copy link

Removing the inet6 part solves the issue on OpenBSD 5.6. And as AF_INET is hardcoded, you can't use ipv6 anyway.


--- adsuck.c    Tue Dec 16 15:21:50 2014
+++ /tmp/adsuck.c       Tue Dec 16 15:21:44 2014
@@ -286,9 +286,8 @@
        in_addr_t                       maddr = INADDR_ANY;

        if (my_address)
-               if (inet_pton(AF_INET6, my_address, &maddr) < 1)
-                       if (inet_pton(AF_INET, my_address, &maddr) < 1)
-                               return (EINVAL);
+               if (inet_pton(AF_INET, my_address, &maddr) < 1)
+                       return (EINVAL);

        addr.sin_family = AF_INET;
        addr.sin_port = (in_port_t) htons((uint16_t)port);

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants