samba-tng: Reproducible, incomprehensible segfaults

Steve Langasek vorlon at netexpress.net
Wed Feb 16 05:49:28 GMT 2000


On Wed, 16 Feb 2000, Luke Kenneth Casson Leighton wrote:

> we've had compile-problems (well, i have) related to smbencrypt.c and a
> couple of other files, before.

> no reports or occurrences for over two years, though.

> i suggest you try compiling without -O2, with -g, with neither etc.

> also, a pain-in-the-neck process that i had to use to narrow down compiler
> problems before (lattice c compiler for the atari st!) was to do a binary
> search, removing functions.

> in this case, you'd have to move them to... smbencrypt1.c otherwise you'd
> not get a link.

Well, seeing no other solution, I pulled apart the source file, and tracked
the problem down to the memset calls in lm_owf_gen and lm_owf_genW.  Replacing
memset() with bzero() fixes the problem.  I have /no/ idea why--but I've
attached a patch which Works For Me<tm>, and which ought to work for others
as well.

Steve Langasek
postmodern programmer
-------------- next part --------------
Index: libsmb/smbencrypt.c
===================================================================
RCS file: /cvsroot/samba/source/libsmb/smbencrypt.c,v
retrieving revision 1.46.2.15
diff -u -w -r1.46.2.15 smbencrypt.c
--- smbencrypt.c	2000/02/13 05:57:56	1.46.2.15
+++ smbencrypt.c	2000/02/16 05:38:00
@@ -139,7 +139,7 @@
 {
 	char pwrd[15];
 
-	memset(pwrd, '\0', 15);
+	bzero(pwrd, 15);
 	if (pwd != NULL)
 	{
 		unistr2_to_ascii(pwrd, pwd, sizeof(pwrd) - 1);
@@ -151,7 +151,7 @@
 
 	/* Calculate the SMB (lanman) hash functions of the password */
 
-	memset(p16, '\0', 16);
+	bzero(p16, 16);
 	E_P16((uchar *) pwrd, (uchar *) p16);
 
 #ifdef DEBUG_PASSWORD
@@ -168,7 +168,7 @@
 {
 	char pwrd[15];
 
-	memset(pwrd, '\0', 15);
+	bzero(pwrd, 15);
 	if (pwd != NULL)
 	{
 		safe_strcpy(pwrd, pwd, sizeof(pwrd) - 1);
@@ -180,7 +180,7 @@
 
 	/* Calculate the SMB (lanman) hash functions of the password */
 
-	memset(p16, '\0', 16);
+	bzero(p16, 16);
 	E_P16((uchar *) pwrd, (uchar *) p16);
 
 #ifdef DEBUG_PASSWORD


More information about the samba-technical mailing list