X-Git-Url: https://git.subgeniuskitty.com/unix-history/.git/blobdiff_plain/9552e6b89c5ab0982221c7edca0008d2dc13db32..0c5f72fb504e8431228d1e650246d87870d236bb:/usr/src/usr.bin/mail/list.c diff --git a/usr/src/usr.bin/mail/list.c b/usr/src/usr.bin/mail/list.c index c3b7ab28a8..b5c998acb1 100644 --- a/usr/src/usr.bin/mail/list.c +++ b/usr/src/usr.bin/mail/list.c @@ -1,12 +1,18 @@ /* * Copyright (c) 1980 Regents of the University of California. - * All rights reserved. The Berkeley software License Agreement - * specifies the terms and conditions for redistribution. + * All rights reserved. + * + * Redistribution and use in source and binary forms are permitted + * provided that this notice is preserved and that due credit is given + * to the University of California at Berkeley. The name of the University + * may not be used to endorse or promote products derived from this + * software without specific prior written permission. This software + * is provided ``as is'' without express or implied warranty. */ -#ifndef lint -static char sccsid[] = "@(#)list.c 5.1 (Berkeley) %G%"; -#endif not lint +#ifdef notdef +static char sccsid[] = "@(#)list.c 5.6 (Berkeley) %G%"; +#endif /* notdef */ #include "rcv.h" #include @@ -134,22 +140,28 @@ number: printf("Non-numeric second argument\n"); return(-1); } - if (valdot < msgCount) - mark(valdot+1); - else { - printf("Referencing beyond EOF\n"); - return(-1); - } + i = valdot; + do { + i++; + if (i > msgCount) { + printf("Referencing beyond EOF\n"); + return(-1); + } + } while ((message[i - 1].m_flag & MDELETED) != f); + mark(i); break; case TDASH: if (beg == 0) { - if (valdot > 1) - mark(valdot-1); - else { - printf("Referencing before 1\n"); - return(-1); - } + i = valdot; + do { + i--; + if (i <= 0) { + printf("Referencing before 1\n"); + return(-1); + } + } while ((message[i - 1].m_flag & MDELETED) != f); + mark(i); } break; @@ -214,7 +226,7 @@ number: if ((np > namelist || colmod != 0) && mc == 0) for (i = 1; i <= msgCount; i++) - if ((message[i-1].m_flag & (MSAVED|MDELETED)) == f) + if ((message[i-1].m_flag & MDELETED) == f) mark(i); /* @@ -336,15 +348,18 @@ check(mesg, f) * for a RAWLIST. */ -getrawlist(line, argv) +getrawlist(line, argv, argc) char line[]; char **argv; + int argc; { register char **ap, *cp, *cp2; char linebuf[BUFSIZ], quotec; + register char **last; ap = argv; cp = line; + last = argv + argc - 1; while (*cp != '\0') { while (any(*cp, " \t")) cp++; @@ -364,6 +379,10 @@ getrawlist(line, argv) *cp2 = '\0'; if (cp2 == linebuf) break; + if (ap >= last) { + printf("Too many elements in the list; excess discarded\n"); + break; + } *ap++ = savestr(linebuf); } *ap = NOSTR; @@ -401,7 +420,7 @@ scan(sp) int quotec; if (regretp >= 0) { - copy(stringstack[regretp], lexstring); + strcpy(lexstring, stringstack[regretp]); lexnumber = numberstack[regretp]; return(regretstack[regretp--]); } @@ -545,11 +564,20 @@ sender(str, mesg) char *str; { register struct message *mp; - register char *cp; + register char *cp, *cp2, *backup; mp = &message[mesg-1]; - cp = nameof(mp, 0); - return(icequal(cp, str)); + backup = cp2 = nameof(mp, 0); + cp = str; + while (*cp2) { + if (*cp == 0) + return(1); + if (raise(*cp++) != raise(*cp2++)) { + cp2 = ++backup; + cp = str; + } + } + return(*cp == 0); } /*