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

Crash when only specifying a port for SOCKS #6

Open
DanielO opened this issue Jul 6, 2018 · 0 comments
Open

Crash when only specifying a port for SOCKS #6

DanielO opened this issue Jul 6, 2018 · 0 comments

Comments

@DanielO
Copy link

DanielO commented Jul 6, 2018

Running tunsocks -D 8080 crashes with...

2018-07-06 15:13:19.690392+0930 tunsocks[84093:18868044] detected buffer overflow
...
(lldb) bt
* thread #1, queue = 'com.apple.main-thread', stop reason = signal SIGABRT
  * frame #0: 0x00007fff53c44b6e libsystem_kernel.dylib`__pthread_kill + 10
    frame #1: 0x00007fff53e0f080 libsystem_pthread.dylib`pthread_kill + 333
    frame #2: 0x00007fff53ba01ae libsystem_c.dylib`abort + 127
    frame #3: 0x00007fff53ba0321 libsystem_c.dylib`abort_report_np + 177
    frame #4: 0x00007fff53bc4bf5 libsystem_c.dylib`__chk_fail + 48
    frame #5: 0x00007fff53bc4bc5 libsystem_c.dylib`__chk_fail_overflow + 16
    frame #6: 0x00007fff53bc5110 libsystem_c.dylib`__memcpy_chk + 37
    frame #7: 0x000000010000fc61 tunsocks`socks_listen(base=0x0000000100402290, host=<unavailable>, port=<unavailable>, keep_alive=<unavailable>) at socks.c:399 [opt]
    frame #8: 0x00000001000119c2 tunsocks`main(argc=3, argv=0x00007ffeefbff898) at main.c:280 [opt]
    frame #9: 0x00007fff53af4015 libdyld.dylib`start + 1
    frame #10: 0x00007fff53af4015 libdyld.dylib`start + 1

This fixes it (by pretending IPv6 doesn't exist)

diff --git a/src/socks.c b/src/socks.c
index 30d1803..420fab0 100644
--- a/src/socks.c
+++ b/src/socks.c
@@ -386,7 +387,7 @@ socks_listen(struct event_base *base, const char *host, const char *port,
        s->keep_alive = keep_alive;

        memset(&hints, 0, sizeof(hints));
-       hints.ai_family = AF_UNSPEC;
+       hints.ai_family = AF_INET;
        hints.ai_socktype = SOCK_STREAM;

        ret = getaddrinfo(host, port, &hints, &result);
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

1 participant