Opened 12 years ago

Closed 12 years ago

#939 closed defect (fixed)

simple-directory-handler: error 500 on listing a directory with a link foo -> foo

Reported by: Mario Domenech Goulart Owned by: sjamaan
Priority: minor Milestone: someday
Component: extensions Version: 4.8.x
Keywords: spiffy, simple-directory-handler Cc:
Estimated difficulty:

Description

Here are the steps to reproduce the problem:

$ cat server.scm 
(use spiffy simple-directory-handler)

(handle-directory simple-directory-handler)

(start-server)

$ mkdir web
$ cd web
$ ln -s foo foo
$ cd ..
$ csi -s server.scm &
[1] 6379

$ wget http://localhost:8080
--2012-10-24 17:32:45--  http://localhost:8080/
Resolving localhost... ::1, 127.0.0.1
Connecting to localhost|::1|:8080... failed: Connection refused.
Connecting to localhost|127.0.0.1|:8080... connected.
HTTP request sent, awaiting response... [Wed Oct 24 17:32:45 2012] "GET http://localhost:8080/ HTTP/1.0" Error: (file-exists?)
system error while trying to access file
"./web//foo"

        Call history:

        display   
        spiffy#root-path          
        make-pathname     
        simple-directory-handler#simple-directory-dotfiles?       
        directory         
        sort      
        fold      
        spiffy#root-path          
        make-pathname     
        make-pathname     
        directory?        
        file-exists?      
        k695701   
        g699700   
        spiffy#handle-exception   
        with-output-to-string           <--


500 Internal Server Error
2012-10-24 17:32:45 ERROR 500: Internal Server Error.

The problem seems to be in simple-directory-handler's simple-directory-handler procedure, when it calls file-exists? in the fold body (around line 82).

The call to file-exists? seems to be due to the fact that (simple-directory-display-file) calls file-size and file-modification-time on the given file. That's actually subject to race conditions, so maybe it would be better to just handle exceptions in (simple-directory-display-file) when attempting those operations.

Change History (1)

comment:1 Changed 12 years ago by sjamaan

Resolution: fixed
Status: newclosed

Should be fixed in r27714. Thanks, Mario!

Note: See TracTickets for help on using tickets.