diff --git a/kernel/diskfs.c b/kernel/diskfs.c index 42efb6e5..a0227cad 100644 --- a/kernel/diskfs.c +++ b/kernel/diskfs.c @@ -391,6 +391,8 @@ static int diskfs_dirent_add( struct fs_dirent *d, const char *name, int type, i struct fs_dirent * diskfs_dirent_create_file_or_dir( struct fs_dirent *d, const char *name, int type ) { + if(strlen(name)>DISKFS_NAME_MAX) return 0; // KERROR_NAME_TOO_LONG + struct fs_dirent *t = diskfs_dirent_lookup(d,name); if(t) { diskfs_dirent_close(t); diff --git a/kernel/diskfs.h b/kernel/diskfs.h index ddf85d37..ee63efb3 100644 --- a/kernel/diskfs.h +++ b/kernel/diskfs.h @@ -38,12 +38,15 @@ struct diskfs_inode { #define DISKFS_ITEM_FILE 1 #define DISKFS_ITEM_DIR 2 +/* Maximum name length chosen so that diskfs_item is 32 bytes. */ +#define DISKFS_NAME_MAX 26 + #pragma pack(1) struct diskfs_item { uint32_t inumber; uint8_t type; uint8_t name_length; - char name[26]; + char name[DISKFS_NAME_MAX]; }; #pragma pack()