Ticket #1943: 01_namelen.patch
File 01_namelen.patch, 1.4 KB (added by mcermak, 15 years ago) |
---|
-
vfs/vfs.c
old new 801 801 * d_name in it. Moreover, linux's glibc-2.9 allocates dirents _less_, 802 802 * than 'sizeof (struct dirent)' making full bitwise (sizeof dirent) copy 803 803 * 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. 805 805 * Strictly saying resulting dirent is unusable as we don't adjust internal 806 806 * structures, holding dirent size. But we don't use it in libc infrastructure. 807 807 * TODO: to make simpler homemade dirent-alike structure. 808 808 */ 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); 810 810 } 811 811 812 812 if (!dirp) { … … 827 827 state = str_vfs_convert_from (dirinfo->converter, 828 828 entry->d_name, vfs_str_buffer); 829 829 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); 831 831 } 832 832 if (entry == NULL) errno = vfs->readdir ? ferrno (vfs) : E_NOTSUPP; 833 833 return (entry != NULL) ? mc_readdir_result : NULL;