summaryrefslogtreecommitdiff
path: root/usr/src/cmd/ssh/libssh/common/log.c
diff options
context:
space:
mode:
authorjp161948 <none@none>2006-11-13 09:43:40 -0800
committerjp161948 <none@none>2006-11-13 09:43:40 -0800
commit60779adb24bbd974e68a9993a8eafd79a30ad887 (patch)
tree46745cb8248ea0c916f22d1053ef6e7a5c0d8906 /usr/src/cmd/ssh/libssh/common/log.c
parent84d68d8e929eb898bba40f17b9966212f1a66de8 (diff)
downloadillumos-gate-60779adb24bbd974e68a9993a8eafd79a30ad887.tar.gz
6477720 possible DoS in CRC compensation attack detector for SSH protocol 1
6481229 potential race in fatal_cleanup() in ssh
Diffstat (limited to 'usr/src/cmd/ssh/libssh/common/log.c')
-rw-r--r--usr/src/cmd/ssh/libssh/common/log.c10
1 files changed, 5 insertions, 5 deletions
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 <atomic.h>
#include <syslog.h>
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;