nmh-workers
[Top] [All Lists]

Re: [Nmh-workers] 128 byte field name limit in NAMESZ breaks scan(1)

2008-10-22 15:09:25
Peter Maydell <pmaydell(_at_)chiark(_dot_)greenend(_dot_)org(_dot_)uk> wrote:

"Jeffrey C Honig" wrote:
If I read RFC0822 correctly field-name does not have a length limit,
it's one or more characters.  Given that, using a fixed value of NAMESZ
in m_getfld() is an invalid assumption.

2822 says that lines MUST be no longer than 998 characters, and gives
no way to break a field-name across multiple lines. So as far as I can
tell you shouldn't ever get a field-name longer than 998 chars.
(The field-body may be wrapped, but that's not important right now.)

Then we should change it to 999.  That will probably address the
problem that brought this up.  Although it is possible that length could
be exceeded with a long mailbox from line.  But, how likely would that be?
 
The proper fix would involve a dynamically allocated buffer and an
examination of all uses of m_getfld() to update it.

A quick look shows that most of the calls to m_getfld() define name char
name[NAMSZ] and pass it to m_getfld().  If they don't assume a length, a
quick change to m_getfld() to return a pointer to a buffer and
reallocate it as necessary should only take a hour or two.

Urgh. All the body-text uses of m_getfld() work on the model of 'pass it
a buffer and get the next chunk of text; call it again to get the next
bit'. It'd be difficult to make the change you propose without affecting
that. 

I've looked at all the uses of name m_getfld and am 95% confident that this
will not cause a problem.
 
I'm very leery about changes to m_getfld(), especially since we
don't currently have any test cases for all the different things it has
to do (including interaction with stdio buffer endings and so on).
I personally would rather avoid major changes to it until we have some
decent tests to detect accidental breakage. I certainly don't think
this particular reliance on a hard-coded buffer size (of which nmh has
many) justifies fiddling with m_getfld() without a safety net^W^Wtest
suite.

Yes, m_getfld() is very scary.  Although I think this is a relatively
simple change to allocate a buffer the first time in and realloc if it
needs to grow.  Enclosed is a quick patch for review.  Although I think
we would be safe with just the first change.

Thanks (谢谢).

Jeff

-- 
Jeffrey C. Honig <jch(_at_)honig(_dot_)net>
http://www.honig.net/jch
GnuPG ID:14E29E13 <http://www.honig.net/jch/key.shtml>

? diff
Index: h/mh.h
===================================================================
RCS file: /sources/nmh/nmh/h/mh.h,v
retrieving revision 1.9
diff -u -u -r1.9 mh.h
--- h/mh.h      2 Jun 2008 22:37:01 -0000       1.9
+++ h/mh.h      22 Oct 2008 19:03:22 -0000
@@ -223,7 +223,9 @@
  * m_getfld() message parsing
  */
 
-#define NAMESZ  128            /* Limit on component name size     */
+#define NAMESZ  999            /* Limit on component name size     */
+                               /* RFC-2822 specifies 998, add one for
+                                * nil */
 
 #define LENERR  (-2)           /* Name too long error from getfld  */
 #define FMTERR  (-3)           /* Message Format error             */
Index: h/prototypes.h
===================================================================
RCS file: /sources/nmh/nmh/h/prototypes.h,v
retrieving revision 1.25
diff -u -u -r1.25 prototypes.h
--- h/prototypes.h      14 Aug 2008 01:50:45 -0000      1.25
+++ h/prototypes.h      22 Oct 2008 19:03:22 -0000
@@ -72,7 +72,7 @@
 int m_convert (struct msgs *, char *);
 char *m_draft (char *, char *, int, int *);
 void m_eomsbr (int (*)(int));
-int m_getfld (int, unsigned char *, unsigned char *, int, FILE *);
+int m_getfld (int, char **, unsigned char *, int, FILE *);
 int m_gmprot (void);
 char *m_maildir (char *);
 char *m_mailpath (char *);
Index: sbr/m_getfld.c
===================================================================
RCS file: /sources/nmh/nmh/sbr/m_getfld.c,v
retrieving revision 1.15
diff -u -u -r1.15 m_getfld.c
--- sbr/m_getfld.c      13 Aug 2008 18:27:37 -0000      1.15
+++ sbr/m_getfld.c      22 Oct 2008 19:03:23 -0000
@@ -183,6 +183,9 @@
 static unsigned char *edelim;
 static int edelimlen;
 
+static unsigned char *namebuf;
+static size_t namebufsiz;
+
 static int (*eom_action)(int) = NULL;
 
 #ifdef _FSTDIO
@@ -206,7 +209,7 @@
 
 
 int
-m_getfld (int state, unsigned char *name, unsigned char *buf,
+m_getfld (int state, char **name, unsigned char *buf,
           int bufsz, FILE *iob)
 {
     register unsigned char  *bp, *cp, *ep, *sp;
@@ -215,6 +218,7 @@
     if ((c = Getc(iob)) < 0) {
        msg_count = 0;
        *buf = 0;
+       *name = NULL;
        return FILEEOF;
     }
     if (eom (c, iob)) {
@@ -227,9 +231,15 @@
        }
        msg_count = 0;
        *buf = 0;
+       *name = NULL;
        return FILEEOF;
     }
 
+    if (namebuf == NULL) {
+       namebufsiz = NAMESZ;
+        namebuf = mh_xmalloc(namebufsiz);
+    }
+
     switch (state) {
        case FLDEOF: 
        case BODYEOF: 
@@ -249,6 +259,7 @@
                    }
                    msg_count = 0;
                    *buf = 0;
+                   *name = NULL;
                    return FILEEOF;
                }
                state = BODY;
@@ -256,11 +267,11 @@
            }
            /*
             * get the name of this component.  take characters up
-            * to a ':', a newline or NAMESZ-1 characters, whichever
+            * to a ':', a newline or namebufsiz-1 characters, whichever
             * comes first.  
             */
-           cp = name;
-           i = NAMESZ - 1;
+           cp = namebuf;
+           i = namebufsiz - 1;
            for (;;) {
 #ifdef LINUX_STDIO
                bp = sp = (unsigned char *) iob->_IO_read_ptr - 1;
@@ -287,7 +298,8 @@
                    if (_filbuf(iob) == EOF) {
 #endif
                        *cp = *buf = 0;
-                       advise (NULL, "eof encountered in field \"%s\"", name);
+                       advise (NULL, "eof encountered in field \"%s\"", *name);
+                       *name = NULL;
                        return FMTERR;
                    }
 #ifdef LINUX_STDIO
@@ -322,7 +334,8 @@
                     * handles it this way). */
 
                    /* See if buf can hold this line, since we were assuming
-                    * we had a buffer of NAMESZ, not bufsz. */
+                    * we had a buffer of namebufsiz, not bufsz.
+                    * Reallocate if necessary. */
                    /* + 1 for the newline */
                    if (bufsz < j + 1) {
                        /* No, it can't.  Oh well, guess we'll blow up. */
@@ -342,13 +355,17 @@
                     * get extra newlines, but that should be harmless enough,
                     * right?  This is a corrupt message anyway. */
                    fseek (iob, ftell (iob) - 2, SEEK_SET);
+                   *name = namebuf;
                    return BODY;
                }
                if ((i -= j) <= 0) {
-                   *cp = *buf = 0;
-                   advise (NULL, "field name \"%s\" exceeds %d bytes", name, 
NAMESZ - 1);
-                   state = LENERR;
-                   goto finish;
+                   size_t len;
+
+                   len = cp - namebuf;
+                   i +- namebufsiz;
+                   namebufsiz *= 2;
+                    namebuf = mh_xrealloc(namebuf, namebufsiz);
+                   cp = namebuf + len;
                }
            }
 
@@ -556,6 +573,7 @@
 #endif
            if (bufsz < 0) {
                msg_count = c;
+               *name = namebuf;
                return (state);
            }
            cp = buf + c;
@@ -567,6 +585,7 @@
 finish:
     *cp = 0;
     msg_count = cp - buf;
+    *name = namebuf;
     return (state);
 }
 
Index: sbr/readconfig.c
===================================================================
RCS file: /sources/nmh/nmh/sbr/readconfig.c,v
retrieving revision 1.3
diff -u -u -r1.3 readconfig.c
--- sbr/readconfig.c    2 Jan 2006 03:17:42 -0000       1.3
+++ sbr/readconfig.c    22 Oct 2008 19:03:23 -0000
@@ -52,7 +52,7 @@
 {
     register int state;
     register char *cp;
-    char name[NAMESZ], field[BUFSIZ];
+    char *name, field[BUFSIZ];
     register struct node *np;
     register struct procstr *ps;
 
@@ -62,7 +62,7 @@
     }
 
     for (state = FLD;;) {
-       switch (state = m_getfld (state, name, field, sizeof(field), ib)) {
+       switch (state = m_getfld (state, &name, field, sizeof(field), ib)) {
            case FLD:
            case FLDPLUS:
            case FLDEOF:
@@ -73,7 +73,7 @@
                if (state == FLDPLUS) {
                    cp = getcpy (field);
                    while (state == FLDPLUS) {
-                       state = m_getfld (state, name, field, sizeof(field), 
ib);
+                       state = m_getfld (state, &name, field, sizeof(field), 
ib);
                        cp = add (field, cp);
                    }
                    np->n_field = trimcpy (cp);
Index: sbr/seq_read.c
===================================================================
RCS file: /sources/nmh/nmh/sbr/seq_read.c,v
retrieving revision 1.5
diff -u -u -r1.5 seq_read.c
--- sbr/seq_read.c      6 Jan 2006 21:51:44 -0000       1.5
+++ sbr/seq_read.c      22 Oct 2008 19:03:23 -0000
@@ -59,7 +59,7 @@
 {
     int state;
     char *cp, seqfile[PATH_MAX];
-    char name[NAMESZ], field[BUFSIZ];
+    char *name, field[BUFSIZ];
     FILE *fp;
 
     /*
@@ -79,14 +79,14 @@
 
     /* Use m_getfld to scan sequence file */
     for (state = FLD;;) {
-       switch (state = m_getfld (state, name, field, sizeof(field), fp)) {
+       switch (state = m_getfld (state, &name, field, sizeof(field), fp)) {
            case FLD: 
            case FLDPLUS:
            case FLDEOF: 
                if (state == FLDPLUS) {
                    cp = getcpy (field);
                    while (state == FLDPLUS) {
-                       state = m_getfld (state, name, field, sizeof(field), 
fp);
+                       state = m_getfld (state, &name, field, sizeof(field), 
fp);
                        cp = add (field, cp);
                    }
                    seq_init (mp, getcpy (name), trimcpy (cp));
Index: uip/distsbr.c
===================================================================
RCS file: /sources/nmh/nmh/uip/distsbr.c,v
retrieving revision 1.4
diff -u -u -r1.4 distsbr.c
--- uip/distsbr.c       13 Apr 2007 11:53:08 -0000      1.4
+++ uip/distsbr.c       22 Oct 2008 19:03:23 -0000
@@ -32,7 +32,7 @@
     int state;
     register unsigned char *dp;
     register char *resent;
-    char name[NAMESZ], buffer[BUFSIZ];
+    char **name, buffer[BUFSIZ];
     register FILE *ifp, *ofp;
 
     if (rename (drft, strcpy (backup, m_backup (drft))) == NOTOK)
@@ -50,7 +50,7 @@
 
     for (state = FLD, resent = NULL;;)
        switch (state =
-               m_getfld (state, name, buffer, sizeof buffer, ifp)) {
+               m_getfld (state, &name, buffer, sizeof buffer, ifp)) {
            case FLD: 
            case FLDPLUS: 
            case FLDEOF: 
@@ -67,7 +67,7 @@
                resent = add (buffer, resent);
                fprintf (ofp, "%s: %s", name, buffer);
                while (state == FLDPLUS) {
-                   state = m_getfld (state, name,
+                   state = m_getfld (state, &name,
                            buffer, sizeof buffer, ifp);
                    resent = add (buffer, resent);
                    fputs (buffer, ofp);
@@ -130,7 +130,7 @@
 ready_msg (char *msgnam)
 {
     int state, out;
-    char name[NAMESZ], buffer[BUFSIZ], tmpfil[BUFSIZ];
+    char *name, buffer[BUFSIZ], tmpfil[BUFSIZ];
     register FILE *ifp, *ofp;
 
     if (hdrfd != NOTOK)
@@ -151,7 +151,7 @@
 
     for (state = FLD;;)
        switch (state =
-               m_getfld (state, name, buffer, sizeof buffer, ifp)) {
+               m_getfld (state, &name, buffer, sizeof buffer, ifp)) {
            case FLD: 
            case FLDPLUS: 
            case FLDEOF: 
@@ -159,7 +159,7 @@
                    fprintf (ofp, "Prev-");
                fprintf (ofp, "%s: %s", name, buffer);
                while (state == FLDPLUS) {
-                   state = m_getfld (state, name,
+                   state = m_getfld (state, &name,
                            buffer, sizeof buffer, ifp);
                    fputs (buffer, ofp);
                }
@@ -180,7 +180,7 @@
                unlink (tmpfil);
                fprintf (ofp, "\n%s", buffer);
                while (state == BODY) {
-                   state = m_getfld (state, name,
+                   state = m_getfld (state, &name,
                            buffer, sizeof buffer, ifp);
                    fputs (buffer, ofp);
                }
Index: uip/inc.c
===================================================================
RCS file: /sources/nmh/nmh/uip/inc.c,v
retrieving revision 1.27
diff -u -u -r1.27 inc.c
--- uip/inc.c   2 Jun 2008 22:37:01 -0000       1.27
+++ uip/inc.c   22 Oct 2008 19:03:23 -0000
@@ -968,10 +968,10 @@
 cpymsg (FILE *in, FILE *out)
 {
     int state;
-    char *tmpbuf, name[NAMESZ];
+    char *tmpbuf, *name;
 
     for (;;) {
-       state = m_getfld (state, name, tmpbuf, rlwidth, in);
+       state = m_getfld (state, &name, tmpbuf, rlwidth, in);
        switch (state) {
        case FLD:
        case FLDPLUS:
Index: uip/mhbuildsbr.c
===================================================================
RCS file: /sources/nmh/nmh/uip/mhbuildsbr.c,v
retrieving revision 1.19
diff -u -u -r1.19 mhbuildsbr.c
--- uip/mhbuildsbr.c    14 Aug 2008 00:56:39 -0000      1.19
+++ uip/mhbuildsbr.c    22 Oct 2008 19:03:23 -0000
@@ -116,7 +116,7 @@
 build_mime (char *infile)
 {
     int        compnum, state;
-    char buf[BUFSIZ], name[NAMESZ];
+    char buf[BUFSIZ], **name;
     char *cp, *np, *vp;
     struct multipart *m;
     struct part **pp;
Index: uip/mhcachesbr.c
===================================================================
RCS file: /sources/nmh/nmh/uip/mhcachesbr.c,v
retrieving revision 1.8
diff -u -u -r1.8 mhcachesbr.c
--- uip/mhcachesbr.c    6 Jan 2006 21:51:44 -0000       1.8
+++ uip/mhcachesbr.c    22 Oct 2008 19:03:23 -0000
@@ -403,7 +403,7 @@
 find_cache_aux2 (char *mapfile, char *id, char *mapname, int namelen)
 {
     int        state;
-    char buf[BUFSIZ], name[NAMESZ];
+    char buf[BUFSIZ], *name;
     FILE *fp;
 
     if (!(fp = lkfopen (mapfile, "r")))
Index: uip/mhlsbr.c
===================================================================
RCS file: /sources/nmh/nmh/uip/mhlsbr.c,v
retrieving revision 1.12
diff -u -u -r1.12 mhlsbr.c
--- uip/mhlsbr.c        13 Apr 2007 11:53:08 -0000      1.12
+++ uip/mhlsbr.c        22 Oct 2008 19:03:23 -0000
@@ -839,7 +839,7 @@
 {
     int state;
     struct mcomp *c1, *c2, *c3;
-    char **ip, name[NAMESZ], buf[BUFSIZ];
+    char **ip, *name, buf[BUFSIZ];
 
     if (forwall) {
        if (digest)
@@ -900,13 +900,13 @@
     }
 
     for (state = FLD;;) {
-       switch (state = m_getfld (state, name, buf, sizeof(buf), fp)) {
+       switch (state = m_getfld (state, &name, buf, sizeof(buf), fp)) {
            case FLD: 
            case FLDPLUS: 
                for (ip = ignores; *ip; ip++)
                    if (!mh_strcasecmp (name, *ip)) {
                        while (state == FLDPLUS)
-                           state = m_getfld (state, name, buf, sizeof(buf), 
fp);
+                           state = m_getfld (state, &name, buf, sizeof(buf), 
fp);
                        break;
                    }
                if (*ip)
@@ -926,7 +926,7 @@
                if (c1 == NULL)
                    c1 = add_queue (&msghd, &msgtl, name, buf, 0);
                while (state == FLDPLUS) {
-                   state = m_getfld (state, name, buf, sizeof(buf), fp);
+                   state = m_getfld (state, &name, buf, sizeof(buf), fp);
                    c1->c_text = add (buf, c1->c_text);
                }
                if (c2 == NULL)
@@ -960,7 +960,7 @@
                        strncpy (holder.c_text, buf, sizeof(buf));
                        while (state == BODY) {
                            putcomp (c1, &holder, BODYCOMP);
-                           state = m_getfld (state, name, holder.c_text,
+                           state = m_getfld (state, &name, holder.c_text,
                                        sizeof(buf), fp);
                        }
                        free (holder.c_text);
Index: uip/mhparse.c
===================================================================
RCS file: /sources/nmh/nmh/uip/mhparse.c,v
retrieving revision 1.21
diff -u -u -r1.21 mhparse.c
--- uip/mhparse.c       14 Aug 2008 06:19:08 -0000      1.21
+++ uip/mhparse.c       22 Oct 2008 19:03:23 -0000
@@ -273,7 +273,7 @@
 get_content (FILE *in, char *file, int toplevel)
 {
     int compnum, state;
-    char buf[BUFSIZ], name[NAMESZ];
+    char buf[BUFSIZ], *name;
     char *np, *vp;
     CT ct;
     HF hp;
Index: uip/msh.c
===================================================================
RCS file: /sources/nmh/nmh/uip/msh.c,v
retrieving revision 1.14
diff -u -u -r1.14 msh.c
--- uip/msh.c   14 Aug 2008 01:50:46 -0000      1.14
+++ uip/msh.c   22 Oct 2008 19:03:23 -0000
@@ -1202,7 +1202,7 @@
 readid (int msgnum)
 {
     int i, state;
-    char *bp, buf[BUFSIZ], name[NAMESZ];
+    char *bp, buf[BUFSIZ], *name;
     register FILE *zp;
 #ifdef BPOP
     int        arg1, arg2, arg3;
Index: uip/mshcmds.c
===================================================================
RCS file: /sources/nmh/nmh/uip/mshcmds.c,v
retrieving revision 1.16
diff -u -u -r1.16 mshcmds.c
--- uip/mshcmds.c       13 Apr 2007 11:53:08 -0000      1.16
+++ uip/mshcmds.c       22 Oct 2008 19:03:24 -0000
@@ -2549,7 +2549,7 @@
     int        result, state;
     unsigned char *bp, *dp;
     char *cp;
-    char buf[BUFSIZ], name[NAMESZ];
+    char buf[BUFSIZ], *name;
     FILE *fp;
 
     if (Msgs[msgnum].m_flags & MHNCHK)
@@ -2559,7 +2559,7 @@
     fp = msh_ready (msgnum, 1);
 
     for (state = FLD;;)
-       switch (state = m_getfld (state, name, buf, sizeof buf, fp)) {
+       switch (state = m_getfld (state, &name, buf, sizeof buf, fp)) {
        case FLD:
        case FLDPLUS:
        case FLDEOF:
@@ -2572,7 +2572,7 @@
 
                cp = add (buf, NULL);
                while (state == FLDPLUS) {
-                   state = m_getfld (state, name, buf, sizeof buf, fp);
+                   state = m_getfld (state, &name, buf, sizeof buf, fp);
                    cp = add (buf, cp);
                }
                bp = cp;
@@ -2675,7 +2675,7 @@
            if (!mh_strcasecmp (name, ENCODING_FIELD)) {
                cp = add (buf, NULL);
                while (state == FLDPLUS) {
-                   state = m_getfld (state, name, buf, sizeof buf, fp);
+                   state = m_getfld (state, &name, buf, sizeof buf, fp);
                    cp = add (buf, cp);
                }
                for (bp = cp; isspace (*bp); bp++)
@@ -2700,7 +2700,7 @@
             * field and go to next one.
             */
            while (state == FLDPLUS)
-               state = m_getfld (state, name, buf, sizeof(buf), fp);
+               state = m_getfld (state, &name, buf, sizeof(buf), fp);
            break;
 
            /*
@@ -2859,20 +2859,20 @@
 get_fields (char *datesw, char *subjsw, int msgnum, struct Msg *msgp)
 {
     int        state, gotdate = 0;
-    char *bp, buf[BUFSIZ], name[NAMESZ];
+    char *bp, buf[BUFSIZ], *name;
     struct tws *tw = (struct tws *) 0;
     register FILE *zp;
 
     zp = msh_ready (msgnum, 0);
     for (state = FLD;;) {
-       switch (state = m_getfld (state, name, buf, sizeof buf, zp)) {
+       switch (state = m_getfld (state, &name, buf, sizeof buf, zp)) {
            case FLD: 
            case FLDEOF: 
            case FLDPLUS: 
                if (!mh_strcasecmp (name, datesw)) {
                    bp = getcpy (buf);
                    while (state == FLDPLUS) {
-                       state = m_getfld (state, name, buf, sizeof buf, zp);
+                       state = m_getfld (state, &name, buf, sizeof buf, zp);
                        bp = add (buf, bp);
                    }
                    if ((tw = dparsetime (bp)) == NULL)
@@ -2889,7 +2889,7 @@
                else if (subjsw && !mh_strcasecmp(name, subjsw)) {
                    bp = getcpy (buf);
                    while (state == FLDPLUS) {
-                       state = m_getfld (state, name, buf, sizeof buf, zp);
+                       state = m_getfld (state, &name, buf, sizeof buf, zp);
                        bp = add (buf, bp);
                    }
                    msgp->m_scanl = sosmash(subjsw, bp);
@@ -2899,7 +2899,7 @@
                        subjsw = (char *)0;/* subject done, need date */
                } else {
                    while (state == FLDPLUS)    /* flush this one */
-                       state = m_getfld (state, name, buf, sizeof buf, zp);
+                       state = m_getfld (state, &name, buf, sizeof buf, zp);
                }
                continue;
 
Index: uip/picksbr.c
===================================================================
RCS file: /sources/nmh/nmh/uip/picksbr.c,v
retrieving revision 1.12
diff -u -u -r1.12 picksbr.c
--- uip/picksbr.c       29 Apr 2007 22:57:36 -0000      1.12
+++ uip/picksbr.c       22 Oct 2008 19:03:24 -0000
@@ -938,7 +938,7 @@
 {
     int state;
     register char *bp;
-    char buf[BUFSIZ], name[NAMESZ];
+    char buf[BUFSIZ], *name;
     register struct tws *tw;
 
     fseek (fp, start, SEEK_SET);
Index: uip/post.c
===================================================================
RCS file: /sources/nmh/nmh/uip/post.c,v
retrieving revision 1.22
diff -u -u -r1.22 post.c
--- uip/post.c  4 Nov 2007 11:54:35 -0000       1.22
+++ uip/post.c  22 Oct 2008 19:03:24 -0000
@@ -315,7 +315,7 @@
 {
     int state, compnum, dashstuff = 0;
     char *cp, *msg = NULL, **argp, **arguments;
-    char buf[BUFSIZ], name[NAMESZ];
+    char buf[BUFSIZ], *name;
     FILE *in, *out;
 
 #ifdef LOCALE
Index: uip/prompter.c
===================================================================
RCS file: /sources/nmh/nmh/uip/prompter.c,v
retrieving revision 1.6
diff -u -u -r1.6 prompter.c
--- uip/prompter.c      4 Nov 2007 11:54:35 -0000       1.6
+++ uip/prompter.c      22 Oct 2008 19:03:24 -0000
@@ -104,7 +104,7 @@
     int body = 1, prepend = 1, rapid = 0;
     int doteof = 0, fdi, fdo, i, state;
     char *cp, *drft = NULL, *erasep = NULL;
-    char *killp = NULL, name[NAMESZ], field[BUFSIZ];
+    char *killp = NULL, *name, field[BUFSIZ];
     char buffer[BUFSIZ], tmpfil[BUFSIZ];
     char **arguments, **argp;
     FILE *in, *out;
Index: uip/rcvdist.c
===================================================================
RCS file: /sources/nmh/nmh/uip/rcvdist.c,v
retrieving revision 1.13
diff -u -u -r1.13 rcvdist.c
--- uip/rcvdist.c       2 Jun 2008 22:37:02 -0000       1.13
+++ uip/rcvdist.c       22 Oct 2008 19:03:24 -0000
@@ -165,7 +165,7 @@
 {
     register int char_read = 0, format_len, i, state;
     register char *tmpbuf, **nxtbuf, **ap;
-    char *cp, *scanl, name[NAMESZ];
+    char *cp, *scanl, *name;
     register struct comp *cptr, **savecomp;
     FILE *out;
 
@@ -199,7 +199,7 @@
        cptr->c_text = addrs;
 
     for (state = FLD;;) {
-       switch (state = m_getfld (state, name, tmpbuf, SBUFSIZ, inb)) {
+       switch (state = m_getfld (state, &name, tmpbuf, SBUFSIZ, inb)) {
            case FLD: 
            case FLDPLUS: 
                if ((cptr = wantcomp[CHASH (name)]))
@@ -224,7 +224,7 @@
                                cptr->c_text = add (tmpbuf, cp);
                            }
                            while (state == FLDPLUS) {
-                               state = m_getfld (state, name, tmpbuf,
+                               state = m_getfld (state, &name, tmpbuf,
                                                  SBUFSIZ, inb);
                                cptr->c_text = add (tmpbuf, cptr->c_text);
                                char_read += msg_count;
@@ -234,7 +234,7 @@
                    } while ((cptr = cptr->c_next));
 
                while (state == FLDPLUS)
-                   state = m_getfld (state, name, tmpbuf, SBUFSIZ, inb);
+                   state = m_getfld (state, &name, tmpbuf, SBUFSIZ, inb);
                break;
 
            case LENERR: 
Index: uip/replsbr.c
===================================================================
RCS file: /sources/nmh/nmh/uip/replsbr.c,v
retrieving revision 1.11
diff -u -u -r1.11 replsbr.c
--- uip/replsbr.c       13 Apr 2007 11:53:08 -0000      1.11
+++ uip/replsbr.c       22 Oct 2008 19:03:24 -0000
@@ -79,7 +79,7 @@
     register char **ap;
     register struct comp **savecomp;
     int        char_read = 0, format_len, mask;
-    char name[NAMESZ], *scanl;
+    char *name, *scanl;
     unsigned char *cp;
     FILE *out;
 
@@ -148,7 +148,7 @@
      * pick any interesting stuff out of msg "inb"
      */
     for (state = FLD;;) {
-       state = m_getfld (state, name, tmpbuf, SBUFSIZ, inb);
+       state = m_getfld (state, &name, tmpbuf, SBUFSIZ, inb);
        switch (state) {
            case FLD: 
            case FLDPLUS: 
@@ -181,7 +181,7 @@
                                cptr->c_text = add (tmpbuf, cp);
                            }
                            while (state == FLDPLUS) {
-                               state = m_getfld (state, name, tmpbuf,
+                               state = m_getfld (state, &name, tmpbuf,
                                                  SBUFSIZ, inb);
                                cptr->c_text = add (tmpbuf, cptr->c_text);
                                char_read += msg_count;
@@ -191,7 +191,7 @@
                    } while ((cptr = cptr->c_next));
 
                while (state == FLDPLUS)
-                   state = m_getfld (state, name, tmpbuf, SBUFSIZ, inb);
+                   state = m_getfld (state, &name, tmpbuf, SBUFSIZ, inb);
                break;
 
            case LENERR: 
Index: uip/scansbr.c
===================================================================
RCS file: /sources/nmh/nmh/uip/scansbr.c,v
retrieving revision 1.13
diff -u -u -r1.13 scansbr.c
--- uip/scansbr.c       8 Aug 2008 23:45:24 -0000       1.13
+++ uip/scansbr.c       22 Oct 2008 19:03:24 -0000
@@ -86,7 +86,7 @@
     struct comp **savecomp;
     char *scnmsg;
     FILE *scnout;
-    char name[NAMESZ];
+    char *name;
     static int rlwidth, slwidth;
 
 #ifdef RPATHS
@@ -156,7 +156,7 @@
      * Get the first field.  If the message is non-empty
      * and we're doing an "inc", open the output file.
      */
-    if ((state = m_getfld (FLD, name, tmpbuf, rlwidth, inb)) == FILEEOF) {
+    if ((state = m_getfld (FLD, &name, tmpbuf, rlwidth, inb)) == FILEEOF) {
        if (ferror(inb)) {
            advise("read", "unable to"); /* "read error" */
            return SCNFAT;
@@ -191,7 +191,7 @@
     }
 
     /* scan - main loop */
-    for (compnum = 1; ; state = m_getfld (state, name, tmpbuf, rlwidth, inb)) {
+    for (compnum = 1; ; state = m_getfld (state, &name, tmpbuf, rlwidth, inb)) 
{
        switch (state) {
            case FLD: 
            case FLDPLUS: 
@@ -227,7 +227,7 @@
                }
 
                while (state == FLDPLUS) {
-                   state = m_getfld (state, name, tmpbuf, rlwidth, inb);
+                   state = m_getfld (state, &name, tmpbuf, rlwidth, inb);
                    if (outnum)
                        FPUTS (tmpbuf);
                }
@@ -265,11 +265,11 @@
                            DIEWRERR ();
                    }
 #ifdef LINUX_STDIO
-                   state = m_getfld(state, name, scnout->_IO_write_ptr,
+                   state = m_getfld(state, &name, scnout->_IO_write_ptr,
                        (long)scnout->_IO_write_ptr-(long)scnout->_IO_write_end 
, inb);
                    scnout->_IO_write_ptr += msg_count;
 #elif defined(__DragonFly__)
-                   state = m_getfld( state, name, ((struct __FILE_public 
*)scnout)->_p, -(((struct __FILE_public *)scnout)->_w), inb );
+                   state = m_getfld( state, &name, ((struct __FILE_public 
*)scnout)->_p, -(((struct __FILE_public *)scnout)->_w), inb );
                    ((struct __FILE_public *)scnout)->_w -= msg_count;
                    ((struct __FILE_public *)scnout)->_p += msg_count;
 #else
Index: uip/sendsbr.c
===================================================================
RCS file: /sources/nmh/nmh/uip/sendsbr.c,v
retrieving revision 1.18
diff -u -u -r1.18 sendsbr.c
--- uip/sendsbr.c       2 Jun 2008 22:37:02 -0000       1.18
+++ uip/sendsbr.c       22 Oct 2008 19:03:24 -0000
@@ -547,7 +547,7 @@
     time_t clock;
     char *cp, *dp, buffer[BUFSIZ], msgid[BUFSIZ];
     char subject[BUFSIZ];
-    char name[NAMESZ], partnum[BUFSIZ];
+    char *name, partnum[BUFSIZ];
     FILE *in;
 
     if ((in = fopen (drft, "r")) == NULL)
Index: uip/show.c
===================================================================
RCS file: /sources/nmh/nmh/uip/show.c,v
retrieving revision 1.10
diff -u -u -r1.10 show.c
--- uip/show.c  13 Apr 2007 11:53:08 -0000      1.10
+++ uip/show.c  22 Oct 2008 19:03:24 -0000
@@ -387,14 +387,14 @@
     int        result, state;
     unsigned char *bp, *dp;
     char *cp;
-    char buf[BUFSIZ], name[NAMESZ];
+    char buf[BUFSIZ], *name;
     FILE *fp;
 
     if ((fp = fopen (msgnam, "r")) == NULL)
        return 0;
 
     for (state = FLD;;) {
-       switch (state = m_getfld (state, name, buf, sizeof(buf), fp)) {
+       switch (state = m_getfld (state, &name, buf, sizeof(buf), fp)) {
        case FLD:
        case FLDPLUS:
        case FLDEOF:
@@ -407,7 +407,7 @@
 
                cp = add (buf, NULL);
                while (state == FLDPLUS) {
-                   state = m_getfld (state, name, buf, sizeof(buf), fp);
+                   state = m_getfld (state, &name, buf, sizeof(buf), fp);
                    cp = add (buf, cp);
                }
                bp = cp;
@@ -510,7 +510,7 @@
            if (!mh_strcasecmp (name, ENCODING_FIELD)) {
                cp = add (buf, NULL);
                while (state == FLDPLUS) {
-                   state = m_getfld (state, name, buf, sizeof(buf), fp);
+                   state = m_getfld (state, &name, buf, sizeof(buf), fp);
                    cp = add (buf, cp);
                }
                for (bp = cp; isspace (*bp); bp++)
@@ -535,7 +535,7 @@
             * field and go to next one.
             */
            while (state == FLDPLUS)
-               state = m_getfld (state, name, buf, sizeof(buf), fp);
+               state = m_getfld (state, &name, buf, sizeof(buf), fp);
            break;
 
            /*
Index: uip/slocal.c
===================================================================
RCS file: /sources/nmh/nmh/uip/slocal.c,v
retrieving revision 1.27
diff -u -u -r1.27 slocal.c
--- uip/slocal.c        11 Apr 2008 14:12:55 -0000      1.27
+++ uip/slocal.c        22 Oct 2008 19:03:24 -0000
@@ -743,7 +743,7 @@
     int i, state;
     int fd1;
     char *cp, *dp, *lp;
-    char name[NAMESZ], field[BUFSIZ];
+    char *name, field[BUFSIZ];
     struct pair *p, *q;
     FILE  *in;
 
@@ -1518,7 +1518,7 @@
 suppress_duplicates (int fd, char *file)
 {
     int        fd1, lockfd, state, result;
-    char *cp, buf[BUFSIZ], name[NAMESZ];
+    char *cp, buf[BUFSIZ], *name;
     datum key, value;
     DBM *db;
     FILE *in;
Index: uip/sortm.c
===================================================================
RCS file: /sources/nmh/nmh/uip/sortm.c,v
retrieving revision 1.15
diff -u -u -r1.15 sortm.c
--- uip/sortm.c 4 Nov 2007 11:54:36 -0000       1.15
+++ uip/sortm.c 22 Oct 2008 19:03:24 -0000
@@ -328,7 +328,7 @@
 {
     register int state;
     int compnum;
-    char *msgnam, buf[BUFSIZ], nam[NAMESZ];
+    char *msgnam, buf[BUFSIZ], *nam;
     register struct tws *tw;
     register char *datecomp = NULL, *subjcomp = NULL;
     register FILE *in;
@@ -418,7 +418,7 @@
            if (strcmp (subjsort, "subject") == 0) {
                while ((c = *cp)) {
                    if (! isspace(c)) {
-                       if(uprf(cp, "re:"))
+                       if(uprf(cp, "re:") || uprf(cp, "fw:"))
                            cp += 2;
                        else
                            break;
Index: uip/spost.c
===================================================================
RCS file: /sources/nmh/nmh/uip/spost.c,v
retrieving revision 1.19
diff -u -u -r1.19 spost.c
--- uip/spost.c 13 Apr 2007 11:53:08 -0000      1.19
+++ uip/spost.c 22 Oct 2008 19:03:24 -0000
@@ -206,7 +206,7 @@
 {
     int state, i, pid, compnum;
     char *cp, *msg = NULL, **argp, **arguments;
-    char *sargv[16], buf[BUFSIZ], name[NAMESZ];
+    char *sargv[16], buf[BUFSIZ], *name;
     FILE *in;
 
 #ifdef LOCALE
Index: uip/whatnowsbr.c
===================================================================
RCS file: /sources/nmh/nmh/uip/whatnowsbr.c,v
retrieving revision 1.11
diff -u -u -r1.11 whatnowsbr.c
--- uip/whatnowsbr.c    3 Aug 2008 18:47:56 -0000       1.11
+++ uip/whatnowsbr.c    22 Oct 2008 19:03:24 -0000
@@ -930,7 +930,7 @@
 check_draft (char *msgnam)
 {
     int        state;
-    char buf[BUFSIZ], name[NAMESZ];
+    char buf[BUFSIZ], *name;
     FILE *fp;
 
     if ((fp = fopen (msgnam, "r")) == NULL)
_______________________________________________
Nmh-workers mailing list
Nmh-workers(_at_)nongnu(_dot_)org
http://lists.nongnu.org/mailman/listinfo/nmh-workers
<Prev in Thread] Current Thread [Next in Thread>