diff -uNr mailx-8.1.1/extern.h mailx-fixed/extern.h --- mailx-8.1.1/extern.h Sun Jun 4 22:16:51 2000 +++ mailx-fixed/extern.h Sun Jun 4 22:20:09 2000 @@ -80,7 +80,7 @@ char *username __P((void)); char *value __P((char [])); char *vcopy __P((char [])); -char *yankword __P((char *, char [])); +char *yankword __P((char *, char [], int)); int Fclose __P((FILE *)); int More __P((void *)); int Pclose __P((FILE *)); diff -uNr mailx-8.1.1/names.c mailx-fixed/names.c --- mailx-8.1.1/names.c Sun Jun 4 22:16:51 2000 +++ mailx-fixed/names.c Sun Jun 4 22:23:12 2000 @@ -108,7 +108,7 @@ top = NIL; np = NIL; cp = line; - while ((cp = yankword(cp, nbuf)) != NOSTR) { + while ((cp = yankword(cp, nbuf, BUFSIZ)) != NOSTR) { t = nalloc(nbuf, ntype); if (top == NIL) top = t; @@ -171,10 +171,12 @@ * Throw away things between ()'s, and take anything between <>. */ char * -yankword(ap, wbuf) +yankword(ap, wbuf, maxsize) char *ap, wbuf[]; + int maxsize; { register char *cp, *cp2; + int used = 0; cp = ap; for (;;) { @@ -201,10 +203,11 @@ break; } if (*cp == '<') - for (cp2 = wbuf; *cp && (*cp2++ = *cp++) != '>';) + /* Pre-increment "used" so we leave room for the trailing zero */ + for (cp2 = wbuf; *cp && (++used < maxsize) && (*cp2++ = *cp++) != '>';) ; else - for (cp2 = wbuf; *cp && !index(" \t,(", *cp); *cp2++ = *cp++) + for (cp2 = wbuf; *cp && (++used < maxsize) && !index(" \t,(", *cp); *cp2++ = *cp++) ; *cp2 = '\0'; return cp;