[Patch] Prevent smbtree from aborting on Fedora Core 3

Jay Fenlason fenlason at redhat.com
Wed Sep 29 14:55:04 GMT 2004


The attached patch to the x_fclose function makes smbtree stop
aborting on startup on Fedora Core 3 (or other systems that use a
recent glibc).

I'm not convinced that this is the correct fix (I think it's rather
suspicious that smbtree sets the log file to stderr and promptly
closes it.)

The failure mode is that if x_fclose is called on x_stdin, x_stdout
or x_stderr, SAFE_FREE gets called with the address of a constant
structure.  Newer glibc detects free being called with a wild pointer
and aborts.

			-- JF


--- samba-3.0.8pre1/source/lib/#xfile.c~	2004-09-28 17:01:29.000000000 -0400
+++ samba-3.0.8pre1/source/lib/xfile.c	2004-09-28 17:01:29.000000000 -0400
@@ -135,7 +135,9 @@
 		memset(f->buf, 0, f->bufsize);
 		SAFE_FREE(f->buf);
 	}
-	SAFE_FREE(f);
+	if ( f != &_x_stdin && f != &_x_stdout && f != &_x_stderr ) {
+	    SAFE_FREE(f);
+	}
 	return ret;
 }
 


More information about the samba-technical mailing list