Don't read or write more bytes than the buffer you provide is large. On reading
it would overwrite memory and on writing it would crash further down when the buffer is accessed. Fixes #4383. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@32857 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
parent
9e15ae596c
commit
1aa8877afe
@ -247,8 +247,8 @@ PartitionMapWriter::_ReadBlock(off_t partitionOffset,
|
||||
if (partitionOffset < 0)
|
||||
return B_BAD_VALUE;
|
||||
// TODO: If fBlockSize > sizeof(partition_table) then stop/read NULL after
|
||||
if (read_pos(fDeviceFD, partitionOffset, &partitionTable, fBlockSize)
|
||||
!= fBlockSize) {
|
||||
if (read_pos(fDeviceFD, partitionOffset, &partitionTable,
|
||||
sizeof(partitionTable)) != sizeof(partitionTable)) {
|
||||
status_t error = errno;
|
||||
if (error == B_OK)
|
||||
error = B_IO_ERROR;
|
||||
@ -266,9 +266,10 @@ PartitionMapWriter::_WriteBlock(off_t partitionOffset,
|
||||
{
|
||||
if (partitionOffset < 0)
|
||||
return B_BAD_VALUE;
|
||||
// TODO: If fBlockSize > sizeof(partition_table) then stop/write NULL after
|
||||
if (write_pos(fDeviceFD, partitionOffset, &partitionTable, fBlockSize)
|
||||
!= fBlockSize) {
|
||||
// TODO: maybe clear the rest of the block if
|
||||
// fBlockSize > sizeof(partition_table)?
|
||||
if (write_pos(fDeviceFD, partitionOffset, &partitionTable,
|
||||
sizeof(partitionTable)) != sizeof(partitionTable)) {
|
||||
status_t error = errno;
|
||||
if (error == B_OK)
|
||||
error = B_IO_ERROR;
|
||||
|
Loading…
Reference in New Issue
Block a user