commit 68b4f733b2755762e43df90f73db5a6ec8d14104
Author:     Laslo Hunhold <[email protected]>
AuthorDate: Mon Feb 22 19:06:36 2021 +0100
Commit:     Laslo Hunhold <[email protected]>
CommitDate: Mon Feb 22 19:06:36 2021 +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 <[email protected]>

diff --git a/sock.c b/sock.c
index 89f1109..ecb73ef 100644
--- 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;

Reply via email to