quark

quark web server
git clone git://git.suckless.org/quark
Log | Files | Refs | LICENSE

commit 68b4f733b2755762e43df90f73db5a6ec8d14104
parent 7814309e9a2c386f646892403e53f2a87b929b0c
Author: Laslo Hunhold <dev@frign.de>
Date:   Mon, 22 Feb 2021 19:06:36 +0100

Improve connection logging

Given connection_log() can be called on "incomplete" connections since
the last changes regarding properly logging dropped connections, the
function sock_get_inaddr_str() had the broken assumption that when
ss_family was neither AF_INET nor AF_INET6 it would be AF_UNIX, leading
to the wrong logging of just-accepted-and-dropped connections as "uds",
even when listening on an IP socket.

As a solution, the switch is amended and yields the expected
in-address-string "-" when the given sockaddr-struct is not filled yet.

Signed-off-by: Laslo Hunhold <dev@frign.de>

Diffstat:
Msock.c | 5++++-
1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/sock.c b/sock.c @@ -176,8 +176,11 @@ sock_get_inaddr_str(const struct sockaddr_storage *in_sa, char *str, return 1; } break; - default: + case AF_UNIX: snprintf(str, len, "uds"); + break; + default: + snprintf(str, len, "-"); } return 0;