From 60779adb24bbd974e68a9993a8eafd79a30ad887 Mon Sep 17 00:00:00 2001 From: jp161948 Date: Mon, 13 Nov 2006 09:43:40 -0800 Subject: 6477720 possible DoS in CRC compensation attack detector for SSH protocol 1 6481229 potential race in fatal_cleanup() in ssh --- usr/src/cmd/ssh/libssh/common/log.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) (limited to 'usr/src/cmd/ssh/libssh/common/log.c') diff --git a/usr/src/cmd/ssh/libssh/common/log.c b/usr/src/cmd/ssh/libssh/common/log.c index 4042d2ffd9..296c52a3f1 100644 --- a/usr/src/cmd/ssh/libssh/common/log.c +++ b/usr/src/cmd/ssh/libssh/common/log.c @@ -33,7 +33,7 @@ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ /* - * Copyright 2004 Sun Microsystems, Inc. All rights reserved. + * Copyright 2006 Sun Microsystems, Inc. All rights reserved. * Use is subject to license terms. */ @@ -45,6 +45,7 @@ RCSID("$OpenBSD: log.c,v 1.24 2002/07/19 15:43:33 markus Exp $"); #include "log.h" #include "xmalloc.h" +#include #include static LogLevel log_level = SYSLOG_LEVEL_INFO; @@ -262,16 +263,15 @@ fatal_remove_all_cleanups(void) fatal_cleanups = NULL; } -/* Cleanup and exit */ +/* Cleanup and exit. Make sure each cleanup is called only once. */ void fatal_cleanup(void) { struct fatal_cleanup *cu, *next_cu; - static int called = 0; + static volatile u_int called = 0; - if (called) + if (atomic_cas_uint(&called, 0, 1) == 1) exit(255); - called = 1; /* Call cleanup functions. */ for (cu = fatal_cleanups; cu; cu = next_cu) { next_cu = cu->next; -- cgit v1.2.3