mirror of
https://gitlab.torproject.org/tpo/core/torsocks.git
synced 2026-01-11 08:04:07 +08:00
When running as non-root, we fail to create the socket in the first place. This happened to cause the test to pass, since it resulted in errno being set to `EBADF` when we tried to `connect` on it. We now check whether creation of the socket succeeded, and if not we skip this particular test. When running as root (as in CI), the test would *sometimes* still pass, because we were passing an uninitialized `sockaddr_sin`. If it didn't happen to have one of the allowed address families then we would still get `EBADF` as the test expected. If it just happened to have one of the allowed families though, then we get `EPERM`. We now initialize `sin` so that we're not depending on uninitialized data, and particularly set the family to `AF_INET` to ensure we're exercising the code path that rejects unsupported socket types, not the earlier check that rejects unsupported address families. With that fixed, the expected errno is `EPERM` instead of `EBADF`.