Kernel: Null terminate ext2 directory entries

This fixes a weird bug with `ls /bin`
This commit is contained in:
Bananymous 2024-09-12 23:54:58 +03:00
parent 7f25ddc229
commit 57e76a65a4
1 changed files with 3 additions and 1 deletions

View File

@ -343,7 +343,9 @@ done:
{
dirp->d_ino = entry.inode;
dirp->d_type = entry.file_type;
strncpy(dirp->d_name, entry.name, entry.name_len);
const size_t name_len = BAN::Math::min<size_t>(entry.name_len, sizeof(dirp->d_name) - 1);
strncpy(dirp->d_name, entry.name, name_len);
dirp->d_name[name_len] = '\0';
dirp++;
}
entry_span = entry_span.slice(entry.rec_len);