provides retry on short-write file descriptors.
ok florian, previous versions seen by millert
-/* $OpenBSD: pax.c,v 1.50 2017/03/11 12:55:47 tb Exp $ */
+/* $OpenBSD: pax.c,v 1.51 2017/12/08 17:04:14 deraadt Exp $ */
/* $NetBSD: pax.c,v 1.5 1996/03/26 23:54:20 mrg Exp $ */
/*-
void
sig_cleanup(int which_sig)
{
- char errbuf[80];
-
/*
* restore modes and times for any dirs we may have created
* or any dirs we may have read.
/* paxwarn() uses stdio; fake it as well as we can */
if (which_sig == SIGXCPU)
- strlcpy(errbuf, "\nCPU time limit reached, cleaning up.\n",
- sizeof errbuf);
+ dprintf(STDERR_FILENO, "\nCPU time limit reached, cleaning up.\n");
else
- strlcpy(errbuf, "\nSignal caught, cleaning up.\n",
- sizeof errbuf);
- (void) write(STDERR_FILENO, errbuf, strlen(errbuf));
+ dprintf(STDERR_FILENO, "\nSignal caught, cleaning up.\n");
ar_close(1);
sltab_process(1);
-/* $OpenBSD: tape.c,v 1.43 2015/08/20 22:02:20 deraadt Exp $ */
+/* $OpenBSD: tape.c,v 1.44 2017/12/08 17:04:15 deraadt Exp $ */
/* $NetBSD: tape.c,v 1.11 1997/06/05 11:13:26 lukem Exp $ */
/*-
statussig(int signo)
{
time_t tnow, deltat;
- char msgbuf[128];
int save_errno = errno;
if (blockswritten < 500)
(void) time(&tnow);
deltat = tstart_writing - tnow + (1.0 * (tnow - tstart_writing))
/ blockswritten * tapesize;
- (void)snprintf(msgbuf, sizeof(msgbuf),
+ /* XXX not safe due to floating point printf */
+ dprintf(STDERR_FILENO,
"dump: %s %3.2f%% done at %lld KB/s, finished in %d:%02d\n",
tape, (blockswritten * 100.0) / tapesize,
(spcl.c_tapea - tapea_volume) / (tnow - tstart_volume),
(int)(deltat / 3600), (int)((deltat % 3600) / 60));
- write(STDERR_FILENO, msgbuf, strlen(msgbuf));
errno = save_errno;
}
-/* $OpenBSD: lib.c,v 1.24 2017/10/09 14:51:31 deraadt Exp $ */
+/* $OpenBSD: lib.c,v 1.25 2017/12/08 17:04:15 deraadt Exp $ */
/****************************************************************
Copyright (C) Lucent Technologies 1997
All Rights Reserved
void fpecatch(int sig)
{
extern Node *curnode;
- char buf[1024];
- snprintf(buf, sizeof buf, "floating point exception\n");
- write(STDERR_FILENO, buf, strlen(buf));
+ dprintf(STDERR_FILENO, "floating point exception\n");
if (compile_time != 2 && NR && *NR > 0) {
- snprintf(buf, sizeof buf, " input record number %d", (int) (*FNR));
- write(STDERR_FILENO, buf, strlen(buf));
-
+ dprintf(STDERR_FILENO, " input record number %d", (int) (*FNR));
if (strcmp(*FILENAME, "-") != 0) {
- snprintf(buf, sizeof buf, ", file %s", *FILENAME);
- write(STDERR_FILENO, buf, strlen(buf));
+ dprintf(STDERR_FILENO, ", file %s", *FILENAME);
}
- write(STDERR_FILENO, "\n", 1);
+ dprintf(STDERR_FILENO, "\n");
}
if (compile_time != 2 && curnode) {
- snprintf(buf, sizeof buf, " source line number %d", curnode->lineno);
- write(STDERR_FILENO, buf, strlen(buf));
+ dprintf(STDERR_FILENO, " source line number %d", curnode->lineno);
} else if (compile_time != 2 && lineno) {
- snprintf(buf, sizeof buf, " source line number %d", lineno);
- write(STDERR_FILENO, buf, strlen(buf));
+ dprintf(STDERR_FILENO, " source line number %d", lineno);
}
if (compile_time == 1 && cursource() != NULL) {
- snprintf(buf, sizeof buf, " source file %s", cursource());
- write(STDERR_FILENO, buf, strlen(buf));
+ dprintf(STDERR_FILENO, " source file %s", cursource());
}
- write(STDERR_FILENO, "\n", 1);
+ dprintf(STDERR_FILENO, "\n");
if (dbg > 1) /* core dump if serious debugging on */
abort();
_exit(1);
-/* $OpenBSD: chpass.c,v 1.43 2015/11/26 19:01:47 deraadt Exp $ */
+/* $OpenBSD: chpass.c,v 1.44 2017/12/08 17:04:15 deraadt Exp $ */
/* $NetBSD: chpass.c,v 1.8 1996/05/15 21:50:43 jtc Exp $ */
/*-
void
kbintr(int signo)
{
- struct iovec iv[5];
-
- iv[0].iov_base = "\n";
- iv[0].iov_len = 1;
- iv[1].iov_base = __progname;
- iv[1].iov_len = strlen(__progname);
- iv[2].iov_base = ": ";
- iv[2].iov_len = 2;
- iv[3].iov_base = _PATH_MASTERPASSWD;
- iv[3].iov_len = sizeof(_PATH_MASTERPASSWD) - 1;
- iv[4].iov_base = " unchanged\n";
- iv[4].iov_len = 11;
- writev(STDERR_FILENO, iv, 5);
-
+ dprintf(STDERR_FILENO, "\n%s: %s unchanged\n",
+ __progname, _PATH_MASTERPASSWD);
_exit(1);
}
-/* $OpenBSD: misc.c,v 1.15 2015/07/14 17:18:48 millert Exp $ */
+/* $OpenBSD: misc.c,v 1.16 2017/12/08 17:04:15 deraadt Exp $ */
/*-
* Copyright (c) 1990, 1993
{
int save_errno = errno;
extern FTSENT *entry;
- struct iovec iov[3];
if (entry != NULL) {
- iov[0].iov_base = "find path: ";
- iov[0].iov_len = strlen(iov[0].iov_base);
- iov[1].iov_base = entry->fts_path;
- iov[1].iov_len = entry->fts_pathlen;
- iov[2].iov_base = "\n";
- iov[2].iov_len = strlen(iov[2].iov_base);
- writev(STDERR_FILENO, iov, 3);
+ dprintf(STDERR_FILENO, "find path: %*s\n",
+ entry->fts_pathlen, entry->fts_path);
errno = save_errno;
}
}
-/* $OpenBSD: login.c,v 1.68 2016/08/21 03:26:04 beck Exp $ */
+/* $OpenBSD: login.c,v 1.69 2017/12/08 17:04:15 deraadt Exp $ */
/* $NetBSD: login.c,v 1.13 1996/05/15 23:50:16 jtc Exp $ */
/*-
void
timedout(int signo)
{
- char warn[1024];
-
- snprintf(warn, sizeof warn,
+ dprintf(STDERR_FILENO,
"Login timed out after %d seconds\n", timeout);
- write(STDERR_FILENO, warn, strlen(warn));
if (username)
badlogin(username);
_exit(0);
-/* $OpenBSD: advcap.c,v 1.17 2015/10/25 22:36:17 jca Exp $ */
+/* $OpenBSD: advcap.c,v 1.18 2017/12/08 17:04:15 deraadt Exp $ */
/* $KAME: advcap.c,v 1.9 2002/05/29 14:28:35 itojun Exp $ */
/*
break;
}
if (cp >= bp + BUFSIZ) {
- write(STDERR_FILENO, "Remcap entry too long\n", 23);
+ dprintf(STDERR_FILENO, "Remcap entry too long\n");
break;
} else
*cp++ = c;
p = tbuf + strlen(tbuf) - 2; /* before the last colon */
while (*--p != ':')
if (p < tbuf) {
- write(STDERR_FILENO, "Bad remcap entry\n", 18);
+ dprintf(STDERR_FILENO, "Bad remcap entry\n");
return (0);
}
p++;
q++;
*q = 0;
if (++hopcount > MAXHOP) {
- write(STDERR_FILENO, "Infinite tc= loop\n", 18);
+ dprintf(STDERR_FILENO, "Infinite tc= loop\n");
return (0);
}
if (getent(tcbuf, tcname, remotefile) != 1) {
;
l = p - holdtbuf + strlen(q);
if (l > BUFSIZ) {
- write(STDERR_FILENO, "Remcap entry too long\n", 23);
+ dprintf(STDERR_FILENO, "Remcap entry too long\n");
q[BUFSIZ - (p-holdtbuf)] = 0;
}
strlcpy(p, q, holdtbuf + BUFSIZ - p);
-/* $OpenBSD: tcpdump.c,v 1.80 2017/09/08 19:10:57 brynet Exp $ */
+/* $OpenBSD: tcpdump.c,v 1.81 2017/12/08 17:04:15 deraadt Exp $ */
/*
* Copyright (c) 1988, 1989, 1990, 1991, 1992, 1993, 1994, 1995, 1996, 1997
{
struct pcap_stat stat;
sigset_t allsigs;
- char buf[1024];
sigfillset(&allsigs);
sigprocmask(SIG_BLOCK, &allsigs, NULL);
/* Can't print the summary if reading from a savefile */
- (void)write(STDERR_FILENO, "\n", 1);
+ dprintf(STDERR_FILENO, "\n");
if (pd != NULL && pcap_file(pd) == NULL) {
if (priv_pcap_stats(&stat) < 0) {
- (void)snprintf(buf, sizeof buf,
+ dprintf(STDERR_FILENO,
"pcap_stats: %s\n", pcap_geterr(pd));
- write(STDERR_FILENO, buf, strlen(buf));
} else {
- (void)snprintf(buf, sizeof buf,
+ dprintf(STDERR_FILENO,
"%u packets received by filter\n", stat.ps_recv);
- write(STDERR_FILENO, buf, strlen(buf));
- (void)snprintf(buf, sizeof buf,
+ dprintf(STDERR_FILENO,
"%u packets dropped by kernel\n", stat.ps_drop);
- write(STDERR_FILENO, buf, strlen(buf));
}
}
_exit(0);