summaryrefslogtreecommitdiff
path: root/usr.sbin
diff options
context:
space:
mode:
authorHenning Brauer <henning@cvs.openbsd.org>2004-01-19 23:15:09 +0000
committerHenning Brauer <henning@cvs.openbsd.org>2004-01-19 23:15:09 +0000
commit1c6d93cfdb6fee121b75af1e5addc4bd9513773d (patch)
tree2a53a5f042a3f81dc711d03963f731e8b18905c5 /usr.sbin
parent619e62d5c5c1e5c61f637513ec8cab3cc0ca047b (diff)
(v)fprintf atomically in vlog() in debug mode, prodded by theo
Diffstat (limited to 'usr.sbin')
-rw-r--r--usr.sbin/bgpd/log.c14
1 files changed, 11 insertions, 3 deletions
diff --git a/usr.sbin/bgpd/log.c b/usr.sbin/bgpd/log.c
index c377b95364c..d3557e0335a 100644
--- a/usr.sbin/bgpd/log.c
+++ b/usr.sbin/bgpd/log.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: log.c,v 1.15 2004/01/06 03:43:50 henning Exp $ */
+/* $OpenBSD: log.c,v 1.16 2004/01/19 23:15:08 henning Exp $ */
/*
* Copyright (c) 2003, 2004 Henning Brauer <henning@openbsd.org>
@@ -142,9 +142,17 @@ logit(int pri, const char *fmt, ...)
void
vlog(int pri, const char *fmt, va_list ap)
{
+ char *nfmt;
+
if (debug) {
- vfprintf(stderr, fmt, ap);
- fprintf(stderr, "\n");
+ /* best effort in out of mem situations */
+ if (asprintf(&nfmt, "%s\n", fmt) == -1) {
+ vfprintf(stderr, fmt, ap);
+ fprintf(stderr, "\n");
+ } else {
+ vfprintf(stderr, nfmt, ap);
+ free(nfmt);
+ }
} else
vsyslog(pri, fmt, ap);
}