summaryrefslogtreecommitdiff
path: root/src/qmail-qmtpd.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/qmail-qmtpd.c')
-rw-r--r--src/qmail-qmtpd.c26
1 files changed, 14 insertions, 12 deletions
diff --git a/src/qmail-qmtpd.c b/src/qmail-qmtpd.c
index 6478e21..b4a1c17 100644
--- a/src/qmail-qmtpd.c
+++ b/src/qmail-qmtpd.c
@@ -16,22 +16,25 @@
#include "received.h"
#include "ip.h"
#include "byte.h"
+#include "timeout.h"
+#include "error.h"
#define PORT_QMTPS "6209" // string compare
-#define QMTP_SIZE 200000000 // 190 MB transfer limit
+#define QMTP_SIZE 200000000 // 23 MB transfer limit
#define QMTP_TIMEOUT 3600 // 1 hour
/** @file qmail-qmtpd.c -- QMTP/QMTPS server
@brief requires sslserver */
+int timeout = QMTP_TIMEOUT;
void badproto() { _exit(100); }
void resources() { _exit(111); }
ssize_t safewrite(int fd,char *buf,int len)
{
int r;
- r = write(fd,buf,len);
- if (r <= 0) _exit(0);
+ r = timeoutwrite(timeout,fd,buf,len);
+ if (r <= 0) _exit(1);
return r;
}
@@ -42,8 +45,9 @@ ssize_t saferead(int fd,char *buf,int len)
{
int r;
buffer_flush(&bo);
- r = read(fd,buf,len);
- if (r <= 0) _exit(0);
+ r = timeoutread(timeout,fd,buf,len);
+ if (r == -1) if (errno == ETIMEDOUT) { buffer_flush(&bo); _exit(1); }
+ if (r <= 0) _exit(1);
return r;
}
@@ -75,8 +79,7 @@ unsigned int bytestooverflow = 0;
struct qmail qq;
char buf[BUFSIZE_LINE]; // sender/recipient buffer
-char bufd[2 * BUFSIZE_MESS]; // temporary data buffer
-char buf2[BUFFER_SMALL]; // QMTP message buffer
+char buf2[BUFFER_SMALL];
char *remotehost;
char *remoteinfo;
@@ -149,7 +152,6 @@ int main()
char ch;
int i;
unsigned long biglen;
- unsigned long dlen;
unsigned long len;
int flagdos;
int flagsenderok;
@@ -243,11 +245,11 @@ int main()
qmail_fail(&qq);
}
while (len > 0) { /* XXX: DJB: could speed this up, obviously; FEH: done */
- dlen = (len < BUFSIZE_LINE) ? len : BUFSIZE_LINE;
- buffer_get(&bi,bufd,dlen);
- qmail_put(&qq,bufd,dlen);
- len -= dlen;
+ buffer_get(&bi,&ch,1);
+ --len;
+ qmail_put(&qq,&ch,1);
}
+
}
getcomma();