[PATCH] fix dhcp log concurrency problem

classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

[PATCH] fix dhcp log concurrency problem

QiuXi
When running dhcp client on Linux, it gets corrupted randomly.
Then we found in function log_debug/log_info/log_error..,there exists
a concurrency problem, now to fix it.

modified:   omapip/errwarn.c

diff --git a/omapip/errwarn.c b/omapip/errwarn.c
index 6317fe4c..46d13fe9 100644
--- a/omapip/errwarn.c
+++ b/omapip/errwarn.c
@@ -45,14 +45,14 @@ int log_perror = 1;
 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);
 
@@ -92,6 +92,8 @@ void log_fatal (const char * fmt, ... )
 int log_error (const char * fmt, ...)
 {
   va_list list;
+  char mbuf [CVT_BUF_MAX + 1];
+  char fbuf [CVT_BUF_MAX + 1];
 
   do_percentm (fbuf, sizeof fbuf, fmt);
 
@@ -119,6 +121,8 @@ int log_error (const char * fmt, ...)
 int log_info (const char *fmt, ...)
 {
   va_list list;
+  char mbuf [CVT_BUF_MAX + 1];
+  char fbuf [CVT_BUF_MAX + 1];
 
   do_percentm (fbuf, sizeof fbuf, fmt);
 
@@ -146,6 +150,8 @@ int log_info (const char *fmt, ...)
 int log_debug (const char *fmt, ...)
 {
   va_list list;
+  char mbuf [CVT_BUF_MAX + 1];
+  char fbuf [CVT_BUF_MAX + 1];
 
   do_percentm (fbuf, sizeof fbuf, fmt);
 
--
2.12.3

_______________________________________________
ISC funds the development of this software with paid support subscriptions. Contact us at https://www.isc.org/contact/ for more information.

dhcp-users mailing list
[hidden email]
https://lists.isc.org/mailman/listinfo/dhcp-users
Reply | Threaded
Open this post in threaded view
|

Re: [PATCH] fix dhcp log concurrency problem

Rongxing Liu
Nice patch!

On Wed, Dec 23, 2020 at 11:21 AM QiuXi <[hidden email]> wrote:
When running dhcp client on Linux, it gets corrupted randomly.
Then we found in function log_debug/log_info/log_error..,there exists
a concurrency problem, now to fix it.

modified:   omapip/errwarn.c

diff --git a/omapip/errwarn.c b/omapip/errwarn.c
index 6317fe4c..46d13fe9 100644
--- a/omapip/errwarn.c
+++ b/omapip/errwarn.c
@@ -45,14 +45,14 @@ int log_perror = 1;
 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);

@@ -92,6 +92,8 @@ void log_fatal (const char * fmt, ... )
 int log_error (const char * fmt, ...)
 {
   va_list list;
+  char mbuf [CVT_BUF_MAX + 1];
+  char fbuf [CVT_BUF_MAX + 1];

   do_percentm (fbuf, sizeof fbuf, fmt);

@@ -119,6 +121,8 @@ int log_error (const char * fmt, ...)
 int log_info (const char *fmt, ...)
 {
   va_list list;
+  char mbuf [CVT_BUF_MAX + 1];
+  char fbuf [CVT_BUF_MAX + 1];

   do_percentm (fbuf, sizeof fbuf, fmt);

@@ -146,6 +150,8 @@ int log_info (const char *fmt, ...)
 int log_debug (const char *fmt, ...)
 {
   va_list list;
+  char mbuf [CVT_BUF_MAX + 1];
+  char fbuf [CVT_BUF_MAX + 1];

   do_percentm (fbuf, sizeof fbuf, fmt);

--
2.12.3

_______________________________________________
ISC funds the development of this software with paid support subscriptions. Contact us at https://www.isc.org/contact/ for more information.

dhcp-users mailing list
[hidden email]
https://lists.isc.org/mailman/listinfo/dhcp-users

_______________________________________________
ISC funds the development of this software with paid support subscriptions. Contact us at https://www.isc.org/contact/ for more information.

dhcp-users mailing list
[hidden email]
https://lists.isc.org/mailman/listinfo/dhcp-users