2.2-CVS failing on Solaris 8

Jeremy Allison jeremy at valinux.com
Thu Jun 21 19:53:48 GMT 2001


Michael Collin Nielsen wrote:
> 
> Hi
> 
> I ran gdb/xxgdb on smbd and placed a breakpoint just before the line in
> question, the variables has the following values:
> 
> 4: len = 4
> 3: (char *) tdb->map_ptr = 0xffffffff <Address 0xffffffff out of bounds>
> 2: off = 172
> 1: buf = (void *) 0xffbef5bc
> 
> is that close to what you need - map_ptr doesn't look good.

Arrggghhh ! Andrew did it to me again ! :-) :-).

I fixed this a month ago and it got regressed.

mmap returns -1 when it fails, not NULL.....

Here's the patch.

	Jeremy.

Index: tdb/tdb.c
===================================================================
RCS file: /data/cvs/samba/source/tdb/tdb.c,v
retrieving revision 1.35.4.25
diff -u -r1.35.4.25 tdb.c
--- tdb/tdb.c   11 Jun 2001 20:56:49 -0000      1.35.4.25
+++ tdb/tdb.c   21 Jun 2001 19:48:45 -0000
@@ -87,7 +87,13 @@
                tdb->map_ptr = mmap(NULL, tdb->map_size,
                                    PROT_READ|(tdb->read_only? 0:PROT_WRITE),
                                    MAP_SHARED|MAP_FILE, tdb->fd, 0);
-               if (!tdb->map_ptr) {
+
+               /*
+                * NB. When mmap fails it returns -1 *NOT* NULL !!!!
+                */
+
+               if (tdb->map_ptr == (void *)-1) {
+                       tdb->map_ptr = NULL;
                        TDB_LOG((tdb, 2, "tdb_mmap failed for size %d (%s)\n",
                                 tdb->map_size, strerror(errno)));
                }


-- 
--------------------------------------------------------
Buying an operating system without source is like buying
a self-assembly Space Shuttle with no instructions.
--------------------------------------------------------




More information about the samba-technical mailing list