This is the mail archive of the cygwin mailing list for the Cygwin project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: Crash in g_file_monitor on 32-bit Cygwin


Hi Ken,

I know the code is not yours, but I have to vent while I see this code :)

On Oct 14 14:30, Ken Brown wrote:
> I stepped into gam_check_not_fat (which I should have done to begin with)
> and narrowed this down further.  The stack location in question gets
> clobbered by the call to GetVolumeInformation:
> 
> (gdb) s
> gam_check_not_fat (path=0x8005c068 "/tmp/fam-kbrown")
>     at /usr/src/debug/gamin-0.1.10-16/server/gam_channel.c:35
> 35        cygwin_conv_path(CCP_POSIX_TO_WIN_A, path, winpath, MAX_PATH);

Ouch.  What about paths longer than MAX_PATH?

> (gdb) x/x $ebp-0x510
> 0x28a6a8:       0x8005c068
> (gdb) n
> 37        pGVPN = GetProcAddress(LoadLibrary("kernel32"), "GetVolumePathNameA");

There's no reason to load GetVolumePathName from kernel32 since all supported
platforms provide this entry point.

> (gdb) x/x $ebp-0x510
> 0x28a6a8:       0x8005c068
> (gdb) n
> 38        if (!pGVPN || !(pGVPN)(winpath, root, MAX_PATH))
> (gdb) x/x $ebp-0x510
> 0x28a6a8:       0x8005c068
> (gdb) n
> 52        if (!GetVolumeInformation (root, volname, MAX_PATH, NULL,
> (gdb) x/x $ebp-0x510
> 0x28a6a8:       0x8005c068
> (gdb) n
> 58        if (!strncmp(fsname, "FAT", 3))       /* FAT, FAT32 */

How old is this code?  What *exactly* is this function trying to check?
I assume it's checking for certain filesystem capabilities, but then,
there's no good reason to check for a filesystem being "FAT" or "FAT32".
Any other filesystem might have the same or similar capabilities and
be called "FOOBAR".

Whatever the code is doing, it should probably simply call statvfs() and
check the f_flag member of the returned struct statvfs for a certain
flag.  The flags returned in f_flag are the same as the fs flags
returned by GetVolumeInformation.

So, what is it the code is trying to test by checking the FS name?


Corinna

-- 
Corinna Vinschen                  Please, send mails regarding Cygwin to
Cygwin Maintainer                 cygwin AT cygwin DOT com
Red Hat

Attachment: pgplBTbzCbp7L.pgp
Description: PGP signature


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]