Bus Error with openssh 3.7.1p1 on 64-bit Sparc/Solaris

Matthias Koeppe mkoeppe at mail.math.uni-magdeburg.de
Fri Sep 26 02:54:43 EST 2003


I compiled openssh 3.7.1p1 on Solaris 9 with the Forte compiler in
64-bit mode.  After authentication, a forked child of sshd dies with a
Bus Error in `read_etc_default_login' (session.c).

The reason is the use of `sscanf' with control string "%5lo" on a
`mode_t' value.  On Solaris in 64-bit mode, `mode_t' is an `unsigned
int' (32 bits), whereas `long' is 64 bits.

Here is a change that fixed the problem for me.  You might want to fix
it in cleaner way, however.

Regards,
Matthias

diff -u /home/mkoeppe/s/ATTIC/openssh-3.7.1p1/session.c\~ /home/mkoeppe/s/ATTIC/openssh-3.7.1p1/session.c
--- /home/mkoeppe/s/ATTIC/openssh-3.7.1p1/session.c~	Tue Sep 16 03:52:19 2003
+++ /home/mkoeppe/s/ATTIC/openssh-3.7.1p1/session.c	Thu Sep 25 18:50:00 2003
@@ -915,6 +915,7 @@
 	u_int i;
 	size_t tmpenvsize = 0;
 	mode_t mask;
+	unsigned long long_mask;
 
 	/*
 	 * We don't want to copy the whole file to the child's environment,
@@ -931,8 +932,10 @@
 		child_set_env(env, envsize, "PATH", var);
 	
 	if ((var = child_get_env(tmpenv, "UMASK")) != NULL)
-		if (sscanf(var, "%5lo", &mask) == 1)
+		if (sscanf(var, "%5lo", &long_mask) == 1) {
+			mask = (mode_t) long_mask;
 			umask(mask);
+		}
 	
 	for (i = 0; tmpenv[i] != NULL; i++)
 		xfree(tmpenv[i]);

-- 
Matthias Koeppe -- http://www.math.uni-magdeburg.de/~mkoeppe




More information about the openssh-unix-dev mailing list