Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/external/mpl/dhcp/dist/omapip Don't use static buffers to st...



details:   https://anonhg.NetBSD.org/src/rev/a6b5befef6ec
branches:  trunk
changeset: 956971:a6b5befef6ec
user:      christos <christos%NetBSD.org@localhost>
date:      Thu Nov 12 22:11:03 2020 +0000

description:
Don't use static buffers to store format strings; this is a multi-threaded
program and if we print from multiple threads we can end up overwriting the
formats while printf is formating and that can end up in tears.

diffstat:

 external/mpl/dhcp/dist/omapip/errwarn.c |  14 ++++++++++----
 1 files changed, 10 insertions(+), 4 deletions(-)

diffs (62 lines):

diff -r 96adcc149655 -r a6b5befef6ec external/mpl/dhcp/dist/omapip/errwarn.c
--- a/external/mpl/dhcp/dist/omapip/errwarn.c   Thu Nov 12 21:54:52 2020 +0000
+++ b/external/mpl/dhcp/dist/omapip/errwarn.c   Thu Nov 12 22:11:03 2020 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: errwarn.c,v 1.3 2020/08/03 21:10:57 christos Exp $     */
+/*     $NetBSD: errwarn.c,v 1.4 2020/11/12 22:11:03 christos Exp $     */
 
 /* errwarn.c
 
@@ -34,7 +34,7 @@
  */
 
 #include <sys/cdefs.h>
-__RCSID("$NetBSD: errwarn.c,v 1.3 2020/08/03 21:10:57 christos Exp $");
+__RCSID("$NetBSD: errwarn.c,v 1.4 2020/11/12 22:11:03 christos Exp $");
 
 #include "dhcpd.h"
 
@@ -50,14 +50,14 @@
 void (*log_cleanup) (void);
 
 #define CVT_BUF_MAX 1023
-static char mbuf [CVT_BUF_MAX + 1];
-static char fbuf [CVT_BUF_MAX + 1];
 
 /* Log an error message, then exit... */
 
 void log_fatal (const char * fmt, ... )
 {
   va_list list;
+  char mbuf [CVT_BUF_MAX + 1];
+  char fbuf [CVT_BUF_MAX + 1];
 
   do_percentm (fbuf, sizeof fbuf, fmt);
 
@@ -96,6 +96,8 @@
 
 int log_error (const char * fmt, ...)
 {
+  char mbuf [CVT_BUF_MAX + 1];
+  char fbuf [CVT_BUF_MAX + 1];
   va_list list;
 
   do_percentm (fbuf, sizeof fbuf, fmt);
@@ -123,6 +125,8 @@
 
 int log_info (const char *fmt, ...)
 {
+  char mbuf [CVT_BUF_MAX + 1];
+  char fbuf [CVT_BUF_MAX + 1];
   va_list list;
 
   do_percentm (fbuf, sizeof fbuf, fmt);
@@ -150,6 +154,8 @@
 
 int log_debug (const char *fmt, ...)
 {
+  char mbuf [CVT_BUF_MAX + 1];
+  char fbuf [CVT_BUF_MAX + 1];
   va_list list;
 
   do_percentm (fbuf, sizeof fbuf, fmt);



Home | Main Index | Thread Index | Old Index