Changeset 5022

Show
Ignore:
Timestamp:
10/31/07 11:24:56 (8 months ago)
Author:
morris
Message:

Don't read .wired/type files that are too big

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • wired/trunk/wired/files.c

    r4986 r5022  
    10471047static wd_file_type_t wd_files_type_with_stat(wi_string_t *path, struct stat *sbp) { 
    10481048        wi_string_t             *typepath, *string; 
     1049        struct stat             sb; 
     1050        wd_file_type_t  type; 
    10491051         
    10501052        if(!S_ISDIR(sbp->st_mode)) 
    10511053                return WD_FILE_TYPE_FILE; 
    10521054         
    1053         typepath        = wi_string_by_appending_path_component(path, WI_STR(WD_FILES_META_TYPE_PATH)); 
    1054         string          = wi_autorelease(wi_string_init_with_contents_of_file(wi_string_alloc(), typepath)); 
     1055        typepath = wi_string_by_appending_path_component(path, WI_STR(WD_FILES_META_TYPE_PATH)); 
     1056         
     1057        if(!wi_file_stat(typepath, &sb) || sb.st_size > 8) 
     1058                return WD_FILE_TYPE_DIR; 
     1059         
     1060        string = wi_autorelease(wi_string_init_with_contents_of_file(wi_string_alloc(), typepath)); 
    10551061         
    10561062        if(!string) 
     
    10591065        wi_string_delete_surrounding_whitespace(string); 
    10601066         
    1061         return wi_string_uint32(string); 
     1067        type = wi_string_uint32(string); 
     1068         
     1069        if(type == WD_FILE_TYPE_FILE) 
     1070                type = WD_FILE_TYPE_DIR; 
     1071         
     1072        return type; 
    10621073} 
    10631074