diff options
| author | manuel <manuel@mausz.at> | 2013-02-04 02:53:06 +0100 |
|---|---|---|
| committer | manuel <manuel@mausz.at> | 2013-02-04 02:53:06 +0100 |
| commit | a0de1c2316ccd0f2146440f422cd79065ec98109 (patch) | |
| tree | cb0fe925d2a85300534821adedc1c1b23c29a32f | |
| parent | ff4ae02e49de534d453d226475f239b128f63c6a (diff) | |
| download | qmail-a0de1c2316ccd0f2146440f422cd79065ec98109.tar.gz qmail-a0de1c2316ccd0f2146440f422cd79065ec98109.tar.bz2 qmail-a0de1c2316ccd0f2146440f422cd79065ec98109.zip | |
[PATCH] Trim large bouncing messages down
qmail-limit-bounce-size
| -rw-r--r-- | qmail-send.c | 13 |
1 files changed, 12 insertions, 1 deletions
diff --git a/qmail-send.c b/qmail-send.c index ef8fe30..4bec118 100644 --- a/qmail-send.c +++ b/qmail-send.c | |||
| @@ -44,6 +44,8 @@ | |||
| 44 | 44 | ||
| 45 | int lifetime = 604800; | 45 | int lifetime = 604800; |
| 46 | 46 | ||
| 47 | int bouncemaxbytes = 50000; | ||
| 48 | |||
| 47 | stralloc percenthack = {0}; | 49 | stralloc percenthack = {0}; |
| 48 | struct constmap mappercenthack; | 50 | struct constmap mappercenthack; |
| 49 | stralloc locals = {0}; | 51 | stralloc locals = {0}; |
| @@ -742,9 +744,17 @@ I tried to deliver a bounce message to this address, but the bounce bounced!\n\ | |||
| 742 | qmail_fail(&qqt); | 744 | qmail_fail(&qqt); |
| 743 | else | 745 | else |
| 744 | { | 746 | { |
| 747 | int bytestogo = bouncemaxbytes; | ||
| 748 | int bytestoget = (bytestogo < sizeof buf) ? bytestogo : sizeof buf; | ||
| 745 | substdio_fdbuf(&ssread,read,fd,inbuf,sizeof(inbuf)); | 749 | substdio_fdbuf(&ssread,read,fd,inbuf,sizeof(inbuf)); |
| 746 | while ((r = substdio_get(&ssread,buf,sizeof(buf))) > 0) | 750 | while (bytestoget > 0 && (r = substdio_get(&ssread,buf,bytestoget)) > 0) { |
| 747 | qmail_put(&qqt,buf,r); | 751 | qmail_put(&qqt,buf,r); |
| 752 | bytestogo -= bytestoget; | ||
| 753 | bytestoget = (bytestogo < sizeof buf) ? bytestogo : sizeof buf; | ||
| 754 | } | ||
| 755 | if (r > 0) { | ||
| 756 | qmail_puts(&qqt,"\n\n--- End of message stripped.\n"); | ||
| 757 | } | ||
| 748 | close(fd); | 758 | close(fd); |
| 749 | if (r == -1) | 759 | if (r == -1) |
| 750 | qmail_fail(&qqt); | 760 | qmail_fail(&qqt); |
| @@ -1439,6 +1449,7 @@ fd_set *rfds; | |||
| 1439 | /* this file is too long ---------------------------------------------- MAIN */ | 1449 | /* this file is too long ---------------------------------------------- MAIN */ |
| 1440 | 1450 | ||
| 1441 | int getcontrols() { if (control_init() == -1) return 0; | 1451 | int getcontrols() { if (control_init() == -1) return 0; |
| 1452 | if (control_readint(&bouncemaxbytes,"control/bouncemaxbytes") == -1) return 0; | ||
| 1442 | if (control_readint(&lifetime,"control/queuelifetime") == -1) return 0; | 1453 | if (control_readint(&lifetime,"control/queuelifetime") == -1) return 0; |
| 1443 | if (control_readint(&concurrency[0],"control/concurrencylocal") == -1) return 0; | 1454 | if (control_readint(&concurrency[0],"control/concurrencylocal") == -1) return 0; |
| 1444 | if (control_readint(&concurrency[1],"control/concurrencyremote") == -1) return 0; | 1455 | if (control_readint(&concurrency[1],"control/concurrencyremote") == -1) return 0; |
