Hi,

The registry loader mmaps the "system.1st" file and then reads it.
However, if the file is empty (as in my case), then mmap() returns
success with (void *)0 as return value without having any valid address
mapped (it is not listed in /proc/xyz/maps). I do not know whether this
is a bug or a feature of either linux-kernel or glibc.

There are probably some other places in the source where this should be
checked and corrected if necessary.

Greetings Bertho

Changelog:
        * Mmap does not fail on zero-length files
diff -urX diffexclude cleancvs/misc/registry.c builtclean/misc/registry.c
--- cleancvs/misc/registry.c    Mon May  1 17:42:44 2000
+++ builtclean/misc/registry.c  Mon May  1 22:08:40 2000
@@ -1063,6 +1063,7 @@
        /* map the registry into the memory */
        if ((fd = open(full_name.long_name, O_RDONLY | O_NONBLOCK)) == -1) return 
FALSE;
        if ((fstat(fd, &st) == -1)) goto error;
+       if (!st.st_size) goto error;
        if ((base = mmap(NULL, st.st_size, PROT_READ, MAP_PRIVATE, fd, 0)) == 
MAP_FAILED) goto error;
 
        switch (*(LPDWORD)base)

Reply via email to