kernel: add assert in _user_read_dir
* This will help catch bugs such as in #15607. Change-Id: I25b28932f9db4e2abe8499dd829c910bb565086b Reviewed-on: https://review.haiku-os.org/c/haiku/+/2082 Reviewed-by: waddlesplash <waddlesplash@gmail.com>
This commit is contained in:
parent
3e818f2075
commit
2cf8f0ee6b
|
@ -984,6 +984,8 @@ _user_read_dir(int fd, struct dirent* userBuffer, size_t bufferSize,
|
||||||
if (status != B_OK)
|
if (status != B_OK)
|
||||||
return status;
|
return status;
|
||||||
|
|
||||||
|
ASSERT(count <= maxCount);
|
||||||
|
|
||||||
// copy the buffer back -- determine the total buffer size first
|
// copy the buffer back -- determine the total buffer size first
|
||||||
size_t sizeToCopy = 0;
|
size_t sizeToCopy = 0;
|
||||||
BytePointer<struct dirent> entry = buffer;
|
BytePointer<struct dirent> entry = buffer;
|
||||||
|
@ -993,6 +995,8 @@ _user_read_dir(int fd, struct dirent* userBuffer, size_t bufferSize,
|
||||||
entry += length;
|
entry += length;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
ASSERT(sizeToCopy <= bufferSize);
|
||||||
|
|
||||||
if (user_memcpy(userBuffer, buffer, sizeToCopy) != B_OK)
|
if (user_memcpy(userBuffer, buffer, sizeToCopy) != B_OK)
|
||||||
return B_BAD_ADDRESS;
|
return B_BAD_ADDRESS;
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue