Log a dummy "<unknown>" IP address in the unlikely event that genameinfo(3) fails
authorjca <jca@openbsd.org>
Tue, 5 Sep 2023 16:01:58 +0000 (16:01 +0000)
committerjca <jca@openbsd.org>
Tue, 5 Sep 2023 16:01:58 +0000 (16:01 +0000)
clang-16 warning reported by robert@, ok tb@ millert@

libexec/spamd/spamd.c

index 5880023..f2f19b3 100644 (file)
@@ -1,4 +1,4 @@
-/*     $OpenBSD: spamd.c,v 1.160 2023/04/19 12:58:15 jsg Exp $ */
+/*     $OpenBSD: spamd.c,v 1.161 2023/09/05 16:01:58 jca Exp $ */
 
 /*
  * Copyright (c) 2015 Henning Brauer <henning@openbsd.org>
@@ -728,10 +728,8 @@ initcon(struct con *cp, int fd, struct sockaddr *sa)
            0 : stutter;
        error = getnameinfo(sa, sa->sa_len, cp->addr, sizeof(cp->addr), NULL, 0,
            NI_NUMERICHOST);
-#ifdef useless
        if (error)
-               errx(1, "%s", gai_strerror(error));
-#endif
+               strlcpy(cp->addr, "<unknown>", sizeof(cp->addr));
        ctime_r(&t, ctimebuf);
        ctimebuf[sizeof(ctimebuf) - 2] = '\0'; /* nuke newline */
        snprintf(cp->obuf, cp->osize, "220 %s ESMTP %s; %s\r\n",