Ticket #1943: 01_namelen.patch

File 01_namelen.patch, 1.4 KB (added by mcermak, 15 years ago)
  • vfs/vfs.c

    old new  
    801801         * d_name in it. Moreover, linux's glibc-2.9 allocates dirents _less_, 
    802802         * than 'sizeof (struct dirent)' making full bitwise (sizeof dirent) copy 
    803803         * heap corrupter. So, allocate longliving dirent with at least 
    804          * (NAME_MAX + 1) for d_name in it. 
     804         * (MAXNAMLEN + 1) for d_name in it. 
    805805         * Strictly saying resulting dirent is unusable as we don't adjust internal 
    806806         * structures, holding dirent size. But we don't use it in libc infrastructure. 
    807807         * TODO: to make simpler homemade dirent-alike structure. 
    808808         */ 
    809         mc_readdir_result = (struct dirent *) g_malloc (sizeof(struct dirent) + NAME_MAX + 1); 
     809        mc_readdir_result = (struct dirent *) g_malloc (sizeof(struct dirent) + MAXNAMLEN + 1); 
    810810    } 
    811811 
    812812    if (!dirp) { 
     
    827827        state = str_vfs_convert_from (dirinfo->converter, 
    828828                                          entry->d_name, vfs_str_buffer); 
    829829        mc_readdir_result->d_ino = entry->d_ino; 
    830         g_strlcpy (mc_readdir_result->d_name, vfs_str_buffer->str, NAME_MAX + 1); 
     830        g_strlcpy (mc_readdir_result->d_name, vfs_str_buffer->str, MAXNAMLEN + 1); 
    831831    } 
    832832    if (entry == NULL) errno = vfs->readdir ? ferrno (vfs) : E_NOTSUPP; 
    833833    return (entry != NULL) ? mc_readdir_result : NULL;