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

ipaddr_remote segfaults on domain names, not actually tested? #224

Open
wusspuss opened this issue Apr 7, 2023 · 1 comment
Open

ipaddr_remote segfaults on domain names, not actually tested? #224

wusspuss opened this issue Apr 7, 2023 · 1 comment

Comments

@wusspuss
Copy link

wusspuss commented Apr 7, 2023

Adaptation from the tutorial:

#include <libdill.h>
#include <stdio.h>

int main() {
  struct ipaddr addr;
  int rc = ipaddr_remote(&addr, "example.org", 80, 0, -1);
  if (rc != 0) {
    printf("rc=%i,errno=%i\n",rc,errno);
    return 1;
  }
   
  return 0;
}

Sometimes prints rc=-1,errno=99 (not a valid errno), sometimes segfaults straight away. If you swap "example.org" for "127.0.0.1" it works just fine. From grepping tests/ for ipaddr_remote it seems it's only tested for 0.0.0.0 and 127.0.0.1 and not domain names.

@jkylander
Copy link

jkylander commented Jan 8, 2025

Same here when doing the sockets tutorial. Compiled with clang -Wall -Wextra -g -o wget wget.c -ldill
gdb --args ./wget https www.example.org /index.html

20   struct ipaddr addr;
21   int rc = ipaddr_remote(&addr, argv[2], port, 0, -1);
[Thread debugging using libthread_db enabled]
Using host libthread_db library "/lib/x86_64-linux-gnu/libthread_db.so.1".

Program received signal SIGSEGV, Segmentation fault.
0x00007ffff7f866e0 in dill_ipaddr_remotes (addrs=0x7fffffffe4bc, naddrs=1, name=<optimized out>, port=443, mode=<optimized out>,
    deadline=-1) at ipaddr.c:377
377             if(naddrs && mode == DILL_IPADDR_IPV4 && it->ai_family == AF_INET) {
(gdb) bt
#0  0x00007ffff7f866e0 in dill_ipaddr_remotes (addrs=0x7fffffffe4bc, naddrs=1, name=<optimized out>, port=443, mode=<optimized out>,
    deadline=-1) at ipaddr.c:377
#1  0x00007ffff7f8653c in dill_ipaddr_remotes (addrs=0x7fffffffe4bc, naddrs=naddrs@entry=1, name=0x7fffffffe976 "www.example.org",
    port=443, mode=<optimized out>, deadline=-1) at ipaddr.c:296
#2  0x00007ffff7f86a2d in dill_ipaddr_remote (addr=<optimized out>, name=<optimized out>, port=<optimized out>, mode=<optimized out>,
    deadline=<optimized out>) at ipaddr.c:261
#3  0x00005555555552ac in main (argc=4, argv=0x7fffffffe618) at wget.c:21

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