summaryrefslogtreecommitdiffstats
path: root/usr.bin/mail/cmd2.c
diff options
context:
space:
mode:
authormikeh <mikeh@FreeBSD.org>2001-03-25 04:57:05 +0000
committermikeh <mikeh@FreeBSD.org>2001-03-25 04:57:05 +0000
commite51e7e067d9cfc20e2881f888c5f45046c153df8 (patch)
treeb1ac3afa472ab794d2a7118bc10ebee16c55812f /usr.bin/mail/cmd2.c
parentafd190c2240ce9ef47e8180f3d48af53f636952f (diff)
downloadFreeBSD-src-e51e7e067d9cfc20e2881f888c5f45046c153df8.zip
FreeBSD-src-e51e7e067d9cfc20e2881f888c5f45046c153df8.tar.gz
Merge various changes from OpenBSD and NetBSD.
o remove panic() in favor of err(3) and use err(3) functions consistently throughout o use stat(2)'s S_IS* macros rather than S_IF* o [r]index -> str[r]chr o convert some static buffers to dynamic ones o use real tempfiles rather than reopening the same templates o rename some functions that clash with libc o convert wait_status from union to int and use wait(2) status macros o fix multiple potential buffer overflows o fix a few comments o add $FreeBSD$ Reviewed by: nra, nectar (earlier version)
Diffstat (limited to 'usr.bin/mail/cmd2.c')
-rw-r--r--usr.bin/mail/cmd2.c22
1 files changed, 13 insertions, 9 deletions
diff --git a/usr.bin/mail/cmd2.c b/usr.bin/mail/cmd2.c
index 3ad78a8..f74a06e 100644
--- a/usr.bin/mail/cmd2.c
+++ b/usr.bin/mail/cmd2.c
@@ -32,7 +32,11 @@
*/
#ifndef lint
+#if 0
static char sccsid[] = "@(#)cmd2.c 8.1 (Berkeley) 6/6/93";
+#endif
+static const char rcsid[] =
+ "$FreeBSD$";
#endif /* not lint */
#include "rcv.h"
@@ -187,14 +191,14 @@ save1(str, mark, cmd, ignore)
else
disp = "[New file]";
if ((obuf = Fopen(file, "a")) == NULL) {
- perror(NOSTR);
+ warn(NOSTR);
return(1);
}
for (ip = msgvec; *ip && ip-msgvec < msgCount; ip++) {
mp = &message[*ip - 1];
touch(mp);
- if (send(mp, obuf, ignore, NOSTR) < 0) {
- perror(file);
+ if (sendmessage(mp, obuf, ignore, NOSTR) < 0) {
+ warnx("%s", file);
Fclose(obuf);
return(1);
}
@@ -203,7 +207,7 @@ save1(str, mark, cmd, ignore)
}
fflush(obuf);
if (ferror(obuf))
- perror(file);
+ warn("%s", file);
Fclose(obuf);
printf("%s\n", disp);
return(0);
@@ -367,11 +371,11 @@ int
core()
{
int pid;
- extern union wait wait_status;
+ extern int wait_status;
switch (pid = fork()) {
case -1:
- perror("fork");
+ warn("fork");
return(1);
case 0:
abort();
@@ -380,7 +384,7 @@ core()
printf("Okie dokie");
fflush(stdout);
wait_child(pid);
- if (wait_status.w_coredump)
+ if (WIFSIGNALED(wait_status) && WCOREDUMP(wait_status))
printf(" -- Core dumped.\n");
else
printf(" -- Can't dump core.\n");
@@ -467,7 +471,7 @@ ignore1(list, tab, which)
struct ignoretab *tab;
char *which;
{
- char field[BUFSIZ];
+ char field[LINESIZE];
register int h;
register struct ignore *igp;
char **ap;
@@ -475,7 +479,7 @@ ignore1(list, tab, which)
if (*list == NOSTR)
return igshow(tab, which);
for (ap = list; *ap != 0; ap++) {
- istrcpy(field, *ap);
+ istrncpy(field, *ap, sizeof(field));
if (member(field, tab))
continue;
h = hash(field);
OpenPOWER on IntegriCloud