OSSP CVS Repository

ossp - Difference in ossp-pkg/lmtp2nntp/lmtp2nntp.c versions 1.33 and 1.34
Not logged in
[Honeypot]  [Browse]  [Home]  [Login]  [Reports
[Search]  [Ticket]  [Timeline
  [History

ossp-pkg/lmtp2nntp/lmtp2nntp.c 1.33 -> 1.34

--- lmtp2nntp.c  2001/08/28 14:27:35     1.33
+++ lmtp2nntp.c  2001/08/29 14:58:21     1.34
@@ -52,7 +52,6 @@
 #define ERR_EXECUTION -1
 #define ERR_DELIVERY -2
 
-#define MESSAGE_MAXLEN 8*1024*1024
 #define STDSTRLEN 128
 #define MAXNEWSSERVICES 3
 
@@ -94,6 +93,7 @@
     int             option_deliverymode;
     char           *option_deliverymodefakestatus;
     char           *option_deliverymodefakedsn;
+    int             option_maxmessagesize;
     int             nsc;
     struct ns       ns[MAXNEWSSERVICES];
     char           *azGroupargs;
@@ -130,8 +130,8 @@
      */
     fprintf(stderr, 
             "USAGE: %s "
-            "lmtp2nntp [-d deliverymode] [-g groupmode] [-h host[:port]] "
-            "[-t tracefile] [-v] [-V] newsgroup [newsgroup ...]"
+            "[-d deliverymode] [-g groupmode] [-h host[:port]] "
+            "[-m maxmessagesize] [-t tracefile] [-v] [-V] newsgroup [newsgroup ...]"
             "\n",
             command);
     return;
@@ -163,6 +163,7 @@
     ctx->option_deliverymode = DELIVERYMODE_FAKE;
     ctx->option_deliverymodefakestatus = "553";   /* Requested action not taken: mailbox name not allowed */
     ctx->option_deliverymodefakedsn    = "5.7.1"; /* Delivery not authorized, message refused */
+    ctx->option_maxmessagesize = 8 * 1024 * 1024;
     ctx->nsc = 0;
     for (i=0; i < MAXNEWSSERVICES; i++) {
         ctx->ns[i].h = NULL;
@@ -199,12 +200,12 @@
     /*POD B<lmtp2nntp> */
 
     /*  use
-     *  perl <lmtp2nntp.c -e 'while (<>) { if(m/\/\*POD (.*) .*\*\//) { $_=$1; s/.<(.*?)>/$1/g ; print "$_\n" };}'
+     *  perl <lmtp2nntp.c -e 'while (<>) { if(m/\/\*POD (.*) .*\*\//) { $_=$1; print "$_\n" };}'
      *  to pull the POD SYNOPSIS header directly out of this source
      */
 
     /* read in the arguments */
-    while ((i = getopt(argc, argv, "d:g:h:t:vV")) != -1) {
+    while ((i = getopt(argc, argv, "d:g:h:m:t:vV")) != -1) {
         switch (i) {
             case 'd': /*POD [B<-d> I<deliverymode>] */
                 if      (strcasecmp(optarg, "post") == 0)
@@ -304,6 +305,13 @@
                 }
                 free(azHosts);
                 break;
+            case 'm': /*POD [B<-m> I<maxmessagesize>] */
+                    ctx->option_maxmessagesize = atoi(optarg);
+                    if(ctx->option_maxmessagesize < 64) {
+                        fprintf(stderr, "%s:Error: maximum message size is unacceptable small.\n", progname);
+                        exit(ERR_EXECUTION);
+                    }
+                break;
             case 't': /*POD [B<-t> I<tracefile>] */
                 ctx->option_tracing = TRUE;
                 trace_read (-1, optarg, 0);
@@ -873,16 +881,17 @@
     res.statusmsg  = "Enter mail, end with \".\" on a line by itself";
     lmtp_response(lmtp, &res);
 
-    rc = lmtp_readmsg(lmtp, &ctx->msg->cpMsg, MESSAGE_MAXLEN);
+    rc = lmtp_readmsg(lmtp, &ctx->msg->cpMsg, ctx->option_maxmessagesize);
 
     /*  RFC0821 4.2.1. REPLY CODES BY FUNCTION GROUPS   552 Requested mail action aborted: exceeded storage allocation
      *  RFC1893 2. Status Codes                         5.X.X   Permanent Failure
-     *  RFC1893 3.5 Network and Routing Status          X.3.4   Message too big for system
+     *  RFC1893 3.5 Network and Routing Status          X.2.3   Message length exceeds administrative limit.
+
      */
     if (rc == LMTP_ERR_OVERFLOW) {
-        str_format(errorstring, sizeof(errorstring), "Overflow reading message: %s", lmtp_error(rc));
+        str_format(errorstring, sizeof(errorstring), "Message length exceeds administrative limit. %s", lmtp_error(rc));
         res.statuscode = "552";
-        res.dsncode    = "5.3.4";
+        res.dsncode    = "5.2.3";
         res.statusmsg  = errorstring;
         rcpt = NULL;
         while ((rcpt = argz_next(ctx->msg->azRcpt, ctx->msg->asRcpt, rcpt)) != NULL) {

CVSTrac 2.0.1