* vfs.h: Introduce union vfs_dirent to ensure that we have
enough space for the filename. * extfs.c (s_readdir): Use vfs_dirent. Avoid strcpy().
Этот коммит содержится в:
родитель
8b8d7de7ca
Коммит
37f335b8c0
@ -1,5 +1,9 @@
|
||||
2002-08-15 Pavel Roskin <proski@gnu.org>
|
||||
|
||||
* vfs.h: Introduce union vfs_dirent to ensure that we have
|
||||
enough space for the filename.
|
||||
* extfs.c (s_readdir): Use vfs_dirent. Avoid strcpy().
|
||||
|
||||
* direntry.c (vfs_s_readdir): Use compute_namelen().
|
||||
* extfs.c (s_readdir): Likewise.
|
||||
* mcfs.c (mcfs_readdir): Likewise.
|
||||
|
15
vfs/extfs.c
15
vfs/extfs.c
@ -882,21 +882,20 @@ static void * s_opendir (vfs *me, char *dirname)
|
||||
|
||||
static void * s_readdir (void *data)
|
||||
{
|
||||
static struct {
|
||||
struct dirent dir;
|
||||
#ifdef NEED_EXTRA_DIRENT_BUFFER
|
||||
char extra_buffer [MC_MAXPATHLEN];
|
||||
#endif
|
||||
} dir;
|
||||
static union vfs_dirent dir;
|
||||
int namelen;
|
||||
|
||||
struct entry **info = (struct entry **) data;
|
||||
|
||||
if (!*info)
|
||||
return NULL;
|
||||
|
||||
strcpy (&(dir.dir.d_name [0]), (*info)->name);
|
||||
namelen = min (strlen ((*info)->name), MC_MAXPATHLEN);
|
||||
|
||||
strncpy (dir.dent.d_name, (*info)->name, namelen);
|
||||
dir.dent.d_name[namelen] = 0;
|
||||
|
||||
compute_namelen (&dir.dir);
|
||||
compute_namelen (&dir.dent);
|
||||
*info = (*info)->next_in_dir;
|
||||
|
||||
return (void *)&dir;
|
||||
|
10
vfs/vfs.h
10
vfs/vfs.h
@ -103,6 +103,16 @@
|
||||
#endif
|
||||
};
|
||||
|
||||
/*
|
||||
* This union is used to ensure that there is enough space for the
|
||||
* filename (d_name) when the dirent structure is created.
|
||||
*/
|
||||
union vfs_dirent {
|
||||
struct dirent dent;
|
||||
char _extra_buffer [((int) &((struct dirent *)0)->d_name) +
|
||||
MC_MAXPATHLEN + 1];
|
||||
};
|
||||
|
||||
/* Other file systems */
|
||||
extern vfs vfs_local_ops;
|
||||
extern vfs vfs_nil_ops;
|
||||
|
Загрузка…
Ссылка в новой задаче
Block a user