diff options
| author | Laurent Bercot <ska-skaware@skarnet.org> | 2026-02-13 03:56:13 +0000 |
|---|---|---|
| committer | Laurent Bercot <ska-skaware@skarnet.org> | 2026-02-13 03:56:13 +0000 |
| commit | 83a388d5d8230dd6c15ecea31cf89f74248bc286 (patch) | |
| tree | 0193a4c41614a481b373385aad6864d043f3c22d | |
| parent | f38c40f9bb3033dce22b4035df87695440660e69 (diff) | |
| download | smtpd-starttls-proxy-83a388d5d8230dd6c15ecea31cf89f74248bc286.tar.gz | |
Treat 0 timeouts as infinite
| -rw-r--r-- | src/qmail-remote/dns.c | 2 | ||||
| -rw-r--r-- | src/qmail-remote/qmail-remote-io.c | 6 | ||||
| -rw-r--r-- | src/qmail-remote/qmail-remote.c | 10 | ||||
| -rw-r--r-- | src/qmail-remote/qmailr.h | 2 | ||||
| -rw-r--r-- | src/qmail-remote/qmailr_smtp.c | 4 |
5 files changed, 13 insertions, 11 deletions
diff --git a/src/qmail-remote/dns.c b/src/qmail-remote/dns.c index 367cb72..61fd483 100644 --- a/src/qmail-remote/dns.c +++ b/src/qmail-remote/dns.c @@ -123,7 +123,7 @@ unsigned int dns_stuff (char const *host, char const *const *eaddr, unsigned int tain deadline ; cnameinfo cnames[n] ; - tain_addsec_g(&deadline, timeoutdns) ; + qdeadline(&deadline, timeoutdns) ; if (!skadns_startf_g(&a, &deadline)) qmailr_tempusys("start asynchronous DNS helper") ; diff --git a/src/qmail-remote/qmail-remote-io.c b/src/qmail-remote/qmail-remote-io.c index a855c20..b7e9f8c 100644 --- a/src/qmail-remote/qmail-remote-io.c +++ b/src/qmail-remote/qmail-remote-io.c @@ -133,7 +133,7 @@ static inline void smtp_body (buffer *in, buffer *out, char const *fmtip, char c put(out, "MAIL FROM:<") ; put(out, sender) ; put(out, ">\r\n") ; - tain_addsec_g(&deadline, timeout) ; + qdeadline(&deadline, timeout) ; if (!buffer_timed_flush_g(out, &deadline)) qmailr_tempsys("qmail-remote-io: ", "unable to ", "send command to ", fmtip) ; code = read_answer(in, timeout, buf, 4096, fmtip) ; @@ -153,7 +153,7 @@ static inline void smtp_body (buffer *in, buffer *out, char const *fmtip, char c put(out, "RCPT TO:<") ; put(out, recip[i]) ; put(out, ">\r\n") ; - tain_addsec_g(&deadline, timeout) ; + qdeadline(&deadline, timeout) ; if (!buffer_timed_flush_g(out, &deadline)) qmailr_tempsys("qmail-remote-io: ", "unable to ", "send command to ", fmtip) ; code = read_answer(in, timeout, buf, 4096, fmtip) ; @@ -180,7 +180,7 @@ static inline void smtp_body (buffer *in, buffer *out, char const *fmtip, char c } put(out, "DATA\r\n") ; - tain_addsec_g(&deadline, timeout) ; + qdeadline(&deadline, timeout) ; if (!buffer_timed_flush_g(out, &deadline)) qmailr_tempsys("qmail-remote-io: ", "unable to ", "send command to ", fmtip) ; code = read_answer(in, timeout, buf, 4096, fmtip) ; diff --git a/src/qmail-remote/qmail-remote.c b/src/qmail-remote/qmail-remote.c index a644352..8d3f095 100644 --- a/src/qmail-remote/qmail-remote.c +++ b/src/qmail-remote/qmail-remote.c @@ -69,11 +69,11 @@ static int smtp_start (buffer *in, buffer *out, char const *helohost, unsigned i buffer_putsnoflush(out, helohost) ; buffer_putnoflush(out, "\r\n", 2) ; - tain_addsec_g(&deadline, timeout) ; + qdeadline(&deadline, timeout) ; if (!buffer_timed_flush_g(out, &deadline)) qmailr_tempusys("send ", "EHLO", " to ", fmtip) ; - tain_addsec_g(&deadline, timeout) ; + qdeadline(&deadline, timeout) ; for (;;) { unsigned int code = 250 ; @@ -107,7 +107,7 @@ static void attempt_smtp (int fd, char const *ip, int is6, unsigned int timeoutc tain deadline ; char line[1024] ; buffer_putsnoflush(&out, "STARTTLS\r\n") ; - tain_addsec_g(&deadline, timeoutremote) ; + qdeadline(&deadline, timeoutremote) ; if (!buffer_timed_flush_g(&out, &deadline)) qmailr_tempusys("send ", "STARTTLS", " to ", fmtip) ; r = qmailr_smtp_read_answer(&in, line, 1024, timeoutremote) ; if (r == -1) qmailr_tempusys("read from ", fmtip) ; @@ -211,7 +211,7 @@ int main (int argc, char const *const *argv) if (qmailr_tcpto_match(ip, 1)) continue ; fd = socket_tcp6() ; if (fd == -1) qmailr_tempusys("create socket") ; - tain_addsec_g(&deadline, timeoutconnect) ; + qdeadline(&deadline, timeoutconnect) ; if (!socket_deadlineconnstamp6_g(fd, ip, port, &deadline)) { if (!qmailr_tcpto_update(ip, 1, errno == ETIMEDOUT)) @@ -233,7 +233,7 @@ int main (int argc, char const *const *argv) if (qmailr_tcpto_match(ip, 0)) continue ; fd = socket_tcp4() ; if (fd == -1) qmailr_tempusys("create socket") ; - tain_addsec_g(&deadline, timeoutconnect) ; + qdeadline(&deadline, timeoutconnect) ; if (!socket_deadlineconnstamp4_g(fd, ip, port, &deadline)) { if (!qmailr_tcpto_update(ip, 0, errno == ETIMEDOUT)) diff --git a/src/qmail-remote/qmailr.h b/src/qmail-remote/qmailr.h index 451824a..61bd08e 100644 --- a/src/qmail-remote/qmailr.h +++ b/src/qmail-remote/qmailr.h @@ -35,6 +35,8 @@ extern void qmailr_dievsys (char const *const *, unsigned int) gccattr_noreturn /* qmailr_utils */ +#define qdeadline(d, t) do { if (t) tain_addsec_g(d, t) ; else tain_add_g(d, &tain_infinite_relative) ; } while (0) + extern int qmailr_memcmp4 (void const *, void const *) ; extern int qmailr_memcmp16 (void const *, void const *) ; extern int qmailr_box_encode (char const *, size_t, stralloc *) ; diff --git a/src/qmail-remote/qmailr_smtp.c b/src/qmail-remote/qmailr_smtp.c index 5a778f4..a0faf78 100644 --- a/src/qmail-remote/qmailr_smtp.c +++ b/src/qmail-remote/qmailr_smtp.c @@ -31,7 +31,7 @@ int qmailr_smtp_read_answer (buffer *in, char *line, size_t max, unsigned int ti { unsigned int code = 1000 ; tain deadline ; - tain_addsec_g(&deadline, timeout) ; + qdeadline(&deadline, timeout) ; for (;;) { unsigned int c ; @@ -48,6 +48,6 @@ void qmailr_smtp_quit (buffer *out, unsigned int timeout) { tain deadline ; buffer_puts(out, "QUIT\r\n") ; - tain_addsec_g(&deadline, timeout) ; + qdeadline(&deadline, timeout) ; buffer_timed_flush_g(out, &deadline) ; } |
