* Seek() must always fail when the resulting offset would be smaller than 0
- "correcting" the offset to 0 is not what should happen. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@28688 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
@@ -143,17 +143,14 @@ BBufferIO::Seek(off_t position, uint32 seekMode)
|
|||||||
if (fStream == NULL)
|
if (fStream == NULL)
|
||||||
return B_NO_INIT;
|
return B_NO_INIT;
|
||||||
|
|
||||||
|
off_t newPosition = fPosition;
|
||||||
|
|
||||||
switch (seekMode) {
|
switch (seekMode) {
|
||||||
case SEEK_CUR:
|
case SEEK_CUR:
|
||||||
fPosition += position;
|
newPosition += position;
|
||||||
if (fPosition < 0)
|
|
||||||
fPosition = 0;
|
|
||||||
break;
|
break;
|
||||||
case SEEK_SET:
|
case SEEK_SET:
|
||||||
if (position < 0)
|
newPosition = position;
|
||||||
return B_BAD_VALUE;
|
|
||||||
|
|
||||||
fPosition = position;
|
|
||||||
break;
|
break;
|
||||||
case SEEK_END:
|
case SEEK_END:
|
||||||
{
|
{
|
||||||
@@ -162,14 +159,16 @@ BBufferIO::Seek(off_t position, uint32 seekMode)
|
|||||||
if (status != B_OK)
|
if (status != B_OK)
|
||||||
return status;
|
return status;
|
||||||
|
|
||||||
fPosition = size - position;
|
newPosition = size - position;
|
||||||
if (fPosition < 0)
|
|
||||||
fPosition = 0;
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return fPosition;
|
if (newPosition < 0)
|
||||||
|
return B_BAD_VALUE;
|
||||||
|
|
||||||
|
fPosition = newPosition;
|
||||||
|
return newPosition;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user