Skip to content

Commit

Permalink
Make DISKFS_NAME_MAX a distinct symbol.
Browse files Browse the repository at this point in the history
Check for name length in diskfs_dirent_create_file_or_dir.
  • Loading branch information
dthain committed Dec 18, 2023
1 parent 220920a commit 3a267ef
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 1 deletion.
2 changes: 2 additions & 0 deletions kernel/diskfs.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
5 changes: 4 additions & 1 deletion kernel/diskfs.h
Original file line number Diff line number Diff line change
Expand Up @@ -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()

Expand Down

0 comments on commit 3a267ef

Please sign in to comment.