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

Segmentation fault while resolving local hostname #28

Open
tomsawyer-zz opened this issue Oct 9, 2012 · 4 comments
Open

Segmentation fault while resolving local hostname #28

tomsawyer-zz opened this issue Oct 9, 2012 · 4 comments

Comments

@tomsawyer-zz
Copy link

Hi, I'm getting segfault while connecting to any server by domain:

tom@hotmeal:~/workspace/proxychains_haad$ ./proxychains4 telnet google.com 80
[proxychains] config file found: /home/tom/workspace/proxychains_haad/proxychains.conf
[proxychains] preloading ./libproxychains4.so
DEBUG:init_lib_wrapper called from gcc_init
DEBUG:added localnet: netaddr=127.0.0.0, netmask=255.0.0.0
[proxychains] DLL init
DEBUG:loaded symbol 'connect' real addr 0x7fee8271ebd0  wrapped addr 0x7fee8342088a
DEBUG:loaded symbol 'gethostbyname' real addr 0x7fee82736bf0  wrapped addr 0x7fee83420c97
DEBUG:loaded symbol 'getaddrinfo' real addr 0x7fee826f89b0  wrapped addr 0x7fee83420dc9
DEBUG:loaded symbol 'freeaddrinfo' real addr 0x7fee826f9430  wrapped addr 0x7fee83420e7e
DEBUG:loaded symbol 'gethostbyaddr' real addr 0x7fee82736660  wrapped addr 0x7fee8342107f
DEBUG:loaded symbol 'getnameinfo' real addr 0x7fee8273ca90  wrapped addr 0x7fee83420efd
DEBUG:gethostbyname: tomhouse
Segmentation fault (core dumped)

While exploring the code I found that 'proxy_gethostbyname' returns a partially zeroed structure when trying to resolve local hostname, so it causes segfault in telnet (I think so).

@tomsawyer-zz
Copy link
Author

managed to fix it by inserting

    data->hostent_space.h_name = strdup(name); //it's a memory leak I think
    data->hostent_space.h_length = sizeof (in_addr_t);
    data->hostent_space.h_addrtype = AF_INET;

after

    if(data->resolved_addr == (in_addr_t) (-1))
        data->resolved_addr = (in_addr_t) (local_host.as_int);

in core.c

Besides, it's needed to add

    data->hostent_space.h_addrtype = AF_INET;

in 'have_ip' section or programs that directly uses gethostbyname() (such as perl) won't work. E.g.

proxychains4 GET cmyip.com

fails with

    LWP::Protocol::http::Socket: Bad hostname 'google.com' at /usr/share/perl5/LWP/Protocol/http.pm line 51.

@haad
Copy link
Owner

haad commented Oct 10, 2012

Can you submit this as pull-up request it's easier to merge and review that way.

@haad
Copy link
Owner

haad commented Oct 10, 2012

Also I would like to merge your changes, if you would like to see them in your parent repo.

crass pushed a commit to crass/proxychains-remove that referenced this issue Sep 1, 2018
Chromium tried to close our pipes and falls into infinity loop.
Copy link

github-actions bot commented Jan 5, 2025

Stale issue message

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

No branches or pull requests

2 participants