ufs2: Fix directory iteration.

The step is reclen. Honour it or we end up stepping in the middle of garbage
when OS aligns next entry to avoid crossing sector boundaries.

Change-Id: I749f9533d4d39e7a9abf9295b8e7c519dab52921
Reviewed-on: https://review.haiku-os.org/c/haiku/+/6851
Reviewed-by: Adrien Destugues <pulkomandy@pulkomandy.tk>
This commit is contained in:
Vladimir Serbinenko 2023-08-20 17:43:14 +02:00 committed by Adrien Destugues
parent de4f20d48d
commit dac0a050de

View File

@ -70,16 +70,10 @@ DirectoryIterator::GetNext(char* name, size_t* _nameLength, ino_t* _id)
dir direct;
size_t size = sizeof(dir);
status_t status = fInode->ReadAt(fOffset, (uint8_t*)&direct, &size);
if (size < 8 || direct.reclen < 8)
return B_ENTRY_NOT_FOUND;
if (status == B_OK) {
int remainder = direct.namlen % 4;
if(remainder != 0) {
remainder = 4 - remainder;
remainder = direct.namlen + remainder;
} else {
remainder = direct.namlen + 4;
}
fOffset = fOffset + 8 + remainder;
fOffset += direct.reclen;
if (direct.next_ino > 0) {
if ((direct.namlen + 1) > *_nameLength)