From: Joshua Rogers Date: Wed, 10 Sep 2025 00:57:09 +0000 (+0000) Subject: Fix UDP log module opening and closing code (#2214) X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=b551ac4f3ab7d7bb86e8856688bd78c9f5415592;p=thirdparty%2Fsquid.git Fix UDP log module opening and closing code (#2214) logfile_mod_udp_open() mistreated successful comm_connect_addr() result as an "Unable to connect" failure (and vice versa), rendering UDP-based logging unusable. Broken since at least 2010 commit d938215. Also fixed logfile_mod_udp_close() closing FD 0 after "Invalid UDP logging address" ERRORs during logfile_mod_udp_open(). --- diff --git a/src/log/ModUdp.cc b/src/log/ModUdp.cc index d4ad05611a..8d279cc606 100644 --- a/src/log/ModUdp.cc +++ b/src/log/ModUdp.cc @@ -145,6 +145,7 @@ logfile_mod_udp_open(Logfile * lf, const char *path, size_t bufsz, int fatal_fla lf->f_rotate = logfile_mod_udp_rotate; l_udp_t *ll = static_cast(xcalloc(1, sizeof(*ll))); + ll->fd = -1; lf->data = ll; if (strncmp(path, "//", 2) == 0) { @@ -178,7 +179,7 @@ logfile_mod_udp_open(Logfile * lf, const char *path, size_t bufsz, int fatal_fla debugs(50, DBG_IMPORTANT, "ERROR: Unable to open UDP socket for logging"); return FALSE; } - } else if (!comm_connect_addr(ll->fd, addr)) { + } else if (comm_connect_addr(ll->fd, addr) == Comm::COMM_ERROR) { xerrno = errno; if (lf->flags.fatal) { fatalf("Unable to connect to %s for UDP log: %s\n", lf->path, xstrerr(xerrno));