diff --git a/src/add-ons/kernel/file_systems/bfs/BlockAllocator.cpp b/src/add-ons/kernel/file_systems/bfs/BlockAllocator.cpp index 2c3b312e3b..34f9e15997 100644 --- a/src/add-ons/kernel/file_systems/bfs/BlockAllocator.cpp +++ b/src/add-ons/kernel/file_systems/bfs/BlockAllocator.cpp @@ -1202,6 +1202,14 @@ BlockAllocator::CheckInode(Inode *inode, check_control *control) if (status < B_OK) return status; + if (inode->IsSymLink() && (inode->Flags() & INODE_LONG_SYMLINK) == 0) { + // symlinks may not have a valid data stream + if (strlen(inode->Node().short_symlink) >= SHORT_SYMLINK_NAME_LENGTH) + return B_BAD_DATA; + + return B_OK; + } + data_stream *data = &inode->Node().data; // check the direct range diff --git a/src/tests/add-ons/kernel/file_systems/bfs/r5/BlockAllocator.cpp b/src/tests/add-ons/kernel/file_systems/bfs/r5/BlockAllocator.cpp index 6af62c984d..bd55c4c984 100644 --- a/src/tests/add-ons/kernel/file_systems/bfs/r5/BlockAllocator.cpp +++ b/src/tests/add-ons/kernel/file_systems/bfs/r5/BlockAllocator.cpp @@ -1140,6 +1140,14 @@ BlockAllocator::CheckInode(Inode *inode, check_control *control) if (status < B_OK) return status; + if (inode->IsSymLink() && (inode->Flags() & INODE_LONG_SYMLINK) == 0) { + // symlinks may not have a valid data stream + if (strlen(inode->Node()->short_symlink) >= SHORT_SYMLINK_NAME_LENGTH) + return B_BAD_DATA; + + return B_OK; + } + data_stream *data = &inode->Node()->data; // check the direct range