* 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:
Axel Dörfler
2008-11-18 21:29:04 +00:00
parent 578dac0cf3
commit c58463ff10
+10 -11
View File
@@ -143,17 +143,14 @@ BBufferIO::Seek(off_t position, uint32 seekMode)
if (fStream == NULL)
return B_NO_INIT;
off_t newPosition = fPosition;
switch (seekMode) {
case SEEK_CUR:
fPosition += position;
if (fPosition < 0)
fPosition = 0;
newPosition += position;
break;
case SEEK_SET:
if (position < 0)
return B_BAD_VALUE;
fPosition = position;
newPosition = position;
break;
case SEEK_END:
{
@@ -162,14 +159,16 @@ BBufferIO::Seek(off_t position, uint32 seekMode)
if (status != B_OK)
return status;
fPosition = size - position;
if (fPosition < 0)
fPosition = 0;
newPosition = size - position;
break;
}
}
return fPosition;
if (newPosition < 0)
return B_BAD_VALUE;
fPosition = newPosition;
return newPosition;
}