zorajiang / mongoose

Automatically exported from code.google.com/p/mongoose
0 stars 0 forks source link

Windows: server stops unintentionally when enumerating directrories #79

Closed GoogleCodeExporter closed 8 years ago

GoogleCodeExporter commented 8 years ago
What steps will reproduce the problem?
1. start the sample program that is delivered as example.c
2. click link "aliased c:\ directory"
3. server stops unintentionally as soon pagefile.sys is to be printed

What is the expected output? What do you see instead?
Expected: the whole directory is printes
Instead: only the files/directories before pagefile.sys are printed, server
stops

What version of the product are you using? On what operating system?
I am using V2.8 on Windows XP SP3

2 related issues: 
line 2660: (void) mg_stat(path, &entries[num_entries].st);
- mg_stat fails on file pagefile.sys 
- return value is not handled
- entries[num_entries].st is invalid

line 2576:(void) strftime(mod, sizeof(mod), "%d-%b-%Y %H:%M",
        localtime(&de->st.mtime));
- if de->st is invalid, localtime fails
- if localtime fails (as not checked) ==> server stops

Original issue reported on code.google.com by tneuhofer@gmail.com on 3 Aug 2009 at 3:25

GoogleCodeExporter commented 8 years ago
Hi there,

I can reproduce this when running in an ordinary user account on Vista. It 
occurs 
when access to the stats for a file is denied.  

I suggest clearing the buffer returned by mg_stat, so that the server will at 
least 
return something (relatively) sensible:

static int
mg_stat(const char *path, struct mgstat *stp)
{
    int             ok = -1; /* Error */
    wchar_t             wbuf[FILENAME_MAX];
    WIN32_FILE_ATTRIBUTE_DATA   info;

        /* *************** ADD THIS LINE: ******************** */
        memset(stp, 0, sizeof(struct mgstat));

The server will now report a date of 'zero', e.g.
    pagefile.sys     01-Jan-1970 00:00    0

I hope this helps.

Cheers
Alistair

Original comment by alistair.brightman%blueyonder.co.uk@gtempaccount.com on 6 Aug 2009 at 6:33

GoogleCodeExporter commented 8 years ago
Submitted http://code.google.com/p/mongoose/source/detail?r=465
Thank you.

Original comment by valenok on 14 Aug 2009 at 7:46

GoogleCodeExporter commented 8 years ago
Thank you very much,too!

Original comment by tneuhofer@gmail.com on 19 Aug 2009 at 2:58

GoogleCodeExporter commented 8 years ago
Issue 129 has been merged into this issue.

Original comment by valenok on 7 Sep 2010 at 8:50