samba-tng: Reproducible, incomprehensible segfaults

Luke Kenneth Casson Leighton lkcl at samba.org
Wed Feb 16 05:58:09 GMT 2000


steve, how does memset(p16, 0, 16) work instead of memset(p16, '\0', 16)?

On Wed, 16 Feb 2000, Steve Langasek wrote:

> 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
> 

<a href="mailto:lkcl at samba.org" > Luke Kenneth Casson Leighton    </a>
<a href="http://cb1.com/~lkcl"  > Samba and Network Development   </a>
<a href="http://samba.org"      > Samba Web site                  </a>
<a href="http://www.iss.net"    > Internet Security Systems, Inc. </a>
<a href="http://mcp.com"        > Macmillan Technical Publishing  </a>
 
ISBN1578701503 DCE/RPC over SMB: Samba and Windows NT Domain Internals
-------------- 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