Changeset 2093

Show
Ignore:
Timestamp:
02/26/2008 04:22:08 PM (3 months ago)
Author:
stbuehler
Message:

r2098@chromobil: stefan | 2008-02-26 17:12:51 +0100
Fix #1574: Check for symlinks after successful pathinfo matching.

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • branches/lighttpd-1.4.x/src/response.c

    r2080 r2093  
    554554 
    555555                        do { 
    556                                 struct stat st; 
    557  
    558556                                if (slash) { 
    559557                                        buffer_copy_string_len(con->physical.path, srv->tmp_buf->ptr, slash - srv->tmp_buf->ptr); 
     
    562560                                } 
    563561 
    564                                 if (0 == stat(con->physical.path->ptr, &(st)) && 
    565                                     S_ISREG(st.st_mode)) { 
    566                                         found = 1; 
     562                                if (HANDLER_ERROR != stat_cache_get_entry(srv, con, con->physical.path, &sce)) { 
     563                                        found = S_ISREG(sce->st.st_mode); 
    567564                                        break; 
    568565                                } 
     
    595592                                return HANDLER_FINISHED; 
    596593                        } 
     594 
     595#ifdef HAVE_LSTAT 
     596                        if ((sce->is_symlink != 0) && !con->conf.follow_symlink) { 
     597                                con->http_status = 403; 
     598 
     599                                if (con->conf.log_request_handling) { 
     600                                        log_error_write(srv, __FILE__, __LINE__,  "s",  "-- access denied due symlink restriction"); 
     601                                        log_error_write(srv, __FILE__, __LINE__,  "sb", "Path         :", con->physical.path); 
     602                                } 
     603 
     604                                buffer_reset(con->physical.path); 
     605                                return HANDLER_FINISHED; 
     606                        }; 
     607#endif 
    597608 
    598609                        /* we have a PATHINFO */